From nobody Tue Apr 23 16:52:34 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VP7TH1FqHz5HcMh; Tue, 23 Apr 2024 16:52:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VP7TG5pbgz4875; Tue, 23 Apr 2024 16:52:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713891154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EPxgEIbd6gSpTls4ab0knQ6/mkxv+VewSBVLqcZlaWU=; b=CCShln7ASYXMsPPFMSzBjnseemabL7hx7INsQ/UjcD2Tr/2TZFgqkgQUhiCe3jnx/P9qpy VCK5N4eo9IEGiOsL969UC/3q0AZtkRofq6hCt994MuE+91W/8gF8tzRm8lyOhJfOA6WCuI eUTiHyY0XK8xLsuCyIL9q6FMml2KkS2WFmVCva9EaJxgJctq+pihP6U336LKY/0/RLxSZB LA5WmfRQrx7qLpJdqpWMeDGn5rK9fNMarWlkpfo45b38GuwzDE5zXk0xNB/Yf7WgoEfBkF /eeF0pNsxd92YWu2CiaFz4nx6wzOSHL6KqLAW5MEBaRlXbua9Sh6asmSY6kPlg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713891154; a=rsa-sha256; cv=none; b=U9cJlP3pk8uvpiSYonGJqlUh4ltFlAG7q9svCDKJgeKrcTscVztpCewV+MWOyVOgh8+GIN nsPLt40F8n7gdW4AqWzhs5Vi3ZgjhadhQCp4Ra0XFUB/jW1bxiv4xbFFv/yY448CAaW1KB rMx7dVHjXv9jG61zHCaifU+trr6u6WF7y2CnsE0GQV1SBrdJBEJKX8UUur21Qxx01GnsV0 RzyexsZRz6+o8++PHJdvzWzNV8HmOjrYFfLsK/7j3HuSgNqISyex7Ci6VAkyX53vMYo3Lc sJiDFOXC9mW80DgHCoKObEGR5O+2tf3hxqGJbIWdHgX6LuXc7/DfPqsvCZ7Ztg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713891154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EPxgEIbd6gSpTls4ab0knQ6/mkxv+VewSBVLqcZlaWU=; b=ClM7tjqRMnSH2j17Rc4KNiXh83jY1i+aWMbDtd64/rXaEqbYo8soSKAPKxgGzSk6KhiQBV 1e6ua59R7ZAd6HRXRgYdfUqAotoRWXGjpGy38L1Xfij8tU6hRA20xB4JL6VpYuxWvYvg5O wt4k4xgQ7xFWASPCao/GkLw5WZIhvJipbqTNt58KBtqCKREAFPM08CBSKhv/4sQEanIqno GyUeTL9HXeNF+/DH8vOGAzM3l3fbq93+TPFJHG3m8SARMxXCxTfArE7f7XpXM2fDwOa3O6 qVMfyy4XIQciWxh1BUelxJ2pJQ9mzTB5Ab4fhUtqo/LaVL4Np1PASgS7jkLBuw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VP7TG55hqzgB8; Tue, 23 Apr 2024 16:52:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43NGqYm5088111; Tue, 23 Apr 2024 16:52:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43NGqYxS088108; Tue, 23 Apr 2024 16:52:34 GMT (envelope-from git) Date: Tue, 23 Apr 2024 16:52:34 GMT Message-Id: <202404231652.43NGqYxS088108@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 53186bc1435e - main - sigqueue(2): add impl-specific flag __SIGQUEUE_TID List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 53186bc1435e2c3ccf9c2124c066a08c6a80c504 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=53186bc1435e2c3ccf9c2124c066a08c6a80c504 commit 53186bc1435e2c3ccf9c2124c066a08c6a80c504 Author: Konstantin Belousov AuthorDate: 2024-04-19 14:29:05 +0000 Commit: Konstantin Belousov CommitDate: 2024-04-23 16:51:09 +0000 sigqueue(2): add impl-specific flag __SIGQUEUE_TID The flag allows the pid argument to designate a thread from the calling process. The flag value is carved from the high bit of the signal number, which slightly changes the ABI of syscall. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44867 --- sys/kern/kern_sig.c | 22 +++++++++++++++++----- sys/sys/signal.h | 4 ++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index a533460090eb..7ac9dcb8cb40 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2012,13 +2012,16 @@ sys_sigqueue(struct thread *td, struct sigqueue_args *uap) } int -kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value) +kern_sigqueue(struct thread *td, pid_t pid, int signumf, union sigval *value) { ksiginfo_t ksi; struct proc *p; + struct thread *td2; + u_int signum; int error; - if ((u_int)signum > _SIG_MAXSIG) + signum = signumf & ~__SIGQUEUE_TID; + if (signum > _SIG_MAXSIG) return (EINVAL); /* @@ -2028,8 +2031,17 @@ kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value) if (pid <= 0) return (EINVAL); - if ((p = pfind_any(pid)) == NULL) - return (ESRCH); + if ((signumf & __SIGQUEUE_TID) == 0) { + if ((p = pfind_any(pid)) == NULL) + return (ESRCH); + td2 = NULL; + } else { + p = td->td_proc; + td2 = tdfind((lwpid_t)pid, p->p_pid); + if (td2 == NULL) + return (ESRCH); + } + error = p_cansignal(td, p, signum); if (error == 0 && signum != 0) { ksiginfo_init(&ksi); @@ -2039,7 +2051,7 @@ kern_sigqueue(struct thread *td, pid_t pid, int signum, union sigval *value) ksi.ksi_pid = td->td_proc->p_pid; ksi.ksi_uid = td->td_ucred->cr_ruid; ksi.ksi_value = *value; - error = pksignal(p, ksi.ksi_signo, &ksi); + error = tdsendsignal(p, td2, ksi.ksi_signo, &ksi); } PROC_UNLOCK(p); return (error); diff --git a/sys/sys/signal.h b/sys/sys/signal.h index 068a7e7bc6da..690cab414e9e 100644 --- a/sys/sys/signal.h +++ b/sys/sys/signal.h @@ -475,6 +475,10 @@ struct sigstack { #if __BSD_VISIBLE #define BADSIG SIG_ERR + +/* sigqueue(2) signo high-bits flags */ +#define __SIGQUEUE_TID 0x80000000 /* queue for tid, instead of pid */ +#define __SIGQUEUE_RSRV 0x40000000 /* reserved */ #endif #if __POSIX_VISIBLE || __XSI_VISIBLE