All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/2] Linux user next patches
@ 2026-10-15 20:02 Helge Deller
  2026-10-16  6:00 ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2026-10-15 20:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Schwab, wangyang, Helge Deller

From: Helge Deller <deller@gmx.de>

The following changes since commit 8ee6c77176cfee03be0ec7665b6652b2f31f1531:

  Merge tag 'pull-ufs-20261012' of https://gitlab.com/jeuk20.kim/qemu into staging (2026-10-13 22:01:07 +0200)

are available in the Git repository at:

  https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request

for you to fetch changes up to fdd414709dea458794e03dc64b2495e579133ead:

  linux-user/riscv: preserve rs1 address for cbo.zero fault reporting (2026-10-14 21:16:41 +0200)

----------------------------------------------------------------
linux user patches

Two linus user patches:
- Show correct fault address on riscv
- Do not trash stderr on unhandled core dump, but instead log it into guest_errors log

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

Andreas Schwab (1):
  linux-user: don't print core dump message by default

wangyang (1):
  linux-user/riscv: preserve rs1 address for cbo.zero fault reporting

 accel/tcg/user-exec.c         |  7 ++++++-
 include/hw/core/cpu.h         |  2 ++
 linux-user/riscv/cpu_loop.c   |  3 +++
 linux-user/signal.c           |  4 ++--
 target/riscv/tcg/cpu_helper.c | 27 ++++++++++++++++++++++++---
 target/riscv/tcg/debug.c      |  3 +++
 target/riscv/tcg/op_helper.c  |  5 +++++
 7 files changed, 45 insertions(+), 6 deletions(-)

-- 
2.54.0



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

* Re: [PULL 0/2] Linux user next patches
  2026-10-15 20:02 Helge Deller
@ 2026-10-16  6:00 ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2026-10-16  6:00 UTC (permalink / raw)
  To: Helge Deller, qemu-devel; +Cc: Andreas Schwab, wangyang, Helge Deller

On 10/15/26 22:02, Helge Deller wrote:
> From: Helge Deller<deller@gmx.de>
> 
> The following changes since commit 8ee6c77176cfee03be0ec7665b6652b2f31f1531:
> 
>    Merge tag 'pull-ufs-20261012' ofhttps://gitlab.com/jeuk20.kim/qemu into staging (2026-10-13 22:01:07 +0200)
> 
> are available in the Git repository at:
> 
>    https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request
> 
> for you to fetch changes up to fdd414709dea458794e03dc64b2495e579133ead:
> 
>    linux-user/riscv: preserve rs1 address for cbo.zero fault reporting (2026-10-14 21:16:41 +0200)
> 
> ----------------------------------------------------------------
> linux user patches
> 
> Two linus user patches:
> - Show correct fault address on riscv
> - Do not trash stderr on unhandled core dump, but instead log it into guest_errors log

This conflicted with the riscv pull.


r~


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

* [PULL 0/2] Linux user next patches
@ 2026-10-27 15:55 Helge Deller
  2026-10-28  8:06 ` Richard Henderson
  0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2026-10-27 15:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Helge Deller, Peter Maydell

From: Helge Deller <deller@gmx.de>

The following changes since commit 4f4225874d4d3747ec1142e935dbd314218992fa:

  Merge tag 'pull-request-2026-10-22' of https://gitlab.com/thuth/qemu into staging (2026-10-22 12:47:21 +0200)

are available in the Git repository at:

  https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request

for you to fetch changes up to 2b1b98f003325761b839b4bbd5af653416d05f72:

  linux-user: Use QemuSemaphore to wait for clone child thread (2026-10-24 17:44:48 +0200)

----------------------------------------------------------------
linux user patches

Two patches from Peter Maydell for linux-user:
One fixes the signal context on loongarch64 and the other replaces an old
pthread implementation by an QemuSemaphore implementation which better mimics
the wanted semantics.

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

Peter Maydell (2):
  linux-user/loongarch64: In extframe_alloc, align before subtracting
    sctx_info size
  linux-user: Use QemuSemaphore to wait for clone child thread

 linux-user/loongarch64/signal.c |  3 ++-
 linux-user/syscall.c            | 17 +++++------------
 2 files changed, 7 insertions(+), 13 deletions(-)

-- 
2.54.0



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

* Re: [PULL 0/2] Linux user next patches
  2026-10-27 15:55 Helge Deller
@ 2026-10-28  8:06 ` Richard Henderson
  0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2026-10-28  8:06 UTC (permalink / raw)
  To: Helge Deller, qemu-devel; +Cc: Helge Deller, Peter Maydell

