]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
powerpc/hugetlb: Handle mmap_min_addr correctly in get_unmapped_area callback
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Tue, 26 Feb 2019 04:39:34 +0000 (10:09 +0530)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
commit15503cd8a768d188937648fbe92c94377a0b8e60
treea669c5df766bfd0bb19252fa73c065d9466c5d94
parentc02186aae0c244bdffca9fe418fc2e66ecef9951
powerpc/hugetlb: Handle mmap_min_addr correctly in get_unmapped_area callback

BugLink: https://bugs.launchpad.net/bugs/1838116
[ Upstream commit 5330367fa300742a97e20e953b1f77f48392faae ]

After we ALIGN up the address we need to make sure we didn't overflow
and resulted in zero address. In that case, we need to make sure that
the returned address is greater than mmap_min_addr.

This fixes selftest va_128TBswitch --run-hugetlb reporting failures when
run as non root user for

mmap(-1, MAP_HUGETLB)

The bug is that a non-root user requesting address -1 will be given address 0
which will then fail, whereas they should have been given something else that
would have succeeded.

We also avoid the first mmap(-1, MAP_HUGETLB) returning NULL address as mmap address
with this change. So we think this is not a security issue, because it only affects
whether we choose an address below mmap_min_addr, not whether we
actually allow that address to be mapped. ie. there are existing capability
checks to prevent a user mapping below mmap_min_addr and those will still be
honoured even without this fix.

Fixes: 484837601d4d ("powerpc/mm: Add radix support for hugetlb")
Reviewed-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/powerpc/mm/hugetlbpage-radix.c