From nobody Fri Jun 17 19:41:34 2022 X-Original-To: dev-commits-src-branches@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 4F4FD85DE8D; Fri, 17 Jun 2022 19:41: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 4LPqDG5rCNz3jB5; Fri, 17 Jun 2022 19:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494895; 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=3yWoIhSsDThvCygtXAIctz9LOyNkDhD8kTobaY4QW7g=; b=B7zB9YF89KsYjM7tn7Y11H6spkNd7qYp8dauY5R0l9kUBu5HWBloh0SwIOGSAnOYrxtvmQ lhMBTAkDIT6owNPdHCrjIf86ZGSjnGwOZtkn134OxgUmdieG3qbVjUB1J2WlH1+IfH8Qib z0goN9oF3l/mtpPc3L7rg99HUaxRcyWX4LDJUCVsYqIfmGbgPlpFH/EVpUjysy1Gcki+/S kBSSqkjzqXOBe3VlkceIaOAgZof396dmk2hQEs2DVlWeCe3kKZW+CknPtGvWwe12foT7xY HtoXFfuGNi0c5AnLtPywqxebbLMWGOULo2eggnAzGPK1XGAssTESHsE5ZZ60VA== 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 38D6125A6A; Fri, 17 Jun 2022 19:41:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJfYgm030641; Fri, 17 Jun 2022 19:41:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJfYCk030640; Fri, 17 Jun 2022 19:41:34 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:41:34 GMT Message-Id: <202206171941.25HJfYCk030640@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: d37548e01059 - stable/13 - linux(4): Properly restore the thread signal mask after signal delivery on i386 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d37548e01059f7cff3b88bebe894b7519b7fd1e6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494895; 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=3yWoIhSsDThvCygtXAIctz9LOyNkDhD8kTobaY4QW7g=; b=B9ruviRJ0SEn+NwJtgaZ8cX9fGdxWISHXHhMxpD9g/p5emBsu6r3ANrZE8i67sJXucWvp6 m9CwGC4N1uGgSZ0+XStCFdr64ZZ6gQdHRoDVofv1vW6h0+4e/kMd6UNA+LCQIeWItXbY4+ i5Zfu64L7MKuw+K/DGkWrmoaHF0KgVIHStLDNzJ6JaVw1TLtWoDxfkNAsR9lkB6h/pJ1Ak 3nqwNlxBysbWBp3oV0ELpRu/FMG0QsyYy3ZyixhP/xpkA4ygBOf728rOcik41wEK2mJ2XJ WE4xWfp8gdzNrKtf9vRD65pv5aB+FOfCarNUCa8cMrArfnlSjAaTW9KtVapKRA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494895; a=rsa-sha256; cv=none; b=vFkPPMBL85HUD3sLOqGZHSa35t++pAIO025VB3KGnpToFNq1mL1JjFzlyPqrECq/vemDqP N42SZxCnMdgn+JU61IgAAhJ+sZNy5q2xz6LMf/voSi7pLO2xiB1dkVr8GaCr9LNiCtQ/ZB NUJqlrGU3RxdV4AOevQmDUiToqSy25A6usz9GorOV70t18RNFywRXEyVpu0YOUxCxlzrga OS+2wmAesaqgzLRQQoqWby+sRcmO4PCHoFXZd/FdUnE/MrTtcNKwbxQJLKyFsPxR+OOw0P ht/U5q6B0qi1JvAgBSEXNVX1d1LG9+TNl5Nty+V9LoubAR3JAHIdtptFoFBEIg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=d37548e01059f7cff3b88bebe894b7519b7fd1e6 commit d37548e01059f7cff3b88bebe894b7519b7fd1e6 Author: Dmitry Chagin AuthorDate: 2022-05-30 17:03:49 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:40 +0000 linux(4): Properly restore the thread signal mask after signal delivery on i386 Replace sigframe sf_extramask by native sigset_t and use it to store/restore the thread signal mask without conversion to/from Linux signal mask. Pointy hat to: dchagin MFC after: 2 weeks (cherry picked from commit 4a6c2d075da0c5105269e6edcbe57bf6aaa0a0ae) --- sys/amd64/linux32/linux32_sysvec.c | 11 ++--------- sys/i386/linux/linux_sysvec.c | 10 ++-------- sys/x86/linux/linux_x86_sigframe.h | 2 +- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c index 2b0d2d267fbe..4b6464bd7b81 100644 --- a/sys/amd64/linux32/linux32_sysvec.c +++ b/sys/amd64/linux32/linux32_sysvec.c @@ -373,7 +373,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) bzero(&frame, sizeof(frame)); frame.sf_sig = sig; - + frame.sf_sigmask = *mask; bsd_to_linux_sigset(mask, &lmask); /* Build the signal context to be used by sigreturn. */ @@ -399,8 +399,6 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) frame.sf_sc.sc_cr2 = (u_int32_t)(uintptr_t)ksi->ksi_addr; frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code); - frame.sf_extramask[0] = lmask.__mask; - if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal @@ -442,8 +440,6 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args) { struct l_sigframe frame; struct trapframe *regs; - sigset_t bmask; - l_sigset_t lmask; int eflags; ksiginfo_t ksi; @@ -477,10 +473,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args) return(EINVAL); } - lmask.__mask = frame.sf_sc.sc_mask; - lmask.__mask = frame.sf_extramask[0]; - linux_to_bsd_sigset(&lmask, &bmask); - kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); + kern_sigprocmask(td, SIG_SETMASK, &frame.sf_sigmask, NULL, 0); /* Restore signal context. */ regs->tf_rdi = frame.sf_sc.sc_edi; diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index b11a3ae136bf..14be8f7aa36b 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -474,7 +474,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) bzero(&frame, sizeof(frame)); frame.sf_sig = sig; - + frame.sf_sigmask = *mask; bsd_to_linux_sigset(mask, &lmask); /* Build the signal context to be used by sigreturn. */ @@ -500,8 +500,6 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) frame.sf_sc.sc_cr2 = (register_t)ksi->ksi_addr; frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(ksi->ksi_trapno); - frame.sf_extramask[0] = lmask.__mask; - if (copyout(&frame, fp, sizeof(frame)) != 0) { /* * Process has trashed its stack; give it an illegal @@ -540,8 +538,6 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args) { struct l_sigframe frame; struct trapframe *regs; - l_sigset_t lmask; - sigset_t bmask; int eflags; ksiginfo_t ksi; @@ -577,9 +573,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args) return (EINVAL); } - lmask.__mask = frame.sf_sc.sc_mask; - linux_to_bsd_sigset(&lmask, &bmask); - kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); + kern_sigprocmask(td, SIG_SETMASK, &frame.sf_sigmask, NULL, 0); /* Restore signal context. */ /* %gs was restored by the trampoline. */ diff --git a/sys/x86/linux/linux_x86_sigframe.h b/sys/x86/linux/linux_x86_sigframe.h index 56ff346ea5b7..75d9a104a345 100644 --- a/sys/x86/linux/linux_x86_sigframe.h +++ b/sys/x86/linux/linux_x86_sigframe.h @@ -116,7 +116,7 @@ struct l_sigframe { l_int sf_sig; struct l_sigcontext sf_sc; struct l_fpstate sf_fpstate; - l_uint sf_extramask[1]; + sigset_t sf_sigmask; }; struct l_rt_sigframe {