Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Kevin Brodsky <kevin.brodsky@arm.com>
To: Jinjie Ruan <ruanjinjie@huawei.com>,
	catalin.marinas@arm.com, will@kernel.org, oleg@redhat.com,
	tglx@linutronix.de, peterz@infradead.org, luto@kernel.org,
	shuah@kernel.org, kees@kernel.org, wad@chromium.org,
	charlie@rivosinc.com, akpm@linux-foundation.org, ldv@strace.io,
	macro@orcam.me.uk, deller@gmx.de, mark.rutland@arm.com,
	efault@gmx.de, song@kernel.org, mbenes@suse.cz,
	ryan.roberts@arm.com, ada.coupriediaz@arm.com,
	anshuman.khandual@arm.com, broonie@kernel.org,
	pengcan@kylinos.cn, dvyukov@google.com, kmal@cock.li,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v8 06/12] arm64/ptrace: Return early for ptrace_report_syscall_entry() error
Date: Thu, 27 Nov 2025 14:29:28 +0100	[thread overview]
Message-ID: <2cc2b342-d350-415d-bc5a-05aa3da17d50@arm.com> (raw)
In-Reply-To: <20251126071446.3234218-7-ruanjinjie@huawei.com>

On 26/11/2025 08:14, Jinjie Ruan wrote:
> The generic entry abort the syscall_trace_enter() sequence if
> ptrace_report_syscall_entry() errors out, but arm64 not.
>
> As the ptrace_report_syscall_entry() comment said, the calling arch code
> should abort the system call and must prevent normal entry so no system
> call is made if ptrace_report_syscall_entry() return nonzero.

Which is already the case on arm64 before patch 2, which changes
syscall_trace_enter() so that it no longer returns regs->syscallno,
meaning that forget_syscall() no longer skips the syscall.

The most sensible thing to do is probably to move this patch before
patch 2. This ensures patch 2 doesn't introduce a regression, and then
the only effect of this patch is to abort the trace sequence early.

- Kevin

> In preparation for moving arm64 over to the generic entry code,
> return early if ptrace_report_syscall_entry() encounters an error.
>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  arch/arm64/kernel/ptrace.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index 233a7688ac94..da9687d30bcf 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -2346,15 +2346,18 @@ static inline unsigned long ptrace_save_reg(struct pt_regs *regs,
>  	return saved_reg;
>  }
>  
> -static void report_syscall_entry(struct pt_regs *regs)
> +static int report_syscall_entry(struct pt_regs *regs)
>  {
>  	unsigned long saved_reg;
> -	int regno;
> +	int regno, ret;
>  
>  	saved_reg = ptrace_save_reg(regs, PTRACE_SYSCALL_ENTER, &regno);
> -	if (ptrace_report_syscall_entry(regs))
> +	ret = ptrace_report_syscall_entry(regs);
> +	if (ret)
>  		forget_syscall(regs);
>  	regs->regs[regno] = saved_reg;
> +
> +	return ret;
>  }
>  
>  static void report_syscall_exit(struct pt_regs *regs)
> @@ -2380,9 +2383,11 @@ static void report_syscall_exit(struct pt_regs *regs)
>  
>  int syscall_trace_enter(struct pt_regs *regs, long syscall, unsigned long flags)
>  {
> +	int ret;
> +
>  	if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
> -		report_syscall_entry(regs);
> -		if (flags & _TIF_SYSCALL_EMU)
> +		ret = report_syscall_entry(regs);
> +		if (ret || (flags & _TIF_SYSCALL_EMU))
>  			return NO_SYSCALL;
>  	}
>  

  reply	other threads:[~2025-11-27 13:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26  7:14 [PATCH v8 00/12] arm64: entry: Convert to Generic Entry Jinjie Ruan
2025-11-26  7:14 ` [PATCH v8 01/12] arm64: Remove unused _TIF_WORK_MASK Jinjie Ruan
2025-11-27 13:27   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 02/12] arm64/ptrace: Split report_syscall() Jinjie Ruan
2025-11-27 13:28   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 03/12] arm64/ptrace: Refactor syscall_trace_enter/exit() Jinjie Ruan
2025-11-27 13:28   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 04/12] arm64: ptrace: Move rseq_syscall() before audit_syscall_exit() Jinjie Ruan
2025-11-27 13:28   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 05/12] arm64: syscall: Rework el0_svc_common() Jinjie Ruan
2025-11-27 13:29   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 06/12] arm64/ptrace: Return early for ptrace_report_syscall_entry() error Jinjie Ruan
2025-11-27 13:29   ` Kevin Brodsky [this message]
2025-11-26  7:14 ` [PATCH v8 07/12] arm64/ptrace: Expand secure_computing() in place Jinjie Ruan
2025-11-27 13:29   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 08/12] arm64/ptrace: Use syscall_get_arguments() heleper Jinjie Ruan
2025-11-27 13:30   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 09/12] entry: Split syscall_exit_to_user_mode_work() for arch reuse Jinjie Ruan
2025-11-26  7:14 ` [PATCH v8 10/12] entry: Add arch_ptrace_report_syscall_entry/exit() Jinjie Ruan
2025-11-27 13:30   ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 11/12] arm64: entry: Convert to generic entry Jinjie Ruan
2025-11-27 13:31   ` Kevin Brodsky
2025-11-28  3:34     ` Jinjie Ruan
2025-11-28 13:32       ` Kevin Brodsky
2025-11-29  1:23         ` Jinjie Ruan
2025-12-01 10:17           ` Kevin Brodsky
2025-11-26  7:14 ` [PATCH v8 12/12] selftests: sud_test: Support aarch64 Jinjie Ruan

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=2cc2b342-d350-415d-bc5a-05aa3da17d50@arm.com \
    --to=kevin.brodsky@arm.com \
    --cc=ada.coupriediaz@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=charlie@rivosinc.com \
    --cc=deller@gmx.de \
    --cc=dvyukov@google.com \
    --cc=efault@gmx.de \
    --cc=kees@kernel.org \
    --cc=kmal@cock.li \
    --cc=ldv@strace.io \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=mark.rutland@arm.com \
    --cc=mbenes@suse.cz \
    --cc=oleg@redhat.com \
    --cc=pengcan@kylinos.cn \
    --cc=peterz@infradead.org \
    --cc=ruanjinjie@huawei.com \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wad@chromium.org \
    --cc=will@kernel.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