qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marlies Ruck <marlies.ruck@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] patch to swap SIGRTMIN + 1 and SIGRTMAX - 1
Date: Fri, 21 Jun 2019 15:58:42 -0700	[thread overview]
Message-ID: <CALw29ZZZ08Lt13oZsbZCwV+uP0roLuT6t+8m16y+8YT-KH4t7A@mail.gmail.com> (raw)

[-- 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)


             reply	other threads:[~2019-06-22  0:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-21 22:58 Marlies Ruck [this message]
2019-06-28 23:26 ` [Qemu-devel] patch to swap SIGRTMIN + 1 and SIGRTMAX - 1 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

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=CALw29ZZZ08Lt13oZsbZCwV+uP0roLuT6t+8m16y+8YT-KH4t7A@mail.gmail.com \
    --to=marlies.ruck@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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).