public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fork: fail on non-zero higher 32 bits of args.exit_signal
@ 2019-09-10 11:57 Eugene Syromiatnikov
  2019-09-10 12:20 ` Dmitry V. Levin
  2019-09-10 12:44 ` Oleg Nesterov
  0 siblings, 2 replies; 10+ messages in thread
From: Eugene Syromiatnikov @ 2019-09-10 11:57 UTC (permalink / raw)
  To: linux-kernel, Christian Brauner
  Cc: Andrew Morton, Peter Zijlstra (Intel), Ingo Molnar,
	Dmitry V. Levin, Eric Biederman, Oleg Nesterov

Previously, higher 32 bits of exit_signal fields were lost when
copied to the kernel args structure (that uses int as a type for the
respective field).  Fail with EINVAL if these are set as it looks like
there's no sane reason to accept them.

* kernel/fork.c (copy_clone_args_from_user): Fail with -EINVAL if
args.exit_signal converted to unsigned int is not equal to the original
value.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 kernel/fork.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 2852d0e..fcbc4d5 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2562,6 +2562,9 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
 	if (copy_from_user(&args, uargs, size))
 		return -EFAULT;
 
+	if (unlikely(((unsigned int)args.exit_signal) != args.exit_signal))
+		return -EINVAL;
+
 	*kargs = (struct kernel_clone_args){
 		.flags		= args.flags,
 		.pidfd		= u64_to_user_ptr(args.pidfd),
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-09-10 15:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-10 11:57 [PATCH] fork: fail on non-zero higher 32 bits of args.exit_signal Eugene Syromiatnikov
2019-09-10 12:20 ` Dmitry V. Levin
2019-09-10 12:44 ` Oleg Nesterov
2019-09-10 13:09   ` Christian Brauner
2019-09-10 13:10     ` Christian Brauner
2019-09-10 13:27       ` Christian Brauner
2019-09-10 14:27         ` Eugene Syromiatnikov
2019-09-10 14:39         ` Oleg Nesterov
2019-09-10 14:46           ` Christian Brauner
2019-09-10 15:18             ` Eugene Syromiatnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox