Skip to content

Commit

Permalink
linux-user/flatload: Take mmap_lock in load_flt_binary()
Browse files Browse the repository at this point in the history
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: fbd3c4c ("linux-user/arm: Mark the commpage executable")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2525
Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
(cherry picked from commit a9ee641)
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
philmd authored and Michael Tokarev committed Oct 10, 2024
1 parent 5762cda commit 18046fb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions linux-user/flatload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 18046fb

Please sign in to comment.