[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1614598093-1188-1-git-send-email-wangqing@vivo.com>
Date: Mon, 1 Mar 2021 19:28:11 +0800
From: Wang Qing <wangqing@...o.com>
To: Christian Brauner <christian.brauner@...ntu.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Thomas Cedeno <thomascedeno@...gle.com>,
Nicolas Viennot <Nicolas.Viennot@...sigma.com>,
Michel Lespinasse <walken@...gle.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Al Viro <viro@...iv.linux.org.uk>,
Gabriel Krisman Bertazi <krisman@...labora.com>,
linux-kernel@...r.kernel.org
Cc: Wang Qing <wangqing@...o.com>
Subject: [PATCH] kernel: Return -EFAULT if copy_to_user() fails
The copy_to_user() function returns the number of bytes remaining to be
copied, but we want to return -EFAULT if the copy doesn't complete.
Signed-off-by: Wang Qing <wangqing@...o.com>
---
kernel/sys.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index 8bb46e5..d97a84a
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1247,7 +1247,7 @@ static int override_release(char __user *release, size_t len)
copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
ret = copy_to_user(release, buf, copy + 1);
}
- return ret;
+ return ret ? -EFAULT : 0;
}
SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name)
--
2.7.4
Powered by blists - more mailing lists