From: "Dmitry V. Levin" <ldv@strace.io>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Eugene Syromyatnikov <evgsyr@gmail.com>,
Mike Frysinger <vapier@gentoo.org>,
Renzo Davoli <renzo@cs.unibo.it>,
Davide Berardi <berardi.dav@gmail.com>,
strace-devel@lists.strace.io, linux-kernel@vger.kernel.org
Subject: [PATCH 4/6] ptrace_get_syscall_info: factor out ptrace_get_syscall_info_op
Date: Wed, 8 Jan 2025 01:04:47 +0200 [thread overview]
Message-ID: <20250107230446.GD30633@strace.io> (raw)
In-Reply-To: <20250107230153.GA30560@strace.io>
Move the code that calculates the type of the system call stop
out of ptrace_get_syscall_info() into a separate function
ptrace_get_syscall_info_op() which is going to be used later
to implement PTRACE_SET_SYSCALL_INFO API.
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
---
kernel/ptrace.c | 52 ++++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 20 deletions(-)
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d5f89f9ef29f..e7e0003cc8e0 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -965,19 +965,8 @@ ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
}
static int
-ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
- void __user *datavp)
+ptrace_get_syscall_info_op(struct task_struct *child)
{
- struct pt_regs *regs = task_pt_regs(child);
- struct ptrace_syscall_info info = {
- .op = PTRACE_SYSCALL_INFO_NONE,
- .arch = syscall_get_arch(child),
- .instruction_pointer = instruction_pointer(regs),
- .stack_pointer = user_stack_pointer(regs),
- };
- unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry);
- unsigned long write_size;
-
/*
* This does not need lock_task_sighand() to access
* child->last_siginfo because ptrace_freeze_traced()
@@ -988,18 +977,41 @@ ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
case SIGTRAP | 0x80:
switch (child->ptrace_message) {
case PTRACE_EVENTMSG_SYSCALL_ENTRY:
- actual_size = ptrace_get_syscall_info_entry(child, regs,
- &info);
- break;
+ return PTRACE_SYSCALL_INFO_ENTRY;
case PTRACE_EVENTMSG_SYSCALL_EXIT:
- actual_size = ptrace_get_syscall_info_exit(child, regs,
- &info);
- break;
+ return PTRACE_SYSCALL_INFO_EXIT;
}
break;
case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8):
- actual_size = ptrace_get_syscall_info_seccomp(child, regs,
- &info);
+ return PTRACE_SYSCALL_INFO_SECCOMP;
+ }
+
+ return PTRACE_SYSCALL_INFO_NONE;
+}
+
+static int
+ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
+ void __user *datavp)
+{
+ struct pt_regs *regs = task_pt_regs(child);
+ struct ptrace_syscall_info info = {
+ .op = ptrace_get_syscall_info_op(child),
+ .arch = syscall_get_arch(child),
+ .instruction_pointer = instruction_pointer(regs),
+ .stack_pointer = user_stack_pointer(regs),
+ };
+ unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry);
+ unsigned long write_size;
+
+ switch (info.op) {
+ case PTRACE_SYSCALL_INFO_ENTRY:
+ actual_size = ptrace_get_syscall_info_entry(child, regs, &info);
+ break;
+ case PTRACE_SYSCALL_INFO_EXIT:
+ actual_size = ptrace_get_syscall_info_exit(child, regs, &info);
+ break;
+ case PTRACE_SYSCALL_INFO_SECCOMP:
+ actual_size = ptrace_get_syscall_info_seccomp(child, regs, &info);
break;
}
--
ldv
next prev parent reply other threads:[~2025-01-07 23:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 23:01 [PATCH 0/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO API Dmitry V. Levin
2025-01-07 23:04 ` [PATCH 1/6] Revert "arch: remove unused function syscall_set_arguments()" Dmitry V. Levin
2025-01-07 23:04 ` [PATCH 2/6] syscall.h: add syscall_set_arguments() on remaining HAVE_ARCH_TRACEHOOK arches Dmitry V. Levin
2025-01-09 12:04 ` Oleg Nesterov
2025-01-09 12:11 ` Dmitry V. Levin
2025-01-07 23:04 ` [PATCH 3/6] syscall.h: introduce syscall_set_nr() Dmitry V. Levin
2025-01-10 7:37 ` Sven Schnelle
2025-01-11 1:16 ` Dmitry V. Levin
2025-01-07 23:04 ` Dmitry V. Levin [this message]
2025-01-09 10:09 ` [PATCH 4/6] ptrace_get_syscall_info: factor out ptrace_get_syscall_info_op Oleg Nesterov
2025-01-09 10:27 ` Dmitry V. Levin
2025-01-09 10:41 ` Oleg Nesterov
2025-01-09 11:14 ` Dmitry V. Levin
2025-01-07 23:04 ` [PATCH 5/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO request Dmitry V. Levin
2025-01-09 1:37 ` kernel test robot
2025-01-09 2:21 ` kernel test robot
2025-01-09 14:03 ` kernel test robot
2025-01-09 15:17 ` Eugene Syromiatnikov
2025-01-09 15:21 ` Oleg Nesterov
2025-01-11 11:49 ` Dmitry V. Levin
2025-01-07 23:05 ` [PATCH 6/6] selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO Dmitry V. Levin
2025-01-10 3:15 ` [PATCH 0/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO API H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250107230446.GD30633@strace.io \
--to=ldv@strace.io \
--cc=berardi.dav@gmail.com \
--cc=evgsyr@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=renzo@cs.unibo.it \
--cc=strace-devel@lists.strace.io \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox