From nobody Sun Feb 8 11:43:20 2026 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DC5E1F6666 for ; Tue, 7 Jan 2025 23:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736291089; cv=none; b=olUaLKHGHAHWK8NGlG9BkARfF6g7dYgA1kM8d+lgt6T4AFUM/74xqSPf5oI3WwVNC4KrlUdfjJiA504plZXu0sYdxOutTqoJKysv3/0zGQg26MDYSYX1gqCgPM96L4ZqOzMS5n662TvSK0QI8BylTC73dzWtLoMv0HBOF4h4rxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736291089; c=relaxed/simple; bh=jbWjQs7WFDFLX5S67TEhVGEaXXHOyDQMVLMCMhuP3aE=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=sJ9q9e0cLdMxzO1VxlNI3sqCPHYJ8zoNb3nhvbZtC7vlYG+FcpJ6KNmJexfcUEbxSZlb1WpuEF4WFLYLvhE29CIzepntQcaPYu9nd5Yr0ipEi4Phq4H+KJYQK2SXWZ9t3jRMNWLKcuNHi+Ll3hvc6XvuLY0CfQbiN4doCaeqDCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 3343B72C97D; Wed, 8 Jan 2025 02:04:47 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 286C57CCB3A; Wed, 8 Jan 2025 01:04:47 +0200 (IST) Date: Wed, 8 Jan 2025 01:04:47 +0200 From: "Dmitry V. Levin" To: Oleg Nesterov Cc: Eugene Syromyatnikov , Mike Frysinger , Renzo Davoli , Davide Berardi , 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 Message-ID: <20250107230446.GD30633@strace.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250107230153.GA30560@strace.io> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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, } =20 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 =3D task_pt_regs(child); - struct ptrace_syscall_info info =3D { - .op =3D PTRACE_SYSCALL_INFO_NONE, - .arch =3D syscall_get_arch(child), - .instruction_pointer =3D instruction_pointer(regs), - .stack_pointer =3D user_stack_pointer(regs), - }; - unsigned long actual_size =3D 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, un= signed long user_size, case SIGTRAP | 0x80: switch (child->ptrace_message) { case PTRACE_EVENTMSG_SYSCALL_ENTRY: - actual_size =3D ptrace_get_syscall_info_entry(child, regs, - &info); - break; + return PTRACE_SYSCALL_INFO_ENTRY; case PTRACE_EVENTMSG_SYSCALL_EXIT: - actual_size =3D ptrace_get_syscall_info_exit(child, regs, - &info); - break; + return PTRACE_SYSCALL_INFO_EXIT; } break; case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8): - actual_size =3D 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 =3D task_pt_regs(child); + struct ptrace_syscall_info info =3D { + .op =3D ptrace_get_syscall_info_op(child), + .arch =3D syscall_get_arch(child), + .instruction_pointer =3D instruction_pointer(regs), + .stack_pointer =3D user_stack_pointer(regs), + }; + unsigned long actual_size =3D offsetof(struct ptrace_syscall_info, entry); + unsigned long write_size; + + switch (info.op) { + case PTRACE_SYSCALL_INFO_ENTRY: + actual_size =3D ptrace_get_syscall_info_entry(child, regs, &info); + break; + case PTRACE_SYSCALL_INFO_EXIT: + actual_size =3D ptrace_get_syscall_info_exit(child, regs, &info); + break; + case PTRACE_SYSCALL_INFO_SECCOMP: + actual_size =3D ptrace_get_syscall_info_seccomp(child, regs, &info); break; } =20 --=20 ldv