kernel: Return -EFAULT if copy_to_user() fails
PATCH 1/1 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 <[email protected]>
--- kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sys.c +1 -1
@@ -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)
Signature · 1 line
2.7.4
Quoted 5 lines · Wang Qing
The
copy_to_user()function returns the number of bytes remaining to be copied, but we want to return-EFAULTif the copy doesn't complete.Signed-off-by Wang Qing <[email protected]>---
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