From nobody Mon Feb 21 13:48:47 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 0F321183992A; Mon, 21 Feb 2022 13:48:48 +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 4K2Ntl4y6cz3PqR; Mon, 21 Feb 2022 13:48:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645451327; 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=mjlKr4KqeZhiuzDbIr/WNQssfOhEkuYwEDMNTbJuIlM=; b=RKftzue4IT8GelR50WADvSk1/LEN5Ju5HfSIkn95jcv1xmpbiuDtEhco8GfcHTD357+ONS otV2wkKo+Fe8ViRjhLCyuJZzdTl2ulUERvl7DmNyXz60v/Ukl3H++SAyZ4B8kdKqCcUQ9F BB88N1rRfMi3VZS+NAOI/XSi8uhxqcX1Ng3RztmJofS+kLyK776GjVD3tXfau4zPXuN/oU mjJ3/PUDu5b3tpXGRzJr6fO3vC4+SO9KyPbygplMSw3B0pOxKg3vSPVPfrVa4dCSf/yS0L q2fyvmnC8yl2/wzfMdFfnGFNdlmtFXpTRObO2s121gQb+OuyLQTm9e3RpROiIg== 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 7A776111C4; Mon, 21 Feb 2022 13:48:47 +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 21LDmlmb091748; Mon, 21 Feb 2022 13:48:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21LDmlGi091747; Mon, 21 Feb 2022 13:48:47 GMT (envelope-from git) Date: Mon, 21 Feb 2022 13:48:47 GMT Message-Id: <202202211348.21LDmlGi091747@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Edward Tomasz Napierala Subject: git: 1f948bb41f7e - stable/13 - linux(4): fix ptrace(2) to properly handle orig_rax 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: trasz X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f948bb41f7e98f3780a9ad696cb598f015823d1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645451327; 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=mjlKr4KqeZhiuzDbIr/WNQssfOhEkuYwEDMNTbJuIlM=; b=LuDGfOBpsi3R8l1ASkJRSsEmUXCenDozDFzATrOUhO/FFYMKmK7bYjQw7TfoKl6ItHwmtZ 4qGN7n+QLEnbojN0mTbuIilOpZur/RaQ1UEaA3fK2aqEoULcXAZRs7nFkuuqlSgKpr1O92 T+fp7hyTo/Lus/Ml2FLX9x3IEfC9RrypTB8qp3fw58EJY/Ht2HOcsdi8N2BvcbAFkiq9Jq EE6LLssnoUVg10v7YWF5PDLhuAWHiKVblf8iX5fBkBvZQl1STOahYYWQB9psc/ZNrS4XWt dQ3EJNqP7Q50ac2bQLuCqJ3A/DmlWUqunrMOlIHV1Mp1zxDyE/Sj8ixshkWQHA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645451327; a=rsa-sha256; cv=none; b=TP8exe2yu3ILzQ5YWEPhS/XHihUVbsr+NggfsgslZ8ANUsK6sZus9pZUfbWG9b6LXXIw5C 0Qnp/VJH9Hlpa2wUW1jdMUXcypSnMoJVyf/YVIJbzBKQFvcisGQyyCej/kcVy0Vcq93Q/X e8fv9hWtoYMOER2CqVtraVNynYJuu+QO7+aUEskSkjtfRqRv0sbA53A89e1UCDU86PpN+J htu8wStr6MoY+/LFQFc6HliDLB3q/7FQiH2ea21oV04ZqZGMKm51WzPU3oqa7vswv9U11K pcdRVeC//Jg5FxsYOWJzIUnf5KOjvrwDNHCN/9LgR4VHv9arLN7i6Bzx4W2SIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=1f948bb41f7e98f3780a9ad696cb598f015823d1 commit 1f948bb41f7e98f3780a9ad696cb598f015823d1 Author: Edward Tomasz Napierala AuthorDate: 2021-05-04 13:11:01 +0000 Commit: Edward Tomasz Napierala CommitDate: 2022-02-21 12:43:37 +0000 linux(4): fix ptrace(2) to properly handle orig_rax This fixes strace(1) erroneously reporting return values as "Function not implemented", combined with reporting the binary ABI as X32. Very similar code in linux_ptrace_getregs() is left as it is - it's probably wrong too, but I don't have a way to test it. Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D29927 (cherry picked from commit 023bff799098cac28732f2800c967f0248d2eb47) --- sys/amd64/linux/linux_ptrace.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/amd64/linux/linux_ptrace.c b/sys/amd64/linux/linux_ptrace.c index e158059ec423..4557cea0502e 100644 --- a/sys/amd64/linux/linux_ptrace.c +++ b/sys/amd64/linux/linux_ptrace.c @@ -505,18 +505,18 @@ linux_ptrace_getregset_prstatus(struct thread *td, pid_t pid, l_ulong data) } if (lwpinfo.pl_flags & PL_FLAG_SCE) { /* - * The strace(1) utility depends on RAX being set to -ENOSYS - * on syscall entry; otherwise it loops printing those: - * - * [ Process PID=928 runs in 64 bit mode. ] - * [ Process PID=928 runs in x32 mode. ] + * Undo the mangling done in exception.S:fast_syscall_common(). */ - l_regset.rax = -38; /* -ENOSYS */ + l_regset.r10 = l_regset.rcx; + } + if (lwpinfo.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)) { /* - * Undo the mangling done in exception.S:fast_syscall_common(). + * In Linux, the syscall number - passed to the syscall + * as rax - is preserved in orig_rax; rax gets overwritten + * with syscall return value. */ - l_regset.r10 = l_regset.rcx; + l_regset.orig_rax = lwpinfo.pl_syscall_code; } len = MIN(iov.iov_len, sizeof(l_regset));