qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR
@ 2024-10-21 12:17 Ilya Leoshkevich
  2024-10-22  2:34 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Ilya Leoshkevich @ 2024-10-21 12:17 UTC (permalink / raw)
  To: Laurent Vivier, Richard Henderson; +Cc: qemu-devel, Ilya Leoshkevich

Running qemu-i386 on a system running with SELinux in enforcing mode
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.

For maximum compatibility, probing is required. Use pgb_find_fallback()
for this purpose. The downside of this approach is that mmap_min_addr
remains incorrect, but there don't seem to be any practical
consequences from this. If a correct mmap_min_addr will be required in
the future, probing will need to be moved to linux-user main().

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 linux-user/elfload.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 6cef8db3b53..f6fb937d68a 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -2968,6 +2968,10 @@ static void pgb_dynamic(const char *image_name, uintptr_t guest_loaddr,
 
         ret = pgb_find_itree(&ga, root, align, brk);
         free_self_maps(root);
+
+        if (ret == -1) {
+            ret = pgb_find_fallback(&ga, align, brk);
+        }
     }
 
     if (ret == -1) {
-- 
2.47.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-22 14:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-21 12:17 [PATCH] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Ilya Leoshkevich
2024-10-22  2:34 ` Richard Henderson
2024-10-22  9:50   ` Ilya Leoshkevich
2024-10-22 14:33     ` 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).