On 10/27/26 10:55, Helge Deller wrote:
> From: Helge Deller<deller@gmx.de>
> 
> The following changes since commit 4f4225874d4d3747ec1142e935dbd314218992fa:
> 
>    Merge tag 'pull-request-2026-10-22' ofhttps://gitlab.com/thuth/qemu into staging (2026-10-22 12:47:21 +0200)
> 
> are available in the Git repository at:
> 
>    https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request
> 
> for you to fetch changes up to 2b1b98f003325761b839b4bbd5af653416d05f72:
> 
>    linux-user: Use QemuSemaphore to wait for clone child thread (2026-10-24 17:44:48 +0200)
> 
> ----------------------------------------------------------------
> linux user patches
> 
> Two patches from Peter Maydell for linux-user:
> One fixes the signal context on loongarch64 and the other replaces an old
> pthread implementation by an QemuSemaphore implementation which better mimics
> the wanted semantics.

Applied, thanks.

r~


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

* [PULL 0/2] Linux user next patches
@ 2026-11-05 22:55 Helge Deller
  2026-11-05 22:55 ` [PULL 1/2] linux-user: allow a zero-length getrandom with a NULL buffer Helge Deller
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Helge Deller @ 2026-11-05 22:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pierrick Bouvier, Laurent Vivier, Helge Deller

From: Helge Deller <deller@gmx.de>

The following changes since commit f71afb409a87c4ecd0f9d63a5963eb645dfab780:

  Merge tag 'pull-loongarch-20261105' of https://github.com/bibo-mao/qemu into staging (2026-11-05 07:24:53 -0800)

are available in the Git repository at:

  https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request

for you to fetch changes up to fadeabfa77834f7f0e5150bea30c6f0e52dc2b5f:

  linux-user: report EFAULT for a NULL sysinfo/getitimer buffer (2026-11-05 23:43:50 +0100)

----------------------------------------------------------------
linux user patches

Two last patches from TAKANO Mitsuhiro for linux-user to return EFAULT for
getrandom(), sysinfo() and getitimer() syscalls when called with NULL pointers.

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

TAKANO Mitsuhiro (2):
  linux-user: allow a zero-length getrandom with a NULL buffer
  linux-user: report EFAULT for a NULL sysinfo/getitimer buffer

 linux-user/syscall.c                          | 12 ++++-
 tests/tcg/multiarch/linux/linux-null-buffer.c | 48 +++++++++++++++++++
 tests/tcg/multiarch/meson.build               |  1 +
 3 files changed, 59 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/multiarch/linux/linux-null-buffer.c

-- 
2.54.0



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

* [PULL 1/2] linux-user: allow a zero-length getrandom with a NULL buffer
  2026-11-05 22:55 [PULL 0/2] Linux user next patches Helge Deller
@ 2026-11-05 22:55 ` Helge Deller
  2026-11-05 22:55 ` [PULL 2/2] linux-user: report EFAULT for a NULL sysinfo/getitimer buffer Helge Deller
  2026-11-06 20:25 ` [PULL 0/2] Linux user next patches Richard Henderson
  2 siblings, 0 replies; 8+ messages in thread
From: Helge Deller @ 2026-11-05 22:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pierrick Bouvier, Laurent Vivier, Helge Deller

From: TAKANO Mitsuhiro <takano32@gmail.com>

The kernel never looks at the buffer of a zero-length request, so
getrandom(NULL, 0, 0) returns 0.  qemu-user hands the request to
lock_user() unconditionally, and a NULL or otherwise unusable address
fails there with EFAULT even though nothing is copied.

read(), write(), pread64() and pwrite64() already special-case the
zero-length request; do the same here.  The address plays no part in it:
with a zero length it is never dereferenced, whatever value the caller
passes.

Fixes: f894efd19917 ("linux-user: add getrandom() syscall")
Signed-off-by: TAKANO Mitsuhiro <takano32@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c                          |  8 ++++++++
 tests/tcg/multiarch/linux/linux-null-buffer.c | 19 +++++++++++++++++++
 tests/tcg/multiarch/meson.build               |  1 +
 3 files changed, 28 insertions(+)
 create mode 100644 tests/tcg/multiarch/linux/linux-null-buffer.c

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9d85a193ef..59cbf5feaa 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11456,6 +11456,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
 #endif
 #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
     case TARGET_NR_getrandom:
