public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched: fix information leak in sys_sched_getattr()
@ 2014-02-16 21:24 vegard.nossum
  2014-02-21 20:32 ` [tip:sched/urgent] sched: Fix " tip-bot for Vegard Nossum
  0 siblings, 1 reply; 2+ messages in thread
From: vegard.nossum @ 2014-02-16 21:24 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Vegard Nossum, Dario Faggioli, Juri Lelli,
	Peter Zijlstra

From: Vegard Nossum <vegard.nossum@oracle.com>

We're copying the on-stack structure to userspace, but forgot to give
the right number of bytes to copy. This allows the calling process to
obtain up to PAGE_SIZE bytes from the stack (and possibly adjacent
kernel memory).

This fix copies only as much as we actually have on the stack
(attr->size defaults to the size of the struct) and leaves the rest of
the userspace-provided buffer untouched.

Found using kmemcheck + trinity.

Fixes: d50dde5a10f30 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI")
Cc: Dario Faggioli <raistlin@linux.it>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 kernel/sched/core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b46131e..ac939c3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3786,7 +3786,7 @@ static int sched_read_attr(struct sched_attr __user *uattr,
 		attr->size = usize;
 	}
 
-	ret = copy_to_user(uattr, attr, usize);
+	ret = copy_to_user(uattr, attr, attr->size);
 	if (ret)
 		return -EFAULT;
 
-- 
1.7.10.4


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

end of thread, other threads:[~2014-02-21 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-16 21:24 [PATCH] sched: fix information leak in sys_sched_getattr() vegard.nossum
2014-02-21 20:32 ` [tip:sched/urgent] sched: Fix " tip-bot for Vegard Nossum

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