Re: [PATCH] kernel: Return -EFAULT if copy_to_user() fails

2021-03-01 Thread Christian Brauner
On Mon, Mar 01, 2021 at 07:28:11PM +0800, Wang Qing wrote:
> 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 
> ---

Hey Wang,

Thanks for the patch. It looks like override_release() is called in
three places and all three places return -EFAULT correctly. They simply
treat any as EFAULT. So not sure this change buys us anything.

Christian


[PATCH] kernel: Return -EFAULT if copy_to_user() fails

2021-03-01 Thread Wang Qing
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 
---
 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