All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fs/signalfd.c: Fix inconsistent return codes for signalfd4
@ 2020-05-30 10:07 Helge Deller
  0 siblings, 0 replies; only message in thread
From: Helge Deller @ 2020-05-30 10:07 UTC (permalink / raw)
  To: Alexander Viro, Andrew Morton, linux-fsdevel, linux-kernel; +Cc: Laurent Vivier

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: Helge Deller <deller@gmx.de>

---
Changelog v2:
- Rephrased commit message.

diff --git a/fs/signalfd.c b/fs/signalfd.c
index 44b6845b071c..5b78719be445 100644
--- a/fs/signalfd.c
+++ b/fs/signalfd.c
@@ -314,9 +314,10 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
 {
 	sigset_t mask;

-	if (sizemask != sizeof(sigset_t) ||
-	    copy_from_user(&mask, user_mask, sizeof(mask)))
+	if (sizemask != sizeof(sigset_t))
 		return -EINVAL;
+	if (copy_from_user(&mask, user_mask, sizeof(mask)))
+		return -EFAULT;
 	return do_signalfd4(ufd, &mask, flags);
 }

@@ -325,9 +326,10 @@ SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask,
 {
 	sigset_t mask;

-	if (sizemask != sizeof(sigset_t) ||
-	    copy_from_user(&mask, user_mask, sizeof(mask)))
+	if (sizemask != sizeof(sigset_t))
 		return -EINVAL;
+	if (copy_from_user(&mask, user_mask, sizeof(mask)))
+		return -EFAULT;
 	return do_signalfd4(ufd, &mask, 0);
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-30 10:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-30 10:07 [PATCH v2] fs/signalfd.c: Fix inconsistent return codes for signalfd4 Helge Deller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.