Skip to contentSkip to conversation

Linux user for 7.1 patches

GIT PULL Applied Laurent Vivier 2 participants 5 messages Aug 3, 2022

lore
Share & tools
lore
#0 lore raw

The following changes since commit 3e4abe2c92964aadd35344a635b0f32cb487fd5c:

Merge tag 'pull-block-2022-07-27' of https://gitlab.com/vsementsov/qemu into staging (2022-07-27 20:10:15 -0700)

are available in the Git repository at:

https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.1-pull-request

for you to fetch changes up to 5b63de6b54add51822db3c89325c6fc05534a54c:

linux-user: Use memfd for open syscall emulation (2022-08-02 15:44:27 +0200)

----------------------------------------------------------------
Pull request linux-user 20220803

----------------------------------------------------------------

Ilya Leoshkevich (1):
linux-user: Do not treat madvise()'s advice as a bitmask

Peter Maydell (1):
linux-user/flatload.c: Fix setting of image_info::end_code

Rainer Müller (1):
linux-user: Use memfd for open syscall emulation

 linux-user/flatload.c |  2 +-
 linux-user/mmap.c     |  2 +-
 linux-user/syscall.c  | 22 ++++++++++++++--------
 3 files changed, 16 insertions(+), 10 deletions(-)
Signature · 1 line
2.37.1
#1 lore raw

[PULL 1/3] linux-user/flatload.c: Fix setting of image_info::end_code

From: Peter Maydell <[email protected]>

The flatload loader sets the end_code field in the image_info struct incorrectly, due to a typo.

This is a very long-standing bug (dating all the way back to when the bFLT loader was added in 2006), but has gone unnoticed because
(a) most people don't use bFLT binaries
(b) we don't actually do anything with the end_code field, except print it in debugging traces and pass it to TCG plugins

Fix the typo.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1119

Message-Id: <[email protected]>

---
 linux-user/flatload.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/flatload.c +1 -1
index e4c2f89a2267..e99570ca182b 100644
@@ -808,7 +808,7 @@ int load_flt_binary(struct linux_binprm *bprm, struct image_info *info)
 
     /* Stash our initial stack pointer into the mm structure */
     info->start_code = libinfo[0].start_code;
-    info->end_code = libinfo[0].start_code = libinfo[0].text_len;
+    info->end_code = libinfo[0].start_code + libinfo[0].text_len;
     info->start_data = libinfo[0].start_data;
     info->end_data = libinfo[0].end_data;
     info->start_brk = libinfo[0].start_brk;
Signature · 1 line
2.37.1
#2 lore raw

[PULL 2/3] linux-user: Do not treat madvise()'s advice as a bitmask

In reply to Laurent Vivier

From: Ilya Leoshkevich <[email protected]>

Advice is enum, not flags. Doing (advice & MADV_DONTNEED) also matches e.g. MADV_MERGEABLE.

Message-Id: <[email protected]>

Fixes 892a4f6a750a ("linux-user: Add partial support for MADV_DONTNEED")
---
 linux-user/mmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
linux-user/mmap.c +1 -1
index 4e7a6be6ee19..edceaca4a8e1 100644
@@ -891,7 +891,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
      * anonymous mappings. In this case passthrough is safe, so do it.
      */
     mmap_lock();
-    if ((advice & MADV_DONTNEED) &&
+    if (advice == MADV_DONTNEED &&
         can_passthrough_madv_dontneed(start, end)) {
         ret = get_errno(madvise(g2h_untagged(start), len, MADV_DONTNEED));
     }
Signature · 1 line
2.37.1
#3 lore raw

[PULL 3/3] linux-user: Use memfd for open syscall emulation

In reply to Laurent Vivier

From: Rainer Müller <[email protected]>

For certain paths in /proc, the open syscall is intercepted and the returned file descriptor points to a temporary file with emulated contents.

If TMPDIR is not accessible or writable for the current user (for example in a read-only mounted chroot or container) tools such as ps from procps may fail unexpectedly. Trying to read one of these paths such as /proc/self/stat would return an error such as ENOENT or EROFS.

To relax the requirement on a writable TMPDIR, use memfd_create() instead to create an anonymous file and return its file descriptor.

Message-Id: <[email protected]>

---
 linux-user/syscall.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
linux-user/syscall.c +14 -8
index b27a6552aa34..ef53feb5ab45 100644
@@ -8260,16 +8260,22 @@ static int do_openat(CPUArchState *cpu_env, int dirfd, const char *pathname, int
         char filename[PATH_MAX];
         int fd, r;
 
-        /* create temporary file to map stat to */
-        tmpdir = getenv("TMPDIR");
-        if (!tmpdir)
-            tmpdir = "/tmp";
-        snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir);
-        fd = mkstemp(filename);
+        fd = memfd_create("qemu-open", 0);
         if (fd < 0) {
-            return fd;
+            if (errno != ENOSYS) {
+                return fd;
+            }
+            /* create temporary file to map stat to */
+            tmpdir = getenv("TMPDIR");
+            if (!tmpdir)
+                tmpdir = "/tmp";
+            snprintf(filename, sizeof(filename), "%s/qemu-open.XXXXXX", tmpdir);
+            fd = mkstemp(filename);
+            if (fd < 0) {
+                return fd;
+            }
+            unlink(filename);
         }
-        unlink(filename);
 
         if ((r = fake_open->fill(cpu_env, fd))) {
             int e = errno;
Signature · 1 line
2.37.1
#4 lore raw
In reply to Laurent Vivier
Quoted 6 lines · Laurent Vivier

The following changes since commit 3e4abe2c92964aadd35344a635b0f32cb487fd5c:

   Merge tag 'pull-block-2022-07-27' of https://gitlab.com/vsementsov/qemu into staging (2022-07-27 20:10:15 -0700)

are available in the Git repository at:

Quoted 8 lines

https://gitlab.com/laurent_vivier/qemu.git tags/linux-user-for-7.1-pull-request

for you to fetch changes up to 5b63de6b54add51822db3c89325c6fc05534a54c:

linux-user: Use memfd for open syscall emulation (2022-08-02 15:44:27 +0200)

----------------------------------------------------------------
Pull request linux-user 20220803

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.

r~

Quoted 17 lines

----------------------------------------------------------------

Ilya Leoshkevich (1):
linux-user: Do not treat madvise()'s advice as a bitmask

Peter Maydell (1):
linux-user/flatload.c: Fix setting of image_info::end_code

Rainer Müller (1):
linux-user: Use memfd for open syscall emulation

  linux-user/flatload.c |  2 +-
  linux-user/mmap.c     |  2 +-
  linux-user/syscall.c  | 22 ++++++++++++++--------
  3 files changed, 16 insertions(+), 10 deletions(-)