Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhao Gongyi" <zhaogongyi@bytedance.com>
To: "Oleg Nesterov" <oleg@redhat.com>
Cc: <catalin.marinas@arm.com>, <will@kernel.org>,
	<mark.rutland@arm.com>,  <ruanjinjie@huawei.com>,
	<linux-arm-kernel@lists.infradead.org>,
	 <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop
Date: Sat, 24 Oct 2026 22:50:06 +0800	[thread overview]
Message-ID: <beb5fc93-4cca-4dc9-a4e3-f406e8c9cd58@bytedance.com> (raw)
In-Reply-To: <attf9KALBQyOGyco@redhat.com>

On 10/23/26 9:24 PM, Oleg Nesterov wrote:
> On 10/23, Zhao Gongyi wrote:
>>
>> --- a/arch/arm64/kernel/ptrace.c
>> +++ b/arch/arm64/kernel/ptrace.c
>> @@ -573,10 +573,6 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
>>   	if (regs->syscallno == NO_SYSCALL)
>>   		return;
>>
>> -	/* We should only be called when target is in a ptrace stop */
>> -	if (WARN_ON_ONCE(!info))
>> -		return;
>> -
>>   	/*
>>   	 * For compat tasks, orig_r0 is provided directly through GPR index
>>   	 * 17.
>> @@ -588,7 +584,7 @@ static void update_syscall_orig_x0_after_ptrace(struct task_struct *target)
>>   	 * Don't update orig_x0 for a syscall-exit-stop, as x0 now contains the
>>   	 * return value of the system call.
>>   	 */
>> -	if ((info->si_code & ~0x80) == SIGTRAP &&
>> +	if (info && (info->si_code & ~0x80) == SIGTRAP &&
>>   	    target->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) {
>>   		return;
> 
> LGTM, but I don't understand this arm-specific code.
> 
> And... Do we need to check target->last_siginfo at all?
> 
> ptrace_signal() -> ptrace_stop() path sets ->ptrace_message = 0.
> 
> In all other cases: if info != NULL, then .si_code == target->exit_code.
> ptrace_event(event) users always use event != 0 and != 0x80.
> 
> So it seems that we can just do
> 
> 	if ((target->exit_code & ~0x80) == SIGTRAP &&
> 	    target->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT)
> 
> ?
> 
> I'll recheck... If I am right, perhaps it makes sense to simplify
> ptrace_get_syscall_info_op().
> 

Hi Oleg,

Thanks for the review. I checked target->exit_code when the tracer calls 
PTRACE_SETREGSET after waitpid(). It
was 0 at syscall-exit-stops both with and without PTRACE_O_TRACESYSGOOD: 
wait_task_stopped() clears it when
reporting the stop. last_siginfo still held the corresponding si_code (5 
or 133).

I also used temporary kernel logging to check orig_x0 before and after 
writing a distinct value to x0 at each
stop. orig_x0 remained unchanged in both cases. Using exit_code in this 
condition would instead fall through
and copy the new x0 into orig_x0.

So I think we should keep the last_siginfo check in v2. The same 
exit_code lifetime also seems relevant to
ptrace_get_syscall_info_op() after waitpid().

Thanks,
Gongyi


  reply	other threads:[~2026-10-24 14:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 11:07 [PATCH v2] arm64: ptrace: don't warn on missing siginfo in a group-stop Zhao Gongyi
2026-10-23 13:24 ` Oleg Nesterov
2026-10-24 14:50   ` Zhao Gongyi [this message]
2026-10-24 15:09     ` Oleg Nesterov
2026-10-26 18:32 ` Catalin Marinas

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=beb5fc93-4cca-4dc9-a4e3-f406e8c9cd58@bytedance.com \
    --to=zhaogongyi@bytedance.com \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=oleg@redhat.com \
    --cc=ruanjinjie@huawei.com \
    --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