diff options
author | Kirill Smelkov <kirr@nexedi.com> | 2019-04-12 12:31:57 +0300 |
---|---|---|
committer | Kirill Smelkov <kirr@nexedi.com> | 2019-05-06 17:46:52 +0300 |
commit | 438ab720c675a16d53bb18f76a94d25bbe420c45 (patch) | |
tree | f84b1009eb6918a07252b22089dde736cf2ff6d3 /drivers/infiniband | |
parent | c5bf68fe0c86a5835bd2e6aead1c49976360753f (diff) |
vfs: pass ppos=NULL to .read()/.write() of FMODE_STREAM files
This amends commit 10dce8af3422 ("fs: stream_open - opener for
stream-like files so that read and write can run simultaneously without
deadlock") in how position is passed into .read()/.write() handler for
stream-like files:
Rasmus noticed that we currently pass 0 as position and ignore any position
change if that is done by a file implementation. This papers over bugs if ppos
is used in files that declare themselves as being stream-like as such bugs will
go unnoticed. Even if a file implementation is correctly converted into using
stream_open, its read/write later could be changed to use ppos and even though
that won't be working correctly, that bug might go unnoticed without someone
doing wrong behaviour analysis. It is thus better to pass ppos=NULL into
read/write for stream-like files as that don't give any chance for ppos usage
bugs because it will oops if ppos is ever used inside .read() or .write().
Note 1: rw_verify_area, new_sync_{read,write} needs to be updated
because they are called by vfs_read/vfs_write & friends before
file_operations .read/.write .
Note 2: if file backend uses new-style .read_iter/.write_iter, position
is still passed into there as non-pointer kiocb.ki_pos . Currently
stream_open.cocci (semantic patch added by 10dce8af3422) ignores files
whose file_operations has *_iter methods.
Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Kirill Smelkov <kirr@nexedi.com>
Diffstat (limited to 'drivers/infiniband')
0 files changed, 0 insertions, 0 deletions