mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/core: Fix a potential double fetch bug on attr->size
@ 2017-09-25 12:53 Meng Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Meng Xu @ 2017-09-25 12:53 UTC (permalink / raw)
  To: mingo, peterz, linux-kernel; +Cc: meng.xu, sanidhya, taesoo, Meng Xu

From: Meng Xu <mengxu.gatech@gmail.com>

`attr->size` after the second fetch `copy_from_user(attr, uattr, size)`,
can be different from what is initially fetched in and checked
`get_user(size, &uattr->size)` by racing condition in the userspace.

The issue and the patch are both similar to commit f12f42a
(in kernel/events/core.c).

Signed-off-by: Meng Xu <mengxu.gatech@gmail.com>
---
 kernel/sched/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0869b20..c22d2b4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4349,6 +4349,8 @@ static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *a
 	if (ret)
 		return -EFAULT;
 
+	attr->size = size;
+
 	/*
 	 * XXX: Do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH] sched/core: Fix a potential double fetch bug on attr->size
@ 2017-08-29 19:10 Meng Xu
       [not found] ` <12F594E4-B8AA-436B-933A-4E1DFDDC7E0C@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Meng Xu @ 2017-08-29 19:10 UTC (permalink / raw)
  To: mingo, peterz, linux-kernel; +Cc: meng.xu, sanidhya, taesoo, Meng Xu

From: Meng Xu <mengxu.gatech@gmail.com>

`attr->size` after the second fetch `copy_from_user(attr, uattr, size)`,
can be different from what is initially fetched in and checked
`get_user(size, &uattr->size)` by racing condition in the userspace.

The issue and the patch are both similar to commit f12f42a
(in kernel/events/core.c).

Signed-off-by: Meng Xu <mengxu.gatech@gmail.com>
---
 kernel/sched/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 0869b20..c22d2b4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4349,6 +4349,8 @@ static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *a
 	if (ret)
 		return -EFAULT;
 
+	attr->size = size;
+
 	/*
 	 * XXX: Do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
-- 
2.7.4

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

end of thread, other threads:[~2017-09-25 12:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 12:53 [PATCH] sched/core: Fix a potential double fetch bug on attr->size Meng Xu
  -- strict thread matches above, loose matches on Subject: below --
2017-08-29 19:10 Meng Xu
     [not found] ` <12F594E4-B8AA-436B-933A-4E1DFDDC7E0C@gmail.com>
2017-09-25  7:31   ` Peter Zijlstra
2017-09-25 12:53     ` Meng Xu

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

all inboxes | Powered by JetHome®