From b82e116c49f88283f8b1b720a8b0058ec6c08a00 Mon Sep 17 00:00:00 2001 From: Eugene Teo Date: Sun, 18 Jan 2004 17:38:23 -0800 Subject: [PATCH] [SUNRPC]: Handle copy_*_user and put_user errors --- net/sunrpc/sysctl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 9dd1231ae26f0..b65a32b1c61f5 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c @@ -81,7 +81,8 @@ proc_dodebug(ctl_table *table, int write, struct file *file, if (left > sizeof(tmpbuf) - 1) return -EINVAL; - copy_from_user(tmpbuf, p, left); + if (copy_from_user(tmpbuf, p, left)) + return -EFAULT; tmpbuf[left] = '\0'; for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--) @@ -101,9 +102,11 @@ proc_dodebug(ctl_table *table, int write, struct file *file, len = sprintf(tmpbuf, "%d", *(unsigned int *) table->data); if (len > left) len = left; - __copy_to_user(buffer, tmpbuf, len); + if (__copy_to_user(buffer, tmpbuf, len)) + return -EFAULT; if ((left -= len) > 0) { - put_user('\n', (char *)buffer + len); + if (put_user('\n', (char *)buffer + len)) + return -EFAULT; left--; } } -- 2.53.0