public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: /proc/<PID>/status: avoid crash computing signal info
Date: Tue, 10 Jan 2023 10:48:47 +0000 (GMT)	[thread overview]
Message-ID: <20230110104847.17A663858C78@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7c14e5a10add3ad3dc53ed6af1ad2044d205e844

commit 7c14e5a10add3ad3dc53ed6af1ad2044d205e844
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Tue Jan 10 11:45:28 2023 +0100
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Tue Jan 10 11:48:02 2023 +0100

    Cygwin: /proc/<PID>/status: avoid crash computing signal info
    
    The code computing the mask of pending signals used the per-queued
    signal TLS pointer without checking it for NULL.  Fix this by using
    the process-wide signal mask in that case.
    
    Fixes: 195169186bfd5 ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/release/3.4.4 | 3 +++
 winsup/cygwin/sigproc.cc    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/release/3.4.4 b/winsup/cygwin/release/3.4.4
index a653b08a1a40..35d746ba08fd 100644
--- a/winsup/cygwin/release/3.4.4
+++ b/winsup/cygwin/release/3.4.4
@@ -10,3 +10,6 @@ Bug Fixes
 
 - Reinstantiate exporting _alloca.
   Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252797.html
+
+- Avoid hangs when reading /proc/<PID>/status.
+  Addresses: https://cygwin.com/pipermail/cygwin/2022-December/252756.html
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index ce36c8be37fb..86e4e607ab7e 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1375,7 +1375,8 @@ wait_sig (VOID *)
 	    *pack.mask = 0;
 	    while ((q = q->next))
 	      {
-		if (q->sigtls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
+		_cygtls *sigtls = q->sigtls ?: _main_tls;
+		if (sigtls->sigmask & (bit = SIGTOMASK (q->si.si_signo)))
 		  {
 		    tl_entry = cygheap->find_tls (q->si.si_signo, issig_wait);
 		    if (tl_entry)

                 reply	other threads:[~2023-01-10 10:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230110104847.17A663858C78@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).