linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set
@ 2020-04-12 20:31 Eugene Syromiatnikov
  2020-04-12 21:13 ` Christian Brauner
  2020-04-15 12:39 ` Christian Brauner
  0 siblings, 2 replies; 3+ messages in thread
From: Eugene Syromiatnikov @ 2020-04-12 20:31 UTC (permalink / raw)
  To: linux-kernel, Christian Brauner
  Cc: Andrew Morton, Ingo Molnar, Tejun Heo, Peter Zijlstra, Dmitry V. Levin

Passing CLONE_INTO_CGROUP with an under-sized structure (that doesn't
properly contain cgroup field) seems like garbage input, especially
considering the fact that fd 0 is a valid descriptor.

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

diff --git a/kernel/fork.c b/kernel/fork.c
index 11bcc7e..8c700f8 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2639,7 +2639,8 @@ noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
 		     !valid_signal(args.exit_signal)))
 		return -EINVAL;
 
-	if ((args.flags & CLONE_INTO_CGROUP) && args.cgroup > INT_MAX)
+	if ((args.flags & CLONE_INTO_CGROUP) &&
+	    (args.cgroup > INT_MAX || usize < CLONE_ARGS_SIZE_VER2))
 		return -EINVAL;
 
 	*kargs = (struct kernel_clone_args){
-- 
2.1.4


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

* Re: [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set
  2020-04-12 20:31 [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set Eugene Syromiatnikov
@ 2020-04-12 21:13 ` Christian Brauner
  2020-04-15 12:39 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2020-04-12 21:13 UTC (permalink / raw)
  To: Eugene Syromiatnikov
  Cc: linux-kernel, Christian Brauner, Andrew Morton, Ingo Molnar,
	Tejun Heo, Peter Zijlstra, Dmitry V. Levin

On Sun, Apr 12, 2020 at 10:31:23PM +0200, Eugene Syromiatnikov wrote:
> Passing CLONE_INTO_CGROUP with an under-sized structure (that doesn't
> properly contain cgroup field) seems like garbage input, especially
> considering the fact that fd 0 is a valid descriptor.
> 
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>

Thanks, will queue for rc2 unless I hear objections.
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

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

* Re: [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set
  2020-04-12 20:31 [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set Eugene Syromiatnikov
  2020-04-12 21:13 ` Christian Brauner
@ 2020-04-15 12:39 ` Christian Brauner
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2020-04-15 12:39 UTC (permalink / raw)
  To: Eugene Syromiatnikov
  Cc: linux-kernel, Christian Brauner, Andrew Morton, Ingo Molnar,
	Tejun Heo, Peter Zijlstra, Dmitry V. Levin

On Sun, Apr 12, 2020 at 10:31:23PM +0200, Eugene Syromiatnikov wrote:
> Passing CLONE_INTO_CGROUP with an under-sized structure (that doesn't
> properly contain cgroup field) seems like garbage input, especially
> considering the fact that fd 0 is a valid descriptor.
> 
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

Applied, thanks!
Christian

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

end of thread, other threads:[~2020-04-15 12:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 20:31 [PATCH] clone3: add a check for the user struct size if CLONE_INTO_CGROUP is set Eugene Syromiatnikov
2020-04-12 21:13 ` Christian Brauner
2020-04-15 12:39 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).