NetBSD Problem Report #56532

From  Wed Dec  1 21:47:43 2021
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 7448C1A921F
	for <>; Wed,  1 Dec 2021 21:47:43 +0000 (UTC)
Message-Id: <>
Date: Wed,  1 Dec 2021 21:47:41 +0000 (UTC)
Subject: RPC client unconditionally unblock user signals
X-Send-Pr-Version: www-1.0

>Number:         56532
>Category:       lib
>Synopsis:       RPC client unconditionally unblock user signals
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 01 21:50:00 +0000 2021
>Originator:     Anthony Mallet
>Release:        -current
NetBSD ficus 9.99.91 NetBSD 9.99.91 (FICUS) #31: Sat Oct 16 15:04:36 CEST 2021  troot@ficus:/usr/obj/sys/arch/amd64/compile/FICUS amd64

RPC client functions unconditionally unblock SIGINT, SIGTERM and SIGQUIT
and others for a small amount of time. This happens for instance in clnt_vc_call()

This was introduced in rev. 1.23 of clnt_vc.c
and rev. 1.29 of clnt.dg.c

It happens that I have a program that blocks those signals in all threads and uses a dedicated thread to handle the signals with sigwait(2).
In this context, a thread using RPC calls will wrongly unblock the signals and this leaves a small time window where the signal will be received by a thread not prepared to deal with it.

I think that the thr_sigsetmask function should be called with SIG_BLOCK instead of SIG_SETMASK to not alter the existing mask. The attached patch shows an example for clnt_vc_destroy(). I can provide a complete patch if you agree with this change.


Index: clnt_vc.c
RCS file: /cvsroot/src/lib/libc/rpc/clnt_vc.c,v
retrieving revision 1.27
diff -u -r1.27 clnt_vc.c
--- clnt_vc.c   21 Aug 2021 23:00:30 -0000      1.27
+++ clnt_vc.c   1 Dec 2021 21:46:12 -0000
@@ -664,7 +664,7 @@
        ct = (struct ct_data *) cl->cl_private;

-       thr_sigsetmask(SIG_SETMASK, &newmask, &mask);
+       thr_sigsetmask(SIG_BLOCK, &newmask, &mask);
 #ifdef _REENTRANT
        ct_fd = ct->ct_fd;

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.