linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR
PATCH v2 1/1 linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR
Running qemu-i386 on a system running with SELinux in enforcing mode (more precisely: s390x trixie container on Fedora 40) fails with:
qemu-i386: tests/tcg/i386-linux-user/sigreturn-sigmask: Unable to find a guest_base to satisfy all guest address mapping requirements
00000000-ffffffff
The reason is that main() determines mmap_min_addr from /proc/sys/vm/mmap_min_addr, but SELinux additionally defines CONFIG_LSM_MMAP_MIN_ADDR, which is normally larger: 32K or 64K, but, in general, can be anything. There is no portable way to query its
value: /boot/config, /proc/config and /proc/config.gz are distro- and environment-specific.
Once the identity map fails, the magnitude of guest_base does not matter, so fix by starting the search from 1M or 1G.
---
v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Start looking for a suitable hole from a higher address,
instead of falling back to probing (Richard).
linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/elfload.c +1 -1
@@ -2898,7 +2898,7 @@ static uintptr_t pgb_try_itree(const PGBAddrs *ga, uintptr_t base,static uintptr_t pgb_find_itree (const PGBAddrs *ga,IntervalTreeRoot *root,uintptr_t align,uintptr_t brk) { -uintptr_t last = mmap_min_addr; +uintptr_t last =sizeof (uintptr_t ) ==4 ? MiB : GiB;uintptr_t base, skip;while (true) {
Signature · 1 line
2.47.0
Richard Henderson
AppliedQuoted 32 lines · Ilya Leoshkevich
Running qemu-i386 on a system running with SELinux in enforcing mode (more precisely: s390x trixie container on Fedora 40) fails with:
qemu-i386: tests/tcg/i386-linux-user/sigreturn-sigmask: Unable to find a
guest_baseto satisfy all guest address mapping requirements
00000000-ffffffffThe reason is that
main()determinesmmap_min_addrfrom/proc/sys/vm/mmap_min_addr, but SELinux additionally definesCONFIG_LSM_MMAP_MIN_ADDR, which is normally larger: 32K or 64K, but, in general, can be anything. There is no portable way to query its
value:/boot/config,/proc/configand/proc/config.gzare distro- and environment-specific.Once the identity map fails, the magnitude of
guest_basedoes not matter, so fix by starting the search from 1M or 1G.Suggested-by Richard Henderson <[email protected]>Signed-off-by Ilya Leoshkevich <[email protected]>---
v1: https://lore.kernel.org/qemu-devel/[email protected]/
v1 -> v2: Start looking for a suitable hole from a higher address,
instead of falling back to probing (Richard).linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)linux-user/elfload.c +0
-0
linux-user/elfload.c static uintptr_t pgb_try_itree(const PGBAddrs *ga, uintptr_t base, · line 2904
Quoted 8 lines
linux-user/elfload.c +1
-1@@ -2898,7 +2898,7 @@ static uintptr_t pgb_try_itree(const PGBAddrs *ga, uintptr_t base,static uintptr_t pgb_find_itree (const PGBAddrs *ga,IntervalTreeRoot *root,uintptr_t align,uintptr_t brk) { -uintptr_t last = mmap_min_addr; +uintptr_t last =sizeof (uintptr_t ) ==4 ? MiB : GiB;uintptr_t base, skip;while (true) {
Queued, thanks.
r~