* [PATCH v2] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR
@ 2024-10-23 0:24 Ilya Leoshkevich
2024-11-11 14:53 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Ilya Leoshkevich @ 2024-10-23 0:24 UTC (permalink / raw)
To: Laurent Vivier, Richard Henderson
Cc: Michael Tokarev, qemu-devel, 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_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.
Closes: https://gitlab.com/qemu-project/qemu/-/issues/2598
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
v1: https://lore.kernel.org/qemu-devel/20241021121820.483535-1-iii@linux.ibm.com/
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(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 6cef8db3b53..d6ad77d27dc 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -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) {
--
2.47.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR
2024-10-23 0:24 [PATCH v2] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Ilya Leoshkevich
@ 2024-11-11 14:53 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2024-11-11 14:53 UTC (permalink / raw)
To: Ilya Leoshkevich, Laurent Vivier; +Cc: Michael Tokarev, qemu-devel
On 10/22/24 17:24, Ilya Leoshkevich wrote:
> 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.
>
> Closes: https://gitlab.com/qemu-project/qemu/-/issues/2598
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> v1: https://lore.kernel.org/qemu-devel/20241021121820.483535-1-iii@linux.ibm.com/
> 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(-)
>
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 6cef8db3b53..d6ad77d27dc 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -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~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-11 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-23 0:24 [PATCH v2] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Ilya Leoshkevich
2024-11-11 14:53 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).