mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
shm: fix null pointer deref when userspace specifies invalid hugepage size
Dave reported an oops triggered by trinity:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
IP: newseg+0x10d/0x390
PGD cf8c1067 PUD cf8c2067 PMD 0
Oops: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
CPU: 2 PID: 7636 Comm: trinity-child2 Not tainted 3.9.0+#67
...
Call Trace:
ipcget+0x182/0x380
SyS_shmget+0x5a/0x60
tracesys+0xdd/0xe2
This bug was introduced by commit af73e4d950 ("hugetlbfs: fix mmap
failure in unaligned size request").
Reported-by: Dave Jones <[email protected]>
Cc: <[email protected]>
Signed-off-by: Li Zefan <[email protected]>
Reviewed-by: Naoya Horiguchi <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
de2657f94a
commit
091d0d55b2
2 changed files with 13 additions and 3 deletions
|
|
@ -1367,9 +1367,13 @@ SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len,
|
|||
len = ALIGN(len, huge_page_size(hstate_file(file)));
|
||||
} else if (flags & MAP_HUGETLB) {
|
||||
struct user_struct *user = NULL;
|
||||
struct hstate *hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) &
|
||||
SHM_HUGE_MASK);
|
||||
|
||||
len = ALIGN(len, huge_page_size(hstate_sizelog(
|
||||
(flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK)));
|
||||
if (!hs)
|
||||
return -EINVAL;
|
||||
|
||||
len = ALIGN(len, huge_page_size(hs));
|
||||
/*
|
||||
* VM_NORESERVE is used because the reservations will be
|
||||
* taken when vm_ops->mmap() is called
|
||||
|
|
|
|||
Loading…
Reference in a new issue