summaryrefslogtreecommitdiff
path: root/include/linux/timerqueue.h
diff options
context:
space:
mode:
authorChris Mason <mason@kernel.org>2026-11-01 13:34:40 +0100
committerChristian Brauner <brauner@kernel.org>2026-11-05 17:17:29 +0100
commitafa735786a89bde4959db52f20e3579de54ec740 (patch)
treedfc74b0b2fed1bd8b3a35fa4b64051aa5ea6fbde /include/linux/timerqueue.h
parent807c1d7125a2b3ca5705a803aa2e19f9d53d1ea3 (diff)
backing-file: pass RWF_NOAPPEND to synchronous writes
pwritev2() with RWF_NOAPPEND ignores the offset and appends the data on an overlayfs or FUSE passthrough file that was opened with O_APPEND, and the call still returns success. The flag must make the write go to the given offset even though the file is in append mode. Any user who can write to the file is affected, with the default mount options. overlayfs and FUSE passthrough forward the reads and writes on their files to a backing file on an underlying filesystem, through the helpers in fs/backing-file.c. The flag works for the file that the user opened: kiocb_set_rw_flags() clears IOCB_APPEND in the write's kiocb. It also copies RWF_NOAPPEND into ki_flags, as it does with every RWF_ flag. overlayfs and FUSE passthrough then pass the write on to the backing file. They opened it with the open flags of the user's file, so it is in append mode too. For a synchronous write, do_backing_file_write_iter() calls vfs_iter_write(), which sets up a new kiocb for the backing file. That kiocb starts out with IOCB_APPEND set. vfs_iter_write() is only given the flags of the user's kiocb that are in BACKING_IOCB_MASK, and RWF_NOAPPEND is not one of them. So nothing clears IOCB_APPEND again, and the data goes to the end of the file while the call returns success. An asynchronous write reuses the flags of the user's kiocb and is not affected. Reproduced by calling pwritev2() with RWF_NOAPPEND at offset 0, on an overlayfs file and on a FUSE passthrough file opened with O_APPEND: the data was at the end of the file afterwards. Fix this by adding RWF_NOAPPEND to BACKING_IOCB_MASK. Fixes: 73fa7547c70b ("vfs: add RWF_NOAPPEND flag for pwritev2") Cc: stable@vger.kernel.org Signed-off-by: Chris Mason <mason@kernel.org> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Link: https://patch.msgid.link/20261101123440.3184069-1-amir73il@gmail.com Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux/timerqueue.h')
0 files changed, 0 insertions, 0 deletions