qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hamza Mahfooz <someguy@effective-light.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org,
	Hamza Mahfooz <someguy@effective-light.com>
Subject: [PATCH] linux-user: make process_pending_signals thread-safe
Date: Sun, 23 May 2021 22:46:55 -0400	[thread overview]
Message-ID: <20210524024655.11115-1-someguy@effective-light.com> (raw)

Use pthread_sigmask instead of sigprocmask inside process_pending_signals
to ensure that race conditions aren't possible.

Signed-off-by: Hamza Mahfooz <someguy@effective-light.com>
---
 linux-user/signal.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/linux-user/signal.c b/linux-user/signal.c
index 7eecec46c4..81ff753c01 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -1005,9 +1005,8 @@ void process_pending_signals(CPUArchState *cpu_env)
     sigset_t *blocked_set;
 
     while (qatomic_read(&ts->signal_pending)) {
-        /* FIXME: This is not threadsafe.  */
         sigfillset(&set);
-        sigprocmask(SIG_SETMASK, &set, 0);
+        pthread_sigmask(SIG_SETMASK, &set, 0);
 
     restart_scan:
         sig = ts->sync_signal.pending;
-- 
2.31.1



             reply	other threads:[~2021-05-24  2:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24  2:46 Hamza Mahfooz [this message]
2021-05-27 10:16 ` [PATCH] linux-user: make process_pending_signals thread-safe Peter Maydell
2021-05-27 10:37   ` Hamza Mahfooz
2021-05-27 10:45     ` Peter Maydell
2021-05-27 12:16       ` Hamza Mahfooz
  -- strict thread matches above, loose matches on Subject: below --
2021-04-27  6:32 effective-light

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=20210524024655.11115-1-someguy@effective-light.com \
    --to=someguy@effective-light.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).