mirror of https://lore.kernel.org/lkml/
 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,
	deller@gmx.de, akpm@linux-foundation.org, charlie@rivosinc.com,
	mark.rutland@arm.com, anshuman.khandual@arm.com, song@kernel.org,
	ryan.roberts@arm.com, thuth@redhat.com, ada.coupriediaz@arm.com,
	broonie@kernel.org, pengcan@kylinos.cn, liqiang01@kylinos.cn,
	kmal@cock.li, dvyukov@google.com, reddybalavignesh9979@gmail.com,
	richard.weiyang@gmail.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH v11 03/14] arm64: ptrace: Move rseq_syscall() before audit_syscall_exit()
Date: Thu, 29 Jan 2026 13:06:29 +0100	[thread overview]
Message-ID: <c70d3fd6-0b62-464b-8e99-e74f07c20846@arm.com> (raw)
In-Reply-To: <20260128031934.3906955-4-ruanjinjie@huawei.com>

On 28/01/2026 04:19, Jinjie Ruan wrote:
> commit a9f3a74a29af ("entry: Provide generic syscall exit function")
> introduce generic syscall exit function and call rseq_syscall()
> before audit_syscall_exit() and arch_syscall_exit_tracehook().
>
> And commit b74406f37737 ("arm: Add syscall detection for restartable
> sequences") add rseq support for arm32, which also call rseq_syscall()
> before audit_syscall_exit() and tracehook_report_syscall().
>
> However, commit 409d5db49867c ("arm64: rseq: Implement backend rseq
> calls and select HAVE_RSEQ") implement arm64 rseq and call
> rseq_syscall() after audit_syscall_exit() and tracehook_report_syscall().
> So compared to the generic entry and arm32 code, arm64 calls
> rseq_syscall() a bit later.
>
> But as commit b74406f37737 ("arm: Add syscall detection for restartable
> sequences") said, syscalls are not allowed inside restartable sequences,
> so should call rseq_syscall() at the very beginning of system call
> exiting path for CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect
> whether there is a syscall issued inside restartable sequences.
>
> As for the impact of raising SIGSEGV via rseq_syscall(), it makes no
> practical difference to signal delivery because signals are processed
> in arm64_exit_to_user_mode() at the very end.
>
> As for the "regs", rseq_syscall() only checks and update
> instruction_pointer(regs), ptrace can not modify the "pc" on syscall exit
> path but 'only changes the return value', so calling rseq_syscall()
> before or after ptrace_report_syscall_exit() makes no difference.

Let's update this as discussed on v10 - PC can be modified when
ptrace_report_syscall_exit() is called.

> And audit_syscall_exit() only checks the return value (x0 for arm64),
> so calling rseq_syscall() before or after audit syscall exit makes
> no difference. trace_sys_exit() only uses syscallno and the return value,
> so calling rseq_syscall() before or after trace_sys_exit() also makes
> no difference.
>
> In preparation for moving arm64 over to the generic entry code, move
> rseq_syscall() ahead before audit_syscall_exit().
>
> No functional changes.

And naturally this is not the case.

- Kevin

> Reviewed-by: Kevin Brodsky <kevin.brodsky@arm.com>
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  arch/arm64/kernel/ptrace.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
> index 9f9aa3087c09..785280c76317 100644
> --- a/arch/arm64/kernel/ptrace.c
> +++ b/arch/arm64/kernel/ptrace.c
> @@ -2443,6 +2443,8 @@ int syscall_trace_enter(struct pt_regs *regs, unsigned long flags)
>  
>  void syscall_trace_exit(struct pt_regs *regs, unsigned long flags)
>  {
> +	rseq_syscall(regs);
> +
>  	audit_syscall_exit(regs);
>  
>  	if (flags & _TIF_SYSCALL_TRACEPOINT)
> @@ -2450,8 +2452,6 @@ void syscall_trace_exit(struct pt_regs *regs, unsigned long flags)
>  
>  	if (flags & (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP))
>  		report_syscall_exit(regs);
> -
> -	rseq_syscall(regs);
>  }
>  
>  /*

  reply	other threads:[~2026-01-29 12:06 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28  3:19 [PATCH v11 00/14] arm64: entry: Convert to Generic Entry Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 01/14] entry: Remove unused syscall in syscall_trace_enter() Jinjie Ruan
2026-01-29 12:06   ` Kevin Brodsky
2026-01-30 10:11   ` Thomas Gleixner
2026-01-30 21:53   ` [tip: core/entry] entry: Remove unused syscall argument from syscall_trace_enter() tip-bot2 for Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 02/14] arm64/ptrace: Refactor syscall_trace_enter/exit() Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 03/14] arm64: ptrace: Move rseq_syscall() before audit_syscall_exit() Jinjie Ruan
2026-01-29 12:06   ` Kevin Brodsky [this message]
2026-01-29 13:06     ` Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 04/14] arm64: syscall: Rework el0_svc_common() Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 05/14] arm64/ptrace: Not check _TIF_SECCOMP/SYSCALL_EMU for syscall_exit_work() Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 06/14] arm64/ptrace: Do not report_syscall_exit() for PTRACE_SYSEMU_SINGLESTEP Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 07/14] arm64/ptrace: Expand secure_computing() in place Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 08/14] arm64/ptrace: Use syscall_get_arguments() helper Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 09/14] entry: Rework syscall_exit_to_user_mode_work() for arch reuse Jinjie Ruan
2026-01-29 12:06   ` Kevin Brodsky
2026-01-29 13:11     ` Jinjie Ruan
2026-01-29 16:00       ` Kevin Brodsky
2026-01-30 10:16         ` Thomas Gleixner
2026-01-30 13:27           ` Kevin Brodsky
2026-01-30 15:01             ` Thomas Gleixner
2026-01-30 23:33               ` Thomas Gleixner
2026-01-31  1:43               ` Jinjie Ruan
2026-01-30 21:53   ` [tip: core/entry] entry: Rework syscall_exit_to_user_mode_work() for architecture reuse tip-bot2 for Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 10/14] entry: Add arch_ptrace_report_syscall_entry/exit() Jinjie Ruan
2026-01-30 21:53   ` [tip: core/entry] " tip-bot2 for Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 11/14] arm64: entry: Convert to generic entry Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 12/14] arm64: Inline el0_svc_common() Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 13/14] entry: Inline syscall_exit_work() and syscall_trace_enter() Jinjie Ruan
2026-01-30 10:14   ` Thomas Gleixner
2026-01-31  1:48     ` Jinjie Ruan
2026-01-30 21:53   ` [tip: core/entry] " tip-bot2 for Jinjie Ruan
2026-01-28  3:19 ` [PATCH v11 14/14] 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=c70d3fd6-0b62-464b-8e99-e74f07c20846@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=kees@kernel.org \
    --cc=kmal@cock.li \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=liqiang01@kylinos.cn \
    --cc=luto@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=oleg@redhat.com \
    --cc=pengcan@kylinos.cn \
    --cc=peterz@infradead.org \
    --cc=reddybalavignesh9979@gmail.com \
    --cc=richard.weiyang@gmail.com \
    --cc=ruanjinjie@huawei.com \
    --cc=ryan.roberts@arm.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thuth@redhat.com \
    --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

all inboxes | Powered by JetHome®