+        if (arg2 == 0) {
+            /*
+             * A zero-length request has no buffer to lock, and the kernel
+             * never looks at the pointer for it, so pass the call through
+             * instead of failing on a NULL or otherwise unusable address.
+             */
+            return get_errno(getrandom(NULL, 0, arg3));
+        }
         p = lock_user(VERIFY_WRITE, arg1, arg2, 0);
         if (!p) {
             return -TARGET_EFAULT;
diff --git a/tests/tcg/multiarch/linux/linux-null-buffer.c b/tests/tcg/multiarch/linux/linux-null-buffer.c
new file mode 100644
index 0000000000..6246e47707
--- /dev/null
+++ b/tests/tcg/multiarch/linux/linux-null-buffer.c
@@ -0,0 +1,19 @@
+/*
+ * A zero-length getrandom() needs no valid buffer: the kernel never looks at
+ * the pointer, so getrandom(NULL, 0, 0) succeeds.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/random.h>
+
+int main(void)
+{
+    errno = 0;
+    assert(getrandom(NULL, 0, 0) == 0);
+
+    return EXIT_SUCCESS;
+}
diff --git a/tests/tcg/multiarch/meson.build b/tests/tcg/multiarch/meson.build
index e60a052700..8f2f57d9ab 100644
--- a/tests/tcg/multiarch/meson.build
+++ b/tests/tcg/multiarch/meson.build
@@ -57,6 +57,7 @@ tests += {
 # Linux tests
 tests += {
   multiarch/'linux/linux-madvise.c': {},
+  multiarch/'linux/linux-null-buffer.c': {},
   multiarch/'linux/linux-shmat-maps.c': {},
   multiarch/'linux/linux-shmat-null.c': {},
   multiarch/'linux/linux-sigrtminmax.c': {},
-- 
2.54.0



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

* [PULL 2/2] linux-user: report EFAULT for a NULL sysinfo/getitimer buffer
  2026-11-05 22:55 [PULL 0/2] Linux user next patches Helge Deller
  2026-11-05 22:55 ` [PULL 1/2] linux-user: allow a zero-length getrandom with a NULL buffer Helge Deller
@ 2026-11-05 22:55 ` Helge Deller
  2026-11-06 20:25 ` [PULL 0/2] Linux user next patches Richard Henderson
  2 siblings, 0 replies; 8+ messages in thread
From: Helge Deller @ 2026-11-05 22:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: Pierrick Bouvier, Laurent Vivier, Helge Deller

From: TAKANO Mitsuhiro <takano32@gmail.com>

Both handlers skip the copy-out when the guest pointer is zero and return
success, so a caller that forgets the buffer gets an uninitialised result
instead of the EFAULT the kernel reports for a NULL address.

Copy unconditionally: a NULL pointer then fails in lock_user_struct() and
in copy_to_user_timeval() like any other unusable address.

Signed-off-by: TAKANO Mitsuhiro <takano32@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/syscall.c                          |  4 +--
 tests/tcg/multiarch/linux/linux-null-buffer.c | 35 +++++++++++++++++--
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 59cbf5feaa..2fc61b3eab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11551,7 +11551,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             struct itimerval value;
 
             ret = get_errno(getitimer(arg1, &value));
-            if (!is_error(ret) && arg2) {
+            if (!is_error(ret)) {
                 if (copy_to_user_timeval(arg2,
                                          &value.it_interval)
                     || copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
@@ -11666,7 +11666,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
             struct target_sysinfo *target_value;
             struct sysinfo value;
             ret = get_errno(sysinfo(&value));
-            if (!is_error(ret) && arg1)
+            if (!is_error(ret))
             {
                 if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0))
                     return -TARGET_EFAULT;
diff --git a/tests/tcg/multiarch/linux/linux-null-buffer.c b/tests/tcg/multiarch/linux/linux-null-buffer.c
index 6246e47707..b099803c57 100644
--- a/tests/tcg/multiarch/linux/linux-null-buffer.c
+++ b/tests/tcg/multiarch/linux/linux-null-buffer.c
@@ -1,6 +1,15 @@
 /*
- * A zero-length getrandom() needs no valid buffer: the kernel never looks at
- * the pointer, so getrandom(NULL, 0, 0) succeeds.
+ * Degenerate buffer pointers must behave like they do in the kernel.
+ *
+ * A zero-length getrandom() needs no valid buffer: the pointer is never
+ * used, so getrandom(NULL, 0, 0) succeeds.  A required output buffer, on
+ * the other hand, must not be silently skipped: sysinfo() and getitimer()
+ * have to report EFAULT for a NULL pointer.
+ *
+ * The NULL cases go through syscall() rather than the libc wrappers: on
+ * 32-bit x86, for example, getitimer() hands the kernel a local structure
+ * and copies the result out itself, so it would follow the NULL pointer
+ * before the kernel's answer could be seen.
  *
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
@@ -9,11 +18,31 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <sys/random.h>
+#include <sys/syscall.h>
+#include <sys/sysinfo.h>
+#include <sys/time.h>
+#include <unistd.h>
 
 int main(void)
 {
+    char buf[8];
+    struct itimerval it;
+    struct sysinfo si;
+
+    /* A zero-length request is not rejected for a NULL buffer. */
     errno = 0;
-    assert(getrandom(NULL, 0, 0) == 0);
+    assert(syscall(SYS_getrandom, NULL, 0, 0) == 0);
+
+    /* A NULL output pointer is reported, not silently skipped. */
+    errno = 0;
+    assert(syscall(SYS_sysinfo, NULL) == -1 && errno == EFAULT);
+    errno = 0;
+    assert(syscall(SYS_getitimer, ITIMER_REAL, NULL) == -1 && errno == EFAULT);
+
+    /* The ordinary calls still work. */
+    assert(getrandom(buf, sizeof(buf), 0) == sizeof(buf));
+    assert(sysinfo(&si) == 0);
+    assert(getitimer(ITIMER_REAL, &it) == 0);
 
     return EXIT_SUCCESS;
 }
