From nobody Thu Dec 22 23:53:58 2022 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 4NdRwk5P3kz1H3n3; Thu, 22 Dec 2022 23:53:58 +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 4NdRwk4zLDz42pB; Thu, 22 Dec 2022 23:53:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671753238; 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=QWfYIE7jzMLLiSp1Y6bImxcm/+ShpKFeM8WQ6RHXQds=; b=cApy7HhOW1/rn11BJzOXHVPOljvHQKfdzc4q+rvh7HyQN8+3JSlY1mDCQaVX4nRRXOGdFc +mQUGnJ9lrh1IrEsTs64Fz4CWzQ+QApdra6V9Ng7tSB7V82hjFjnro1QW3dgJkfCtp0YFI 5SLPuIrAkjOgFU/62zzqQ+XzqW2gfWN8ljvSBWB0/LYC8OgZvkC69yTgugCRnpsSFapH5y KuVwfRqeZDfNFotOk0tKjV5j+c8asFc7YQ02ViMdGn/eQtDxyP6VLXCzAS/oofH5l0OmdV OQ++88vX61zhG7yXlYNLhXOtHHcHyW+TaZoEvr/GptInwYgOcR0GO/OsAMeanw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1671753238; 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=QWfYIE7jzMLLiSp1Y6bImxcm/+ShpKFeM8WQ6RHXQds=; b=rP0chTSx1spSMb1LM7yFTyU8jNDmaUdy85yYfuRj4qpILJr7krOlRbKd8v5sv3nYqo3oJ+ kCOd25hJNIM9R4N8a5ZNaJwHQYS1WQvArOkuHYx37Q9Z+wfsSfXV7y8JmHAW/VX9EZQftZ 2SnrVHff9jcwdrq+VdQ/MB34GNgXJaPEkuErX9N3t1tsEoQ3BKbJQgT7gzgyZMaw3Q7BfA eujspcdSBBde6NqRmyeWVcwqXObVC66P4Fr8rDrw0rBuQ6Jx0h9BwTulPuGU3TEaQ0+egC l/4SWzCEqAHPV7391CPkqCpUezoAEO083umpc7hrXGRq2eeCkuk2QEE27JFTXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1671753238; a=rsa-sha256; cv=none; b=r9Ov/T+I1EDpgHG0YSNphsvQwdvLTJNJSeX2ct8qFh8ycXgjiBdXDAg6P6rL5Z+Q8ifMQ9 kGaURRiYd1S6K3+ngMfRyHG9CYiiHrqBA+UOcMpd7kpZ272NTQKeWXxFFLKaH1HiT0tO10 oP0h2pTn1JqWEWul8Iu3ydS7BAhav0e9rcXDIGdHT94Y5La+Uxn4iuMHOLiBKGsCX2Dcu4 yk1F6kYJUqkAn3imfJnVdDbxpph8kdJCAr6Zk07jiEB0R6EMe+41hh6I0WeYj67kTbceuz dqtepK1BQWqLfcgVtQgrHi9aS+uJfYxoKYQwUjaLeahqZ78rJHcYMlB5AHmGPg== 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 4NdRwk43sLz1Cqg; Thu, 22 Dec 2022 23:53:58 +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 2BMNrwru083332; Thu, 22 Dec 2022 23:53:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BMNrwhn083331; Thu, 22 Dec 2022 23:53:58 GMT (envelope-from git) Date: Thu, 22 Dec 2022 23:53:58 GMT Message-Id: <202212222353.2BMNrwhn083331@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: 974be51b3f60 - main - Fixes for ptrace_syscallreq() 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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: 974be51b3f6070f9aae02e115ea6099f90bc9175 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=974be51b3f6070f9aae02e115ea6099f90bc9175 commit 974be51b3f6070f9aae02e115ea6099f90bc9175 Author: Konstantin Belousov AuthorDate: 2022-12-22 23:51:34 +0000 Commit: Konstantin Belousov CommitDate: 2022-12-22 23:53:41 +0000 Fixes for ptrace_syscallreq() Re-assign the sc local (syscall number) before moving args for SYS_syscall. Correct the audit and kdtrace hooks invocations. Fixes: 140ceb5d956bb8795a77c23d3fd5ef047b0f3c68 Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/kern_sig.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index df40cdf404db..e0ef60d0ca20 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2672,6 +2672,7 @@ ptrace_syscallreq(struct thread *td, struct proc *p, sc = tsr->ts_sa.code; if (sc == SYS_syscall || sc == SYS___syscall) { + sc = tsr->ts_sa.args[0]; memmove(&tsr->ts_sa.args[0], &tsr->ts_sa.args[1], sizeof(register_t) * (tsr->ts_nargs - 1)); } @@ -2692,7 +2693,7 @@ ptrace_syscallreq(struct thread *td, struct proc *p, #endif sy_thr_static = (se->sy_thrcnt & SY_THR_STATIC) != 0; - audited = AUDIT_SYSCALL_ENTER(tsr->ts_syscall, td) != 0; + audited = AUDIT_SYSCALL_ENTER(sc, td) != 0; if (!sy_thr_static) { error = syscall_thread_enter(td, se); @@ -2716,7 +2717,7 @@ ptrace_syscallreq(struct thread *td, struct proc *p, #ifdef KDTRACE_HOOKS if (se->sy_return != 0) (*systrace_probe_func)(&tsr->ts_sa, SYSTRACE_RETURN, - tsr->ts_ret->sr_error != 0 ? -1 : td->td_retval[0]); + tsr->ts_ret.sr_error != 0 ? -1 : td->td_retval[0]); #endif tsr->ts_ret.sr_retval[0] = td->td_retval[0];