All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] patch to swap SIGRTMIN + 1 and SIGRTMAX - 1
@ 2019-06-21 22:58 Marlies Ruck
  2019-06-28 23:26 ` Marlies Ruck
  0 siblings, 1 reply; 12+ messages in thread
From: Marlies Ruck @ 2019-06-21 22:58 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

Hi,

Attached is a patch to let guest programs use SIGRTMIN + 1 by swapping with
SIGRTMAX - 1. Since QEMU links against glibc, it reserves the signal for
itself and returns EINVAL (as noted in the commit message). This means
various applications that use SIGRTMIN + 1 cannot run on QEMU, including
G-WAN web server and Open TFTP.

Thanks,
Marli

[-- Attachment #2: 0001-Swap-SIGRTMIN-1-and-SIGRTMAX-1.patch --]
[-- Type: application/octet-stream, Size: 1873 bytes --]

From 096c244668345f80a4582799d0b860b7c20a9b59 Mon Sep 17 00:00:00 2001
From: marlies ruck <marlies@forallsecure.com>
Date: Fri, 21 Jun 2019 14:42:42 -0700
Subject: [PATCH] Swap SIGRTMIN + 1 and SIGRTMAX - 1

We already have a hack whereby we flip the guest's SIGRTMAX and SIGRTMIN
signals, to avoid a collision between guest use of SIGRTMIN and the host
libc use of it for SIGCANCEL. However newer glibc also uses SIGRTMIN+1
for internal purposes (as SIGSETXID). Reverse SIGRTMIN+1 and SIGRTMAX-1
so the guest can successfully use SIGRTMIN+1.

This didn't cause any immediately observed issues in guests because glibc
does not check the return value when it registers a SIGSETXID handler(!).
However it meant that if a guest program with more than one thread issued
a setuid() syscall it would hang.

Credit: Peter Maydell https://patches.linaro.org/patch/63313/
Signed-off-by: marlies ruck <marlies@forallsecure.com>
---
 linux-user/signal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 5cd237834d..137a449140 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -75,8 +75,12 @@ static uint8_t host_to_target_signal_table[_NSIG] = {
     /* Nasty hack: Reverse SIGRTMIN and SIGRTMAX to avoid overlap with
        host libpthread signals.  This assumes no one actually uses SIGRTMAX :-/
        To fix this properly we need to do manual signal delivery multiplexed
-       over a single host signal.  */
+       over a single host signal.
+       Similarly we reverse SIGRTMIN + 1 and SIGRTMAX - 1, because
+       host glibc uses SIGRTMIN+1 for SIGSETXID. */
     [__SIGRTMIN] = __SIGRTMAX,
+    [__SIGRTMIN + 1] = __SIGRTMAX - 1,
+    [__SIGRTMAX - 1] = __SIGRTMIN + 1,
     [__SIGRTMAX] = __SIGRTMIN,
 };
 static uint8_t target_to_host_signal_table[_NSIG];
-- 
2.20.1 (Apple Git-117)


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* Re: [Qemu-devel] patch to swap SIGRTMIN + 1 and SIGRTMAX - 1
@ 2019-08-19 21:46 Josh Kunz via Qemu-devel
  2019-08-21  9:28 ` Laurent Vivier
  0 siblings, 1 reply; 12+ messages in thread
From: Josh Kunz via Qemu-devel @ 2019-08-19 21:46 UTC (permalink / raw)
  To: marlies.ruck, qemu-devel, riku.voipio, laurent
  Cc: qemu-trivial, peter.maydell, Shu-Chun Weng

Hi all,

I have also experienced issues with SIGRTMIN + 1, and am interested in
moving this patch forwards. Anything I can do here to help? Would the
maintainers prefer myself or Marli re-submit the patch?

The Go issue here seems particularly sticky. Even if we update the Go
runtime, users may try and run older binaries built with older versions of
Go for quite some time (months? years?). Would it be better to hide this
behind some kind of build-time flag (`--enable-sigrtmin-plus-one-proxy` or
something), so that some users can opt-in, but older binaries still work as
expected?

Also, here is a link to the original thread this message is in reply to
in-case my mail-client doesn't set up the reply properly:
https://lists.nongnu.org/archive/html/qemu-devel/2019-07/msg01303.html

Thanks,
Josh Kunz

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

end of thread, other threads:[~2019-12-07 16:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-21 22:58 [Qemu-devel] patch to swap SIGRTMIN + 1 and SIGRTMAX - 1 Marlies Ruck
2019-06-28 23:26 ` Marlies Ruck
2019-06-29 10:53   ` Philippe Mathieu-Daudé
2019-07-01  9:08     ` Peter Maydell
2019-07-01 22:04       ` Marlies Ruck
2019-07-03 21:11         ` Marlies Ruck
2019-08-19 21:46 Josh Kunz via Qemu-devel
2019-08-21  9:28 ` Laurent Vivier
2019-08-26 21:10   ` Josh Kunz via Qemu-devel
2019-08-27  8:08     ` Peter Maydell
2019-08-28  8:51     ` Laurent Vivier
2019-08-28 17:31       ` [Qemu-devel] [EXTERNAL]Re: " Aleksandar Markovic
2019-12-07 13:05         ` [Qemu-devel] " Aleksandar Markovic

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.