]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
selftest/vm: verify remap destination address in mremap_test
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Thu, 21 Apr 2022 23:35:52 +0000 (16:35 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:22:58 +0000 (14:22 +0200)
commit26dd018d9e42c165d10264fe8668f3ea24bac323
tree3533a59abdd202cbd5c787beb1112c89acec4f66
parent2e3c1b223ff189d2a4059f860caba8438185a193
selftest/vm: verify remap destination address in mremap_test

BugLink: https://bugs.launchpad.net/bugs/1978234
[ Upstream commit 18d609daa546c919fd36b62a7b510c18de4b4af8 ]

Because mremap does not have a MAP_FIXED_NOREPLACE flag, it can destroy
existing mappings.  This causes a segfault when regions such as text are
remapped and the permissions are changed.

Verify the requested mremap destination address does not overlap any
existing mappings by using mmap's MAP_FIXED_NOREPLACE flag.  Keep
incrementing the destination address until a valid mapping is found or
fail the current test once the max address is reached.

Link: https://lkml.kernel.org/r/20220420215721.4868-2-sidhartha.kumar@oracle.com
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
tools/testing/selftests/vm/mremap_test.c