[patch 38/42] sunrpc: fix possible overrun on read of /proc/sys/sunrpc/transports

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg KH
Date: Wednesday, September 3, 2008 - 10:26 am

2.6.26-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Cyrill Gorcunov <gorcunov@gmail.com>

commit 27df6f25ff218072e0e879a96beeb398a79cdbc8 upstream

Vegard Nossum reported
----------------------


David Wagner added (among other things) that copy_to_user could be
probably used here.

Ingo Oeser suggested to use simple_read_from_buffer() here.

The conclusion is that proc_do_xprt doesn't check for userside buffer
size indeed so fix this by using Ingo's suggestion.

Reported-by: Vegard Nossum <vegard.nossum@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
CC: Ingo Oeser <ioe-lkml@rameria.de>
Cc: Neil Brown <neilb@suse.de>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Greg Banks <gnb@sgi.com>
Cc: Tom Tucker <tom@opengridcomputing.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 net/sunrpc/sysctl.c |   18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -60,24 +60,14 @@ static int proc_do_xprt(ctl_table *table
 			void __user *buffer, size_t *lenp, loff_t *ppos)
 {
 	char tmpbuf[256];
-	int len;
+	size_t len;
+
 	if ((*ppos && !write) || !*lenp) {
 		*lenp = 0;
 		return 0;
 	}
-	if (write)
-		return -EINVAL;
-	else {
-		len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
-		if (!access_ok(VERIFY_WRITE, buffer, len))
-			return -EFAULT;
-
-		if (__copy_to_user(buffer, tmpbuf, len))
-			return -EFAULT;
-	}
-	*lenp -= len;
-	*ppos += len;
-	return 0;
+	len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
+	return simple_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
 }
 
 static int

-- 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 00/42] 2.6.26-stable review, Greg KH, (Wed Sep 3, 10:24 am)
[patch 01/42] cramfs: fix named-pipe handling, Greg KH, (Wed Sep 3, 10:25 am)
[patch 03/42] eeepc-laptop: fix use after free, Greg KH, (Wed Sep 3, 10:25 am)
[patch 07/42] x86: work around MTRR mask setting, Greg KH, (Wed Sep 3, 10:25 am)
[patch 13/42] forcedeth: fix checksum flag, Greg KH, (Wed Sep 3, 10:25 am)
[patch 14/42] atl1: disable TSO by default, Greg KH, (Wed Sep 3, 10:25 am)
[patch 24/42] pkt_sched: Fix actions referencing, Greg KH, (Wed Sep 3, 10:26 am)
[patch 36/42] tg3: Fix firmware event timeouts, Greg KH, (Wed Sep 3, 10:26 am)
[patch 38/42] sunrpc: fix possible overrun on read of /pro ..., Greg KH, (Wed Sep 3, 10:26 am)
[patch 41/42] KVM: MMU: Fix torn shadow pte, Greg KH, (Wed Sep 3, 10:26 am)
Re: [patch 29/42] net: Unbreak userspace which includes li ..., Stefan Lippers-Hollmann, (Wed Sep 3, 12:16 pm)
Re: [patch 00/42] 2.6.26-stable review, Henrique de Moraes H ..., (Wed Sep 3, 7:39 pm)
Re: [patch 00/42] 2.6.26-stable review, Andi Kleen, (Thu Sep 4, 5:21 am)
Re: [patch 00/42] 2.6.26-stable review, Milan Broz, (Thu Sep 4, 5:28 am)
Re: [patch 00/42] 2.6.26-stable review, Andi Kleen, (Thu Sep 4, 6:58 am)
Re: [patch 00/42] 2.6.26-stable review, Pavel Machek, (Fri Sep 12, 7:22 am)
Re: [patch 00/42] 2.6.26-stable review, Andi Kleen, (Fri Sep 12, 8:37 am)
Re: [patch 00/42] 2.6.26-stable review, Henrique de Moraes H ..., (Fri Sep 12, 12:46 pm)
Re: [patch 00/42] 2.6.26-stable review, Pavel Machek, (Sat Sep 13, 9:56 am)