mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
hugetlbfs: fix mmap failure in unaligned size request
The current kernel returns -EINVAL unless a given mmap length is
"almost" hugepage aligned. This is because in sys_mmap_pgoff() the
given length is passed to vm_mmap_pgoff() as it is without being aligned
with hugepage boundary.
This is a regression introduced in commit 40716e2924 ("hugetlbfs: fix
alignment of huge page requests"), where alignment code is pushed into
hugetlb_file_setup() and the variable len in caller side is not changed.
To fix this, this patch partially reverts that commit, and adds
alignment code in caller side. And it also introduces hstate_sizelog()
in order to get proper hstate to specified hugepage size.
Addresses https://bugzilla.kernel.org/show_bug.cgi?id=56881
[[email protected]: fix warning when CONFIG_HUGETLB_PAGE=n]
Signed-off-by: Naoya Horiguchi <[email protected]>
Signed-off-by: Johannes Weiner <[email protected]>
Reported-by: <[email protected]>
Cc: Steven Truelove <[email protected]>
Cc: Jianguo Wu <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
1ab4ce7623
commit
af73e4d950
4 changed files with 34 additions and 22 deletions
|
|
@ -491,10 +491,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
|
|||
|
||||
sprintf (name, "SYSV%08x", key);
|
||||
if (shmflg & SHM_HUGETLB) {
|
||||
struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
|
||||
& SHM_HUGE_MASK);
|
||||
size_t hugesize = ALIGN(size, huge_page_size(hs));
|
||||
|
||||
/* hugetlb_file_setup applies strict accounting */
|
||||
if (shmflg & SHM_NORESERVE)
|
||||
acctflag = VM_NORESERVE;
|
||||
file = hugetlb_file_setup(name, 0, size, acctflag,
|
||||
file = hugetlb_file_setup(name, hugesize, acctflag,
|
||||
&shp->mlock_user, HUGETLB_SHMFS_INODE,
|
||||
(shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue