From nobody Mon May 30 17:04:20 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 9C31F1B6072E; Mon, 30 May 2022 17:04:21 +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 4LBhb91dzyz4kjG; Mon, 30 May 2022 17:04:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653930261; 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=KjJtjEtiShdbapNld+tIaNu0u+IQH8t3RdSVLke0OmU=; b=NiWNIScQWUrnYrp+q4rhfRxcLB4BElnTzIwDDBm7w9YFE79b1LWjLSjUFH6ZXa0SdaKJKA DuOlrRlXu1621nZYjePyVgFjoFkZgYO58Z+wLaakgoSxbY89ssvO4TCFyDFfChY0Cymx7x DzhiQMnhmtB9lIafJbGmwWKP5/Y8j5ZSgKNbWN81eykMbq4cZETNczWr3kw80Zoh3deA9C dMXvqehWwEE0soGtClpSVL0vF1S/C4edD7GtoXFeAgdcOKwxeb3Fthd8TXQ2IuQ0VYAPZ1 DbGBY4PJiuU/BhF0X/PdkPqjuBJQpd2cw+0Vh34Yukn75EGuu7Z4oUHC3gU30g== 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 E22CB1B429; Mon, 30 May 2022 17:04:20 +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 24UH4KSV067852; Mon, 30 May 2022 17:04:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24UH4KqR067851; Mon, 30 May 2022 17:04:20 GMT (envelope-from git) Date: Mon, 30 May 2022 17:04:20 GMT Message-Id: <202205301704.24UH4KqR067851@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: 109fd18ad969 - main - linux(4): Properly build argument list for the signal handler 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: 109fd18ad96957c25cfaa78da2f825c729e33fef Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653930261; 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=KjJtjEtiShdbapNld+tIaNu0u+IQH8t3RdSVLke0OmU=; b=EwCRq04YtPa2Qc8GaiM/B3DYTiqfdYvk00nfXX13VebrWCWAPfd9Q/ODU13EApbwvN4A21 HK5VxDtPXhYEUCtw6vZq3y4UqR3B2r0mwCmYItAiOgtxd4nIeal9C91RZaLMMZ8cDjUWyN WGbdlWoP4nvyXJOhiNXthPRasv4Det66rwZV3U0EREq03SpBXlme1MFf+ZS23dpK0NEObL m79lmVQ3H3YDQD0odqjbErlmoml+4KFs+jOc97hX9llQSDJtEq6/0Te72G+Zv1qEEeRJ4W bsgiF56AMVfWb9U3MRfWXlZ4mLKU85PqQzbEGLERAls2PaocDVS0kRk7CZIr5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653930261; a=rsa-sha256; cv=none; b=Cv7aRDS73RXJu7Pry6vCj2Ke+rBASL1SJeUrm/dkMGVF6X1bFTlHA5ZyFZ8OSjf4yrHhY8 cGGFR9NxHu9thv24YBjSsc9kq2ZnR/1XHKyBTJ1YZEsdB0EX6WvmoJgjHM+/8yO3qAQn8X x2EeWso6ygPvlA55XcDXVfbMxMrv3jqfhOZVupoh+X3sjpUtU4hBesjK0VV3hTmYjDa+/B U3kWTvr/DCHTay9dbAYmxBSLk8ZxZUwgpJb5glnIN1/Fw85geuMh+B91OYxJG6Z4KEpLhk A2JDPEut0ZwTfOe9T6bkc9MZBnkjDmqBCNbBkSebe9w2hIM8yxsJHWa8Do587g== 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=109fd18ad96957c25cfaa78da2f825c729e33fef commit 109fd18ad96957c25cfaa78da2f825c729e33fef Author: Dmitry Chagin AuthorDate: 2022-05-30 16:53:12 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-30 16:53:12 +0000 linux(4): Properly build argument list for the signal handler Provide arguments 2 and 3 if signal handler installed with SA_SIGINFO. MFC after: 2 weeks --- sys/amd64/linux/linux_sysvec.c | 28 ++++++++++++++++------------ sys/arm64/linux/linux_sysvec.c | 12 +++++++++--- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index 4cd41b364b95..25fc8b10e903 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -558,13 +558,14 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) caddr_t sp; struct trapframe *regs; int sig, code; - int oonstack; + int oonstack, issiginfo; td = curthread; p = td->td_proc; PROC_LOCK_ASSERT(p, MA_OWNED); sig = linux_translate_traps(ksi->ksi_signo, ksi->ksi_trapno); psp = p->p_sigacts; + issiginfo = SIGISMEMBER(psp->ps_siginfo, sig); code = ksi->ksi_code; mtx_assert(&psp->ps_mtx, MA_OWNED); regs = td->td_frame; @@ -616,22 +617,14 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) /* Align to 16 bytes. */ sfp = (struct l_rt_sigframe *)((unsigned long)sp & ~0xFul); + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + /* Translate the signal. */ sig = bsd_to_linux_signal(sig); - - /* Build the argument list for the signal handler. */ - regs->tf_rdi = sig; /* arg 1 in %rdi */ - regs->tf_rax = 0; - regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */ - regs->tf_rdx = (register_t)&sfp->sf_uc; /* arg 3 in %rdx */ - regs->tf_rcx = (register_t)catcher; - /* Fill in POSIX parts. */ siginfo_to_lsiginfo(&ksi->ksi_info, &sf.sf_si, sig); - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(p); - /* Copy the sigframe out to the user's stack. */ if (copyout(&sf, sfp, sizeof(*sfp)) != 0) { uprintf("pid %d comm %s has trashed its stack, killing\n", @@ -640,6 +633,17 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) sigexit(td, SIGILL); } + /* Build the argument list for the signal handler. */ + regs->tf_rdi = sig; /* arg 1 in %rdi */ + regs->tf_rax = 0; + if (issiginfo) { + regs->tf_rsi = (register_t)&sfp->sf_si; /* arg 2 in %rsi */ + regs->tf_rdx = (register_t)&sfp->sf_uc; /* arg 3 in %rdx */ + } else { + regs->tf_rsi = 0; + regs->tf_rdx = 0; + } + regs->tf_rcx = (register_t)catcher; regs->tf_rsp = (long)sfp; regs->tf_rip = linux_rt_sigcode; regs->tf_rflags &= ~(PSL_T | PSL_D); diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c index 72465285dfed..732eddf0c308 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -430,7 +430,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) ucontext_t uc; uint8_t *scr; struct sigacts *psp; - int onstack, sig; + int onstack, sig, issiginfo; td = curthread; p = td->td_proc; @@ -442,6 +442,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) tf = td->td_frame; onstack = sigonstack(tf->tf_sp); + issiginfo = SIGISMEMBER(psp->ps_siginfo, sig); CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, catcher, sig); @@ -528,8 +529,13 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) free(frame, M_LINUX); tf->tf_x[0]= sig; - tf->tf_x[1] = (register_t)&fp->sf.sf_si; - tf->tf_x[2] = (register_t)&fp->sf.sf_uc; + if (issiginfo) { + tf->tf_x[1] = (register_t)&fp->sf.sf_si; + tf->tf_x[2] = (register_t)&fp->sf.sf_uc; + } else { + tf->tf_x[1] = 0; + tf->tf_x[2] = 0; + } tf->tf_x[8] = (register_t)catcher; tf->tf_sp = (register_t)fp; tf->tf_elr = (register_t)linux_vdso_sigcode;