qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Beraldo Leal" <bleal@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Riku Voipio" <riku.voipio@iki.fi>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>
Subject: [PATCH v2 2/4] linux-user/flatload: Take mmap_lock in load_flt_binary()
Date: Thu, 22 Aug 2024 11:50:43 +0200	[thread overview]
Message-ID: <20240822095045.72643-3-philmd@linaro.org> (raw)
In-Reply-To: <20240822095045.72643-1-philmd@linaro.org>

load_flt_binary() calls load_flat_file() -> page_set_flags().

page_set_flags() must be called with the mmap_lock held,
otherwise it aborts:

  $ qemu-arm -L stm32/lib/ stm32/bin/busybox
  qemu-arm: ../accel/tcg/user-exec.c:505: page_set_flags: Assertion `have_mmap_lock()' failed.
  Aborted (core dumped)

Fix by taking the lock in load_flt_binary().

Fixes: fbd3c4cff6 ("linux-user/arm: Mark the commpage executable")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2525
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 linux-user/flatload.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/flatload.c b/linux-user/flatload.c
index 04d8138d12..0e4be5bf44 100644
--- a/linux-user/flatload.c
+++ b/linux-user/flatload.c
@@ -487,7 +487,10 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
     stack_len += (bprm->envc + 1) * 4; /* the envp array */
 
 
+    mmap_lock();
     res = load_flat_file(bprm, libinfo, 0, &stack_len);
+    mmap_unlock();
+
     if (is_error(res)) {
             return res;
     }
-- 
2.45.2



  parent reply	other threads:[~2024-08-22  9:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22  9:50 [PATCH v2 0/4] linux-user/flatload: Take mmap_lock in load_flt_binary() Philippe Mathieu-Daudé
2024-08-22  9:50 ` [PATCH v2 1/4] accel/tcg: Make page_set_flags() documentation public Philippe Mathieu-Daudé
2024-08-22  9:50 ` Philippe Mathieu-Daudé [this message]
2024-10-06  8:51   ` [PATCH v2 2/4] linux-user/flatload: Take mmap_lock in load_flt_binary() Michael Tokarev
2024-10-06 15:23     ` Richard Henderson
2024-08-22  9:50 ` [PATCH v2 3/4] tests/avocado: Allow running user-mode tests Philippe Mathieu-Daudé
2024-08-22  9:50 ` [PATCH v2 4/4] tests/avocado: Run STM32 bFLT busybox binary in current directory Philippe Mathieu-Daudé
2024-08-22 11:08   ` Thomas Huth
2024-08-22 23:48 ` [PATCH v2 0/4] linux-user/flatload: Take mmap_lock in load_flt_binary() Richard Henderson
2024-10-05 23:04 ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240822095045.72643-3-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=riku.voipio@iki.fi \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).