Commit 7c89e40e authored by Helge Deller's avatar Helge Deller Committed by Greg Kroah-Hartman

fs/signalfd.c: fix inconsistent return codes for signalfd4

[ Upstream commit a089e3fd ]

The kernel signalfd4() syscall returns different error codes when called
either in compat or native mode.  This behaviour makes correct emulation
in qemu and testing programs like LTP more complicated.

Fix the code to always return -in both modes- EFAULT for unaccessible user
memory, and EINVAL when called with an invalid signal mask.
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Laurent Vivier <laurent@vivier.eu>
Link: http://lkml.kernel.org/r/20200530100707.GA10159@ls3530.fritz.boxSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 6afcb8b9
...@@ -313,9 +313,10 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask, ...@@ -313,9 +313,10 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
{ {
sigset_t mask; sigset_t mask;
if (sizemask != sizeof(sigset_t) || if (sizemask != sizeof(sigset_t))
copy_from_user(&mask, user_mask, sizeof(mask)))
return -EINVAL; return -EINVAL;
if (copy_from_user(&mask, user_mask, sizeof(mask)))
return -EFAULT;
return do_signalfd4(ufd, &mask, flags); return do_signalfd4(ufd, &mask, flags);
} }
...@@ -324,9 +325,10 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask, ...@@ -324,9 +325,10 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask,
{ {
sigset_t mask; sigset_t mask;
if (sizemask != sizeof(sigset_t) || if (sizemask != sizeof(sigset_t))
copy_from_user(&mask, user_mask, sizeof(mask)))
return -EINVAL; return -EINVAL;
if (copy_from_user(&mask, user_mask, sizeof(mask)))
return -EFAULT;
return do_signalfd4(ufd, &mask, 0); return do_signalfd4(ufd, &mask, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment