qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user: make process_pending_signals thread-safe
@ 2021-05-24  2:46 Hamza Mahfooz
  2021-05-27 10:16 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Hamza Mahfooz @ 2021-05-24  2:46 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel, Hamza Mahfooz

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



^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] linux-user: make process_pending_signals thread-safe
@ 2021-04-27  6:32 effective-light
  0 siblings, 0 replies; 6+ messages in thread
From: effective-light @ 2021-04-27  6:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, laurent, effective-light

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



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

end of thread, other threads:[~2021-05-27 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-24  2:46 [PATCH] linux-user: make process_pending_signals thread-safe Hamza Mahfooz
2021-05-27 10:16 ` 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

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