From patchwork Tue Mar 1 16:37:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 63313 Delivered-To: patches@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1928921lbc; Tue, 1 Mar 2016 08:37:21 -0800 (PST) X-Received: by 10.194.222.234 with SMTP id qp10mr21283036wjc.138.1456850241764; Tue, 01 Mar 2016 08:37:21 -0800 (PST) Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id f88si86084wmi.3.2016.03.01.08.37.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Mar 2016 08:37:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84) (envelope-from ) id 1aanIX-0005pJ-2o; Tue, 01 Mar 2016 16:37:21 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, patches@linaro.org, Riku Voipio Subject: [RFC] linux-user: Use SIGRTMAX-1 for guest SIGRTMIN+1 to avoid conflict with host libc Date: Tue, 1 Mar 2016 16:37:20 +0000 Message-Id: <1456850240-21096-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.9.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. Signed-off-by: Peter Maydell --- This is sent as an RFC because although I think it is the right thing it is potentially enabling a bunch of glibc code that we weren't even going to attempt to run before. Probably this just means a different style of deadlock if you attempt setuid() calls in a multithreaded process, though... Does anybody actually have an idea about how the "manual signal delivery multiplexed over a single host signal" would work? linux-user/signal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/linux-user/signal.c b/linux-user/signal.c index 962111c..487cc5f 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];