Commit d57c764a authored by Chris Salls's avatar Chris Salls Committed by Greg Kroah-Hartman

mm/mempolicy.c: fix error handling in set_mempolicy and mbind.

commit cf01fb99 upstream.

In the case that compat_get_bitmap fails we do not want to copy the
bitmap to the user as it will contain uninitialized stack data and leak
sensitive data.
Signed-off-by: default avatarChris Salls <salls@cs.ucsb.edu>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 596c2d18
...@@ -1526,7 +1526,6 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy, ...@@ -1526,7 +1526,6 @@ COMPAT_SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask,
compat_ulong_t, maxnode) compat_ulong_t, maxnode)
{ {
long err = 0;
unsigned long __user *nm = NULL; unsigned long __user *nm = NULL;
unsigned long nr_bits, alloc_size; unsigned long nr_bits, alloc_size;
DECLARE_BITMAP(bm, MAX_NUMNODES); DECLARE_BITMAP(bm, MAX_NUMNODES);
...@@ -1535,13 +1534,12 @@ COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask, ...@@ -1535,13 +1534,12 @@ COMPAT_SYSCALL_DEFINE3(set_mempolicy, int, mode, compat_ulong_t __user *, nmask,
alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
if (nmask) { if (nmask) {
err = compat_get_bitmap(bm, nmask, nr_bits); if (compat_get_bitmap(bm, nmask, nr_bits))
return -EFAULT;
nm = compat_alloc_user_space(alloc_size); nm = compat_alloc_user_space(alloc_size);
err |= copy_to_user(nm, bm, alloc_size); if (copy_to_user(nm, bm, alloc_size))
}
if (err)
return -EFAULT; return -EFAULT;
}
return sys_set_mempolicy(mode, nm, nr_bits+1); return sys_set_mempolicy(mode, nm, nr_bits+1);
} }
...@@ -1550,7 +1548,6 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len, ...@@ -1550,7 +1548,6 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
compat_ulong_t, mode, compat_ulong_t __user *, nmask, compat_ulong_t, mode, compat_ulong_t __user *, nmask,
compat_ulong_t, maxnode, compat_ulong_t, flags) compat_ulong_t, maxnode, compat_ulong_t, flags)
{ {
long err = 0;
unsigned long __user *nm = NULL; unsigned long __user *nm = NULL;
unsigned long nr_bits, alloc_size; unsigned long nr_bits, alloc_size;
nodemask_t bm; nodemask_t bm;
...@@ -1559,13 +1556,12 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len, ...@@ -1559,13 +1556,12 @@ COMPAT_SYSCALL_DEFINE6(mbind, compat_ulong_t, start, compat_ulong_t, len,
alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8; alloc_size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
if (nmask) { if (nmask) {
err = compat_get_bitmap(nodes_addr(bm), nmask, nr_bits); if (compat_get_bitmap(nodes_addr(bm), nmask, nr_bits))
return -EFAULT;
nm = compat_alloc_user_space(alloc_size); nm = compat_alloc_user_space(alloc_size);
err |= copy_to_user(nm, nodes_addr(bm), alloc_size); if (copy_to_user(nm, nodes_addr(bm), alloc_size))
}
if (err)
return -EFAULT; return -EFAULT;
}
return sys_mbind(start, len, mode, nm, nr_bits+1, flags); return sys_mbind(start, len, mode, nm, nr_bits+1, flags);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment