From nobody Thu Apr 2 09:30:13 2026 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6801B35F19C for ; Fri, 20 Mar 2026 10:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774002327; cv=none; b=Z8MvQMMlf+qSY7TYD9U3+maHPS8FCb3N5YBr7SD5dUwpjIEmY6BX3jM/bg09X2k+g1COQP8DKfjW/QR7OyBDQ5tOU6Vi6LInz3ABMuaJel++yL8Cp0746YZpBASXdqxA7wWrcNAqSIho7u4Y94A3SgW8gfxSolmO9Mf5brbUmyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774002327; c=relaxed/simple; bh=kLf6M024Tco3oPkGs0WSSbt09t2XC4UHfpohgD8/YQ8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iPkG72VpyhTJ8nrCWWAW5BzBcaUeGl6uoTpkWnZhat78VN1A7xYJ9QfuI3Ls4jYYNi3VPFYUG6+uT7trMf+75MWbl/iK7rX87tDcEjLvpvm/gmQ86IKJUEEZGjAVIUHBu3qiQf6lEhUHNmN92hrudGQdX1RSLRTzrVcfvBTUIAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=BgOa3ZDS; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="BgOa3ZDS" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=AOc2fmMnHOmJWsKHkLeBB6cXdDIbogbdN1bTr0iEfBQ=; b=BgOa3ZDSj01JjfAZnmMOvhcT5iXcMEcV/IWU1ib4Bi4sikg3LMvt2V5xLe0DjR8QPbXkassn1 Ban90EYycnQFr1SI9X79kJy8+yf4EeGPUsyHmFkw336mPiSSm5d9IjdSp7p/1q7tPxnpseZdfzU e0142G+QwkoraPf9a3HDuzY= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fcdqT26rPzKm4D; Fri, 20 Mar 2026 18:20:21 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id B953440565; Fri, 20 Mar 2026 18:25:22 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 20 Mar 2026 18:25:21 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v14 02/10] arm64/ptrace: Use syscall_get_nr() helper for syscall_trace_enter() Date: Fri, 20 Mar 2026 18:26:12 +0800 Message-ID: <20260320102620.1336796-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260320102620.1336796-1-ruanjinjie@huawei.com> References: <20260320102620.1336796-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) Content-Type: text/plain; charset="utf-8" Use syscall_get_nr() to get syscall number for syscall_trace_enter(). This aligns arm64's internal tracing logic with the generic entry framework. [Changes] 1. Use syscall_get_nr() helper: - Replace direct regs->syscallno access with syscall_get_nr(current, regs). - This helper is functionally equivalent to direct access on arm64. 2. Re-read syscall number after tracepoint: - Re-fetch the syscall number after trace_sys_enter() as it may have been modified by BPF or ftrace probes, matching generic entry behavior. [Why this matters] - Aligns arm64 with the generic entry interface. - Makes future migration to generic entry framework. - Properly handles syscall number modifications by tracers. - Uses standard architecture-independent helpers. No functional changes intended. Cc: Will Deacon Cc: Catalin Marinas Reviewed-by: Linus Walleij Reviewed-by: Yeoreum Yun Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index e4d524ccbc7b..8d296a07fbf7 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2410,6 +2410,7 @@ static void report_syscall_exit(struct pt_regs *regs) =20 int syscall_trace_enter(struct pt_regs *regs, unsigned long flags) { + long syscall; int ret; =20 if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { @@ -2422,13 +2423,23 @@ int syscall_trace_enter(struct pt_regs *regs, unsig= ned long flags) if (secure_computing() =3D=3D -1) return NO_SYSCALL; =20 - if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) - trace_sys_enter(regs, regs->syscallno); + /* Either of the above might have changed the syscall number */ + syscall =3D syscall_get_nr(current, regs); =20 - audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1], + if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) { + trace_sys_enter(regs, syscall); + + /* + * Probes or BPF hooks in the tracepoint may have changed the + * system call number as well. + */ + syscall =3D syscall_get_nr(current, regs); + } + + audit_syscall_entry(syscall, regs->orig_x0, regs->regs[1], regs->regs[2], regs->regs[3]); =20 - return regs->syscallno; + return syscall; } =20 void syscall_trace_exit(struct pt_regs *regs, unsigned long flags) --=20 2.34.1