From nobody Mon May 30 17:04:27 2022 X-Original-To: dev-commits-src-main@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 6DD5D1B60DB7; Mon, 30 May 2022 17:04:28 +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 4LBhbJ0t1Sz4krd; Mon, 30 May 2022 17:04:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653930268; 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=8jgfvB5FI4GC5lS8KETda+3tf9Jb2nrcUKOQFLcNfO8=; b=lcceC1UcDOLpvGhHx/mwWu7J6CxpQp3xlI7x7tjK1rY/P1DhTfo8Mn7zd7RSX+QiX2CZTQ tGpczdHvfFceo7TO3fVZk1NhygVHwh1MvaHJHjXoKmI6gGHL4fbqwj+gpIp4lloXUZ4TEE 5lGjRbTcsjq3TlYEJLBGKHz7Koq/VWdg/DjaygLTwlCJv8IBkzlWE6sVFsHJsBITWp7Cff 4a787W9BrZ0hQ3yyhADIp4B/TiKbhg8yWc1k9QZySaHf1yvpxsklJTyISPH16FUTj5yOGT N4QP5Eix9sf0+SmU9mjxeNO9hDc0wsGwgIp8hY4TI106+Mj5L3dejkLIxvzOlA== 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 A526A1B33F; Mon, 30 May 2022 17:04:27 +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 24UH4Rgd068002; Mon, 30 May 2022 17:04:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24UH4RVH068001; Mon, 30 May 2022 17:04:27 GMT (envelope-from git) Date: Mon, 30 May 2022 17:04:27 GMT Message-Id: <202205301704.24UH4RVH068001@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 4a6c2d075da0 - main - linux(4): Properly restore the thread signal mask after signal delivery on i386 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 4a6c2d075da0c5105269e6edcbe57bf6aaa0a0ae Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653930268; 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=8jgfvB5FI4GC5lS8KETda+3tf9Jb2nrcUKOQFLcNfO8=; b=HhYQhwllFoNqsSx6EGoY5HW00sxFcVfAkE5tHL6HPqDICT9JrGrIfWWDc8G+8d3sCDlk2y XdoVF1xOgDeozaU/IhVo+r086SaX1ysjCkJviHlVqHTCBpt7Y9FM3SYXg40K/bZUcPe+aC q3IH0+cTLu9SSl5/zCQLiRcDyL/TKoRIuKe+ryKciZQuRSSxOa9Nfg86o4r4Ez0uGMRcO3 OfAh85xPd/x+EdT8LUs03+YcrxUxnTSDH9nz4Vchkpf76Fl1oIAt/jb5YO8eXk2d1jK9mn NsuBMKVPWAFSGbjmPATZ5HWKGf4TOl1RmygukSTf+koTEuns+khr3ALCsx3w/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653930268; a=rsa-sha256; cv=none; b=eNMjJsGh9VVS6kTz49Po2twh70KosUDFSYMtCFk4eHz6MBj2Ukt60GPrFzXPlCaPt36YGN 78uBrw1vZUCAoMPgKDbae5GVqVuXNvjuQ+r3ClGdRYbxZ5YwiFja35rc7ChHvL+98ktoH8 hzjgalrw601JNKr0fGBHsNpkZeoigTbQKvHlIExKfntyTCGjU3mqCAbQ7Mbzg38d9KrIV6 ImQufPIfsAnXn/VW+UOOtWRqDhNSYUAhQ2lQw6w9r1DTlo4tuAZQFtqIWVjZGbQYDJBYSi pFHNQb5S1ogV78jIDT2mlWvX/A8QAc5dh4PKuj3JxAtlNKNHCLyruC7aedvKqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=4a6c2d075da0c5105269e6edcbe57bf6aaa0a0ae commit 4a6c2d075da0c5105269e6edcbe57bf6aaa0a0ae Author: Dmitry Chagin AuthorDate: 2022-05-30 17:03:49 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-30 17:03:49 +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 --- 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 ff16822a352b..e9162f04d3f7 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 12f02ca22cb4..269ab3b7ab75 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 {