From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66E6DC624D0 for ; Wed, 2 Sep 2026 09:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uaX39/CE0Q5UxvlotHbRwxFXgD9FMOYuW98v5zboCb0=; b=cWxgE6RHqZ9z2al54pbREqgrUU jGM8FirPONmdHSS4WU8sDo7r66W7xVWNavFHHBlGECdzixsmyZGEClw5bsmK8s2S8rnCZgSu9Gprs KYF5SCKseMzDOtTwctpbErHsJT2FqPontqrBkm7QA7dks8A3h/vkAlyrRASXCJEbNszGDXu+aTTTn Q3bhINdf6KS7+VRKWKP+ebyTjni1svfilcRomTNQZ1NLSd0q9s6whQwDYx2TLLhx3x0Uq3P/PN6Ts X1IY8D3WD9DeWI0qV11R7+316RTXXc3Mnt49P9j3c/NURDkRKj1iLZ0tb4LVL0jBVXmR6HSI/pIAh mFnw3BvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1hgT-0000000EHAH-2I8P; Wed, 02 Sep 2026 09:55:09 +0000 Received: from canpmsgout01.his.huawei.com ([113.46.200.216]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1hgO-0000000EH5B-43rC for linux-arm-kernel@lists.infradead.org; Wed, 02 Sep 2026 09:55:07 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=uaX39/CE0Q5UxvlotHbRwxFXgD9FMOYuW98v5zboCb0=; b=xcHNuANSzX9n+igcAqjiUBDz1CrooEDLf+EJ7mbDAmiiGQ72Hlu+8cgu2yV5hPOWJczpEr6Yg coYmblX4RpoQS8AQQhSLPuiwf+g3lEgKZTIB4kNXSvsLepWCqmuOYmP2hw0b1kf6WuGJT0Tkcof AW0LX0rr1BrhLwm/vJEU60s= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4hZd8S4L0dz1T4gl; Wed, 2 Sep 2026 17:43:36 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 357154058E; Wed, 2 Sep 2026 17:54:58 +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; Wed, 2 Sep 2026 17:54:56 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v18 02/14] arm64: ptrace: Rework audit_syscall_entry() Date: Wed, 2 Sep 2026 17:55:25 +0800 Message-ID: <20260902095537.602517-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260902095537.602517-1-ruanjinjie@huawei.com> References: <20260902095537.602517-1-ruanjinjie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To dggpemf500011.china.huawei.com (7.185.36.131) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260902_025505_326620_F31200A4 X-CRM114-Status: GOOD ( 10.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Extract syscall_enter_audit() helper and switch to generic helpers to get syscall number and syscall arguments, matching the generic entry implementation. The new code: - Checks audit_context() first to avoid unnecessary work when audit is not active. - Use syscall_get_arguments() helper instead of directly accessing regs fields. - Use syscall_get_nr() helper to get syscall number instead of directly accessing regs->syscallno. - Now exactly equivalent to generic entry's syscall_enter_audit(). This is a preparation step for converting arm64 to the generic entry infrastructure. No functional changes intended. Cc: Mark Rutland Cc: Will Deacon Cc: Catalin Marinas Reviewed-by: Ada Couprie Diaz Reviewed-by: Linus Walleij Reviewed-by: Yeoreum Yun Reviewed-by: Kevin Brodsky Signed-off-by: Jinjie Ruan --- arch/arm64/kernel/ptrace.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 96462de75d4b..ede6f3bf29e0 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -2458,6 +2458,17 @@ static void report_syscall_exit(struct pt_regs *regs) } } +#ifdef CONFIG_AUDITSYSCALL +static inline void syscall_enter_audit(struct pt_regs *regs) +{ + long syscall = syscall_get_nr(current, regs); + unsigned long args[6]; + + syscall_get_arguments(current, regs, args); + __audit_syscall_entry(syscall, args[0], args[1], args[2], args[3]); +} +#endif + int syscall_trace_enter(struct pt_regs *regs) { unsigned long flags = read_thread_flags(); @@ -2476,8 +2487,8 @@ int syscall_trace_enter(struct pt_regs *regs) if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) trace_sys_enter(regs, regs->syscallno); - audit_syscall_entry(regs->syscallno, regs->orig_x0, regs->regs[1], - regs->regs[2], regs->regs[3]); + if (unlikely(audit_context())) + syscall_enter_audit(regs); return regs->syscallno; } -- 2.34.1