Skip to content

Commit

Permalink
sched: Fix information leak in sys_sched_getattr()
Browse files Browse the repository at this point in the history
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: d50dde5 ("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: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1392585857-10725-1-git-send-email-vegard.nossum@oracle.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Vegard Nossum authored and Thomas Gleixner committed Feb 21, 2014
1 parent 3cf1962 commit 4efbc45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 4efbc45

Please sign in to comment.