linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] fs: nfsd: remove calls to simple_strtoll
@ 2013-10-26  2:33 Daniel Walker
  2013-10-26 18:41 ` J. Bruce Fields
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Walker @ 2013-10-26  2:33 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs, linux-kernel

Signed-off-by: Daniel Walker <dwalker@fifo99.com>
---
 fs/nfsd/fault_inject.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
index d620e7f..41165f0 100644
--- a/fs/nfsd/fault_inject.c
+++ b/fs/nfsd/fault_inject.c
@@ -125,20 +125,24 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
 	size_t size = min(sizeof(write_buf) - 1, len);
 	struct net *net = current->nsproxy->net_ns;
 	struct sockaddr_storage sa;
+	int ret = -EFAULT;
 	u64 val;
 
 	if (copy_from_user(write_buf, buf, size))
-		return -EFAULT;
+		return ret;
 	write_buf[size] = '\0';
 
 	size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
 	if (size > 0)
 		nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);
 	else {
-		val = simple_strtoll(write_buf, NULL, 0);
-		nfsd_inject_set(file_inode(file)->i_private, val);
+		ret = kstrtoll(write_buf, 0, &val);
+		if (ret == 0) {
+			nfsd_inject_set(file_inode(file)->i_private, val);
+			ret = len;
+		}
 	}
-	return len; /* on success, claim we got the whole input */
+	return ret; /* on success, claim we got the whole input */
 }
 
 static const struct file_operations fops_nfsd = {
-- 
1.8.3.2


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

* Re: [PATCH 2/3] fs: nfsd: remove calls to simple_strtoll
  2013-10-26  2:33 [PATCH 2/3] fs: nfsd: remove calls to simple_strtoll Daniel Walker
@ 2013-10-26 18:41 ` J. Bruce Fields
  2013-10-27 15:09   ` Daniel Walker
  0 siblings, 1 reply; 3+ messages in thread
From: J. Bruce Fields @ 2013-10-26 18:41 UTC (permalink / raw)
  To: Daniel Walker; +Cc: linux-nfs, linux-kernel

On Fri, Oct 25, 2013 at 07:33:12PM -0700, Daniel Walker wrote:
> Signed-off-by: Daniel Walker <dwalker@fifo99.com>
> ---
>  fs/nfsd/fault_inject.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
> index d620e7f..41165f0 100644
> --- a/fs/nfsd/fault_inject.c
> +++ b/fs/nfsd/fault_inject.c
> @@ -125,20 +125,24 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
>  	size_t size = min(sizeof(write_buf) - 1, len);
>  	struct net *net = current->nsproxy->net_ns;
>  	struct sockaddr_storage sa;
> +	int ret = -EFAULT;
>  	u64 val;
>  
>  	if (copy_from_user(write_buf, buf, size))
> -		return -EFAULT;
> +		return ret;
>  	write_buf[size] = '\0';
>  
>  	size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
>  	if (size > 0)
>  		nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);

If we take this branch, don't we end up returning -EFAULT below?

--b.

>  	else {
> -		val = simple_strtoll(write_buf, NULL, 0);
> -		nfsd_inject_set(file_inode(file)->i_private, val);
> +		ret = kstrtoll(write_buf, 0, &val);
> +		if (ret == 0) {
> +			nfsd_inject_set(file_inode(file)->i_private, val);
> +			ret = len;
> +		}
>  	}
> -	return len; /* on success, claim we got the whole input */
> +	return ret; /* on success, claim we got the whole input */
>  }
>  
>  static const struct file_operations fops_nfsd = {
> -- 
> 1.8.3.2
> 

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

* Re: [PATCH 2/3] fs: nfsd: remove calls to simple_strtoll
  2013-10-26 18:41 ` J. Bruce Fields
@ 2013-10-27 15:09   ` Daniel Walker
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Walker @ 2013-10-27 15:09 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs, linux-kernel

On Sat, Oct 26, 2013 at 02:41:24PM -0400, J. Bruce Fields wrote:
> On Fri, Oct 25, 2013 at 07:33:12PM -0700, Daniel Walker wrote:
> > Signed-off-by: Daniel Walker <dwalker@fifo99.com>
> > ---
> >  fs/nfsd/fault_inject.c | 12 ++++++++----
> >  1 file changed, 8 insertions(+), 4 deletions(-)
> > 
> > diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
> > index d620e7f..41165f0 100644
> > --- a/fs/nfsd/fault_inject.c
> > +++ b/fs/nfsd/fault_inject.c
> > @@ -125,20 +125,24 @@ static ssize_t fault_inject_write(struct file *file, const char __user *buf,
> >  	size_t size = min(sizeof(write_buf) - 1, len);
> >  	struct net *net = current->nsproxy->net_ns;
> >  	struct sockaddr_storage sa;
> > +	int ret = -EFAULT;
> >  	u64 val;
> >  
> >  	if (copy_from_user(write_buf, buf, size))
> > -		return -EFAULT;
> > +		return ret;
> >  	write_buf[size] = '\0';
> >  
> >  	size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
> >  	if (size > 0)
> >  		nfsd_inject_set_client(file_inode(file)->i_private, &sa, size);
> 
> If we take this branch, don't we end up returning -EFAULT below?
> 


Looks like it .. I wasn't try to change that behavior, I'll update the
patch and resend.

Daniel

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

end of thread, other threads:[~2013-10-27 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-26  2:33 [PATCH 2/3] fs: nfsd: remove calls to simple_strtoll Daniel Walker
2013-10-26 18:41 ` J. Bruce Fields
2013-10-27 15:09   ` Daniel Walker

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).