Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: David Windsor <dwindsor@gmail.com>,
	mhiramat@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	shuah@kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] x86/uprobes: Keep shadow stack in sync for emulated CALLs
Date: Tue, 23 Jun 2026 15:25:10 +0200	[thread overview]
Message-ID: <ajqJNju6MY3B0S2F@redhat.com> (raw)
In-Reply-To: <20260623125725.GW48970@noisy.programming.kicks-ass.net>

On 06/23, Peter Zijlstra wrote:
>
> On Tue, Jun 23, 2026 at 02:52:32PM +0200, Oleg Nesterov wrote:
> > On 06/22, David Windsor wrote:
> > >
> > > --- a/arch/x86/kernel/uprobes.c
> > > +++ b/arch/x86/kernel/uprobes.c
> > > @@ -1246,8 +1246,12 @@ static int default_post_xol_op(struct arch_uprobe *auprobe, struct pt_regs *regs
> > >  		long correction = utask->vaddr - utask->xol_vaddr;
> > >  		regs->ip += correction;
> > >  	} else if (auprobe->defparam.fixups & UPROBE_FIX_CALL) {
> > > +		unsigned long retaddr = utask->vaddr + auprobe->defparam.ilen;
> > > +
> > >  		regs->sp += sizeof_long(regs); /* Pop incorrect return address */
> > > -		if (emulate_push_stack(regs, utask->vaddr + auprobe->defparam.ilen))
> > > +		if (emulate_push_stack(regs, retaddr))
> > > +			return -ERESTART;
> > > +		if (shstk_update_last_frame(retaddr))
> > >  			return -ERESTART;
> >
> > Well, if shstk_update_last_frame() fails after emulate_push_stack(), we should
> > probably return another error, so that the caller handle_singlestep() will kill
> > this task?
>
> Makes sense, the other user has a force_sig(SIGSEGV) on failure.

Offtopic question... both shstk_update_last_frame() and shstk_push() are only
used by arch/x86/kernel/uprobes.c. But they are not symmetric in that
shstk_update_last_frame() returns 0 if !features_enabled(ARCH_SHSTK_SHSTK),
while shstk_push() returns -ENOTSUPP in this case.

That is why the users can't just do "if (shstk_push(xxx)) ...". This is really
minor, but perhaps it makes sense to change shstk_push() to return 0 in this
case too? I don't think -ENOTSUPP is actually useful...

Oleg.


      reply	other threads:[~2026-06-23 13:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22 18:31 [PATCH 1/2] x86/uprobes: Keep shadow stack in sync for emulated CALLs David Windsor
2026-06-22 18:31 ` [PATCH 2/2] selftests/x86: Add shadow stack uprobe CALL test David Windsor
2026-06-23  8:43 ` [PATCH 1/2] x86/uprobes: Keep shadow stack in sync for emulated CALLs Peter Zijlstra
2026-06-23 14:07   ` David Windsor
2026-06-23 12:52 ` Oleg Nesterov
2026-06-23 12:57   ` Peter Zijlstra
2026-06-23 13:25     ` Oleg Nesterov [this message]

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=ajqJNju6MY3B0S2F@redhat.com \
    --to=oleg@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwindsor@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=shuah@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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