fs: nfs: misused copy_to_user() return value
Subsystems (3)
PATCH 8/9 fs: nfs: misused copy_to_user() return value
copy_to_user() returns nonzero value on error, this value may be any value between 0 and requested count, not only requested count.
--- fs/nfs/idmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/nfs/idmap.c +1 -1
@@ -362,7 +362,7 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,unsigned long left; left =copy_to_user (dst, data, mlen); -if (left = mlen) { +if (left) msg->errno = -EFAULT ;return -EFAULT ; }
Signature · 1 line
1.7.0.4
Quoted 13 lines · Kulikov Vasiliy
copy_to_user()returns nonzero value on error, this value may be any value between 0 and requested count, not only requested count.Signed-off-by Kulikov Vasiliy <[email protected]>--- fs/nfs/idmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/nfs/idmap.c +0
-0
fs/nfs/idmap.c idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, · line 368
Quoted 8 lines
fs/nfs/idmap.c +1
-1@@ -362,7 +362,7 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,unsigned long left; left =copy_to_user (dst, data, mlen); -if (left = mlen) { +if (left) msg->errno = -EFAULT ;return -EFAULT ; }
...and we do handle the case where copy_to_user returns less than the requested number of bytes: it is called a 'short read' and is quite allowed in POSIX. The userland application can just call sys_read() again...
Trond
Quoted 16 lines · Trond Myklebust
Quoted 15 lines · Kulikov Vasiliy
copy_to_user()returns nonzero value on error, this value may be any value between 0 and requested count, not only requested count.Signed-off-by Kulikov Vasiliy <[email protected]>--- fs/nfs/idmap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/nfs/idmap.c +0
-0@@ -362,7 +362,7 @@ idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg,unsigned long left;
Quoted 11 lines
fs/nfs/idmap.c idmap_pipe_upcall(struct file *filp, struct rpc_pipe_msg *msg, · line 368
Quoted 6 lines
fs/nfs/idmap.c +1
-1left =copy_to_user (dst, data, mlen); -if (left = mlen) { +if (left) msg->errno = -EFAULT ;return -EFAULT ; }...and we do handle the case where
copy_to_userreturns less than the requested number of bytes: it is called a 'short read' and is quite allowed in POSIX. The userland application can just callsys_read()again...
Right, please ignore these 2 patches.
Quoted 2 lines
Trond