[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241029-arm-generic-entry-v2-2-573519abef38@linaro.org>
Date: Tue, 29 Oct 2024 11:52:42 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Oleg Nesterov <oleg@...hat.com>, Russell King <linux@...linux.org.uk>,
Kees Cook <kees@...nel.org>, Andy Lutomirski <luto@...capital.net>,
Will Drewry <wad@...omium.org>, Frederic Weisbecker <frederic@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Jinjie Ruan <ruanjinjie@...wei.com>, Arnd Bergmann <arnd@...db.de>,
Ard Biesheuvel <ardb@...nel.org>, Al Viro <viro@...iv.linux.org.uk>
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH RFC v2 02/28] ARM: ptrace: Split report_syscall()
The generic entry code requires that report_syscall() be provided
in two parts: report_syscall_enter() and report_syscall_exit()
so split the combined function in two.
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
arch/arm/kernel/ptrace.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index c421a899fc84..07b0daf47441 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -827,31 +827,45 @@ enum ptrace_syscall_dir {
PTRACE_SYSCALL_EXIT,
};
-static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir)
+static void report_syscall_enter(struct pt_regs *regs)
{
unsigned long ip;
/*
* IP is used to denote syscall entry/exit:
- * IP = 0 -> entry, =1 -> exit
+ * IP = 0 -> entry
*/
ip = regs->ARM_ip;
- regs->ARM_ip = dir;
+ regs->ARM_ip = PTRACE_SYSCALL_ENTER;
- if (dir == PTRACE_SYSCALL_EXIT)
- ptrace_report_syscall_exit(regs, 0);
- else if (ptrace_report_syscall_entry(regs))
+ if (ptrace_report_syscall_entry(regs))
current_thread_info()->abi_syscall = -1;
regs->ARM_ip = ip;
}
+static void report_syscall_exit(struct pt_regs *regs)
+{
+ unsigned long ip;
+
+ /*
+ * IP is used to denote syscall entry/exit:
+ * IP = 1 -> exit
+ */
+ ip = regs->ARM_ip;
+ regs->ARM_ip = PTRACE_SYSCALL_EXIT;
+
+ ptrace_report_syscall_exit(regs, 0);
+
+ regs->ARM_ip = ip;
+}
+
asmlinkage int syscall_trace_enter(struct pt_regs *regs)
{
int scno;
if (test_thread_flag(TIF_SYSCALL_TRACE))
- report_syscall(regs, PTRACE_SYSCALL_ENTER);
+ report_syscall_enter(regs);
/* Do seccomp after ptrace; syscall may have changed. */
#ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
@@ -892,5 +906,5 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
trace_sys_exit(regs, regs_return_value(regs));
if (test_thread_flag(TIF_SYSCALL_TRACE))
- report_syscall(regs, PTRACE_SYSCALL_EXIT);
+ report_syscall_exit(regs);
}
--
2.46.2
Powered by blists - more mailing lists