-- 
2.54.0



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

* Re: [PULL 0/2] Linux user next patches
  2026-11-05 22:55 [PULL 0/2] Linux user next patches Helge Deller
  2026-11-05 22:55 ` [PULL 1/2] linux-user: allow a zero-length getrandom with a NULL buffer Helge Deller
  2026-11-05 22:55 ` [PULL 2/2] linux-user: report EFAULT for a NULL sysinfo/getitimer buffer Helge Deller
@ 2026-11-06 20:25 ` Richard Henderson
  2 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2026-11-06 20:25 UTC (permalink / raw)
  To: Helge Deller, qemu-devel; +Cc: Pierrick Bouvier, Laurent Vivier, Helge Deller

On 11/5/26 14:55, Helge Deller wrote:
> From: Helge Deller<deller@gmx.de>
> 
> The following changes since commit f71afb409a87c4ecd0f9d63a5963eb645dfab780:
> 
>    Merge tag 'pull-loongarch-20261105' ofhttps://github.com/bibo-mao/qemu into staging (2026-11-05 07:24:53 -0800)
> 
> are available in the Git repository at:
> 
>    https://github.com/hdeller/qemu-hppa.git tags/linux-user-next-pull-request
> 
> for you to fetch changes up to fadeabfa77834f7f0e5150bea30c6f0e52dc2b5f:
> 
>    linux-user: report EFAULT for a NULL sysinfo/getitimer buffer (2026-11-05 23:43:50 +0100)
> 
> ----------------------------------------------------------------
> linux user patches
> 
> Two last patches from TAKANO Mitsuhiro for linux-user to return EFAULT for
> getrandom(), sysinfo() and getitimer() syscalls when called with NULL pointers.

Applied, thanks.

r~


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

end of thread, other threads:[~2026-11-06 20:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-05 22:55 [PULL 0/2] Linux user next patches Helge Deller
2026-11-05 22:55 ` [PULL 1/2] linux-user: allow a zero-length getrandom with a NULL buffer Helge Deller
2026-11-05 22:55 ` [PULL 2/2] linux-user: report EFAULT for a NULL sysinfo/getitimer buffer Helge Deller
2026-11-06 20:25 ` [PULL 0/2] Linux user next patches Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2026-10-27 15:55 Helge Deller
2026-10-28  8:06 ` Richard Henderson
2026-10-15 20:02 Helge Deller
2026-10-16  6:00 ` Richard Henderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.