Re: [PATCH 4/6] ptrace_get_syscall_info: factor out ptrace_get_syscall_info_op

From: Oleg Nesterov
Date: Thu Jan 09 2025 - 05:10:31 EST


On 01/08, Dmitry V. Levin wrote:
>
> +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;

OK... but unless I misread this patch, all 3 ptrace_get_syscall_info_xxx()
helpers will do the pointless info->op = PTRACE_SYSCALL_INFO_XXX ?

Oleg.