linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 8/9] fs: nfs: misused copy_to_user() return value
@ 2010-07-30 11:09 Kulikov Vasiliy
  2010-07-30 17:47 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Kulikov Vasiliy @ 2010-07-30 11:09 UTC (permalink / raw)
  To: kernel-janitors; +Cc: Trond Myklebust, linux-nfs, linux-kernel

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 <segooon@gmail.com>
---
 fs/nfs/idmap.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
index 21a84d4..a9f2cd5 100644
--- a/fs/nfs/idmap.c
+++ b/fs/nfs/idmap.c
@@ -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;
 	}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/9] fs: nfs: misused copy_to_user() return value
  2010-07-30 11:09 [PATCH 8/9] fs: nfs: misused copy_to_user() return value Kulikov Vasiliy
@ 2010-07-30 17:47 ` Trond Myklebust
       [not found]   ` <1280512047.12852.8.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2010-07-30 17:47 UTC (permalink / raw)
  To: Kulikov Vasiliy; +Cc: kernel-janitors, linux-nfs, linux-kernel

On Fri, 2010-07-30 at 15:09 +0400, Kulikov Vasiliy wrote:
> 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 <segooon@gmail.com>
> ---
>  fs/nfs/idmap.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
> index 21a84d4..a9f2cd5 100644
> --- a/fs/nfs/idmap.c
> +++ b/fs/nfs/idmap.c
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 8/9] fs: nfs: misused copy_to_user() return value
       [not found]   ` <1280512047.12852.8.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
@ 2010-07-30 18:03     ` Vasiliy Kulikov
  0 siblings, 0 replies; 3+ messages in thread
From: Vasiliy Kulikov @ 2010-07-30 18:03 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: kernel-janitors, linux-nfs, linux-kernel

On Fri, Jul 30, 2010 at 13:47 -0400, Trond Myklebust wrote:
> On Fri, 2010-07-30 at 15:09 +0400, Kulikov Vasiliy wrote:
> > 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 <segooon@gmail.com>
> > ---
> >  fs/nfs/idmap.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/fs/nfs/idmap.c b/fs/nfs/idmap.c
> > index 21a84d4..a9f2cd5 100644
> > --- a/fs/nfs/idmap.c
> > +++ b/fs/nfs/idmap.c
> > @@ -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...

Right, please ignore these 2 patches.

> 
> Trond

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-30 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-30 11:09 [PATCH 8/9] fs: nfs: misused copy_to_user() return value Kulikov Vasiliy
2010-07-30 17:47 ` Trond Myklebust
     [not found]   ` <1280512047.12852.8.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2010-07-30 18:03     ` Vasiliy Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).