From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=166.70.13.231 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796404450; b=sDQqFVKeoU5/HPEpFNwxC12kxcZplKlcAou7gnd7qovfkJd9V7VTyl73xy12vOyMrDGo vovbaCsS5Thw70IRAZMH+VMHAkhRbvOAWCBCZ626OmsxEePtV7mkXc9ldwTaxBxG4jTVb /+ZtSDLJ6+KZoxW6H1IcIO0o9CQoVMMxqj3FQxT18WAqGfTPiLeZ6KRTdZbb65MSMFjJB pVu6yMd2ApAHYYyxIney7dqc5hzwnyUPozI5h6Beqss/yMuTqYrfFZOHYdbGI6zqZMuIM XemMlwGpJnw51mVqk3Kd2p3TzsR6nGlq9URKuUDVhw+oP6n9zmuJHFhm8f2vJpzlfPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796404450; h=DMARC-Filter:DKIM-Signature:Received:Received:From:To:Cc:In-Reply-To: References:Date:Message-ID:User-Agent:MIME-Version:Content-Type: X-XM-SPF:X-XM-AID:X-Spam-Checker-Version:X-Spam-Level:X-Spam-Status: X-Spam-Report:X-Spam-DCC:X-Spam-Combo:X-Spam-Relay-Country: X-Spam-Timing:Subject:X-SA-Exim-Connect-IP:X-SA-Exim-Rcpt-To: X-SA-Exim-Mail-From:X-SA-Exim-Scanned; bh=hbRhfADEps+vSSrpdLvyPOGzZMmE6CFw4TWBskedTKo=; b=j+n/w9PM/ZAmB0ql4I/grvcFmYhPc25jRN+BS03pKuKjGx2dKN5Cqsm3JaS01rMS2kMx cVW8x6t3E0vfYhX3NsfO9Y9iUnLH6l/0SgHKrJpxqiW+T11C6BWtg0FhXk7qcfF1CUDej Aw6umaEXXhSTjQ63Msg/Roh9MiUUhYktYMsAViM4tiasr03f7UTg3ybj6mG7NTfMRShN6 NcZqiiEjc9cNnvnBmWDoGQviND8Ng5cXZG7xBMe+tBGR9P7EalcQhgkUiq9aZ19TL0T1q kGmQXUugzp0ef75I/+R1hAfUXNWcOujhjO0o2Gnn/kAas64I+1ECSc4gxTasNDpVyqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=xmission.com; spf=pass smtp.mailfrom=xmission.com; dkim=pass header.d=xmission.com header.i=@xmission.com header.a=rsa-sha256 header.s=xmission header.b=caBgNGZk; arc=none smtp.remote-ip=166.70.13.231 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57D8C606A338; Fri, 4 Dec 2026 17:14:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 57D8C606A338 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=xmission.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xmission.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=xmission.com header.i=@xmission.com header.a=rsa-sha256 header.s=xmission header.b=caBgNGZk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=xmission.com; s=xmission; h=Subject:Content-Type:MIME-Version:Message-ID:Date:References: In-Reply-To:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fIrtKH4FyNzgnLS3GHqtb/ZSwB4uG4Ae1VrybeuLoqs=; b=caBgNGZkE9z9qrHENdERSqWZD6 CVQYREZGc/1eeuVrxUcmQp//Q5V3bFyMjML3qEMM6wrXJTuHXXAZqDRq7KOu5ZUOsXjznESPtnXgM ADu2332m+WAlyEj6d8MAF+xlWXqni1kN/j/qrCzMM2Fbb9QCMOFGdwdsJZTknyiSyRPs=; Received: from in01.mta.xmission.com ([166.70.13.51]:53586) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1xZWrD-00DHTW-2v; Fri, 04 Dec 2026 10:14:03 -0700 Received: from ip72-198-196-98.om.om.cox.net ([72.198.196.98]:33476 helo=email.froward.int.ebiederm.org.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1xZWrB-00FKif-VK; Fri, 04 Dec 2026 10:14:02 -0700 From: "Eric W. Biederman" To: Alejandro Colomar Cc: Raphael Bauer , linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , Tejun Heo , Matt Fleming , Arnd Bergmann , Thomas Gleixner , Peter Zijlstra In-Reply-To: (Alejandro Colomar's message of "Wed, 2 Dec 2026 00:26:30 +0100") References: Date: Fri, 04 Dec 2026 11:13:55 -0600 Message-ID: <87a4mlezos.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1xZWrB-00FKif-VK;;;mid=<87a4mlezos.fsf@email.froward.int.ebiederm.org>;;;hst=in01.mta.xmission.com;;;ip=72.198.196.98;;;frm=ebiederm@xmission.com;;;spfnum=0;;;sPf=pass X-XM-AID: U2FsdGVkX19PDR+zZmEWViD1aEJUi7Ob1cJSry5+Nr0= X-Spam-Level: X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * -0.5 BAYES_40 BODY: Bayes spam probability is 20 to 40% * [score: 0.3864] * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.4 XMBrknScrpt_02 Possible Broken Spam Script * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 XM_B_AI_SPAM_COMBINATION Email matches multiple AI-related * patterns X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Alejandro Colomar X-Spam-Relay-Country: X-Spam-Timing: total 547 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 8 (1.4%), b_tie_ro: 7 (1.2%), parse: 0.86 (0.2%), extract_message_metadata: 11 (2.1%), get_uri_detail_list: 2.3 (0.4%), tests_pri_-2000: 5 (0.9%), tests_pri_-1000: 2.5 (0.5%), tests_pri_-950: 1.13 (0.2%), tests_pri_-900: 0.80 (0.1%), tests_pri_-90: 88 (16.2%), check_bayes: 87 (15.8%), b_tokenize: 10 (1.8%), b_tok_get_all: 8 (1.5%), b_comp_prob: 4.1 (0.7%), b_tok_touch_all: 60 (10.9%), b_finish: 1.16 (0.2%), tests_pri_0: 409 (74.8%), check_dkim_signature: 0.73 (0.1%), check_dkim_adsp: 3.8 (0.7%), poll_dns_idle: 1.04 (0.2%), tests_pri_10: 3.2 (0.6%), tests_pri_500: 13 (2.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: sigwaitinfo.2: sigtimedwait() fails with EINTR, without a signal handler, when another thread accepts a process-directed signal X-SA-Exim-Connect-IP: 166.70.13.51 X-SA-Exim-Rcpt-To: peterz@infradead.org, tglx@kernel.org, arnd@arndb.de, matt.fleming@linux.intel.com, tj@kernel.org, oleg@redhat.com, linux-kernel@vger.kernel.org, linux-man@vger.kernel.org, raphael.bauer@atsec.com, alx+linux-man@kernel.org X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on out01.mta.xmission.com); SAEximRunCond expanded to false Alejandro Colomar writes: > Hi Raphael, > >> Date: 2026-12-01 14:05:28+0100 >> From: Raphael Bauer >> >> Hi Alejandro, >> >> When two threads of a process wait in sigtimedwait() for the same signal and >> that signal is sent to the process (here by alarm()), one thread accepts it, >> and the other fails with EINTR at that same moment instead of failing with >> EAGAIN at its timeout. No signal handler is installed. The EINTR entry in >> sigwaitinfo.2 (the page for sigtimedwait(2)) names only a signal handler as >> the cause, and I found nothing else in that page or in signal(7) that covers >> this case. I read this in man-pages 6.13 as installed; the current page in >> man-pages.git has the same wording. >> >> I can't tell whether the page or the kernel should change, so I'm copying >> LKML. > > I have CCd a few people that have been involved in implementing > sigtimedwait(2) --according to git-blame(1)--. > >> Could you, or someone on LKML, say which it is? > > I don't know much about this API, so can't answer. But unless someone > considers this a bug, I guess we should document what happens at the > moment (it's good to CC them just in case). There is an issue with the test program. It only blocks SIG_ALARM. Any other signal can come in and cause the other thread to say -EINTR. So this looks like it could be exactly the documented behavior in the manpage. I don't see anything obvious that would generate another signal, but some more sleuthing needs to be done to rule out another signal before we can say anything. If there is no other signal then it is likely a bug in the kernel as all of the wakeups I see only wake up a single thread. I suspect a quick run of the test program under gdb or strace (following all of the threads) would show what is going on. Eric >> Reproducer: both threads block SIGALRM and wait for it with a timeout of 2.5s; >> main calls alarm(1). >> >> #define _GNU_SOURCE >> #include >> #include >> #include >> #include >> #include >> #include >> #include >> >> static pthread_barrier_t barrier; >> >> static void *waiter(void *name) >> { >> sigset_t set; >> struct timespec timeout = { 2, 500000000 }; /* 2.5 s */ >> int sig; >> >> sigemptyset(&set); >> sigaddset(&set, SIGALRM); >> pthread_barrier_wait(&barrier); >> sig = sigtimedwait(&set, NULL, &timeout); >> printf("%-6s: sigtimedwait() = %d%s%s\n", (char *) name, sig, >> sig == -1 ? ", errno " : "", sig == -1 ? >> strerrorname_np(errno) : ""); >> return NULL; >> } >> >> int main(void) >> { >> sigset_t set; >> pthread_t thread; >> >> sigemptyset(&set); >> sigaddset(&set, SIGALRM); >> sigprocmask(SIG_BLOCK, &set, NULL); /* inherited by the thread >> */ >> >> pthread_barrier_init(&barrier, NULL, 2); >> pthread_create(&thread, NULL, waiter, "thread"); >> alarm(1); >> waiter("main"); >> pthread_join(thread, NULL); >> return 0; >> } >> >> Output on SUSE Linux Enterprise Server 16.0 (kernel >> 6.12.0-160000.5-default), the same in each of 10 runs; both lines appear >> after 1.0 s, and 14 is SIGALRM: >> >> main : sigtimedwait() = 14 >> thread: sigtimedwait() = -1, errno EINTR > > Thanks! Please keep this reproducer in the commit message of the patch, > if you send one. (Indent it so that git(1) doesn't consider the > '#include' lines to be comments.) > > > Have a lovely night! > Alex > >> >> Without the alarm(1), both threads fail with EAGAIN after 2.5 s. I have not >> tried other kernels. >> >> Thanks, >> Raphael Bauer Eric