From: Jiri Olsa <olsajiri@gmail.com>
To: Andy Lutomirski <luto@kernel.org>, Kees Cook <kees@kernel.org>
Cc: Jiri Olsa <olsajiri@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Andrii Nakryiko <andrii@kernel.org>,
Eyal Birger <eyal.birger@gmail.com>,
stable@vger.kernel.org, Jann Horn <jannh@google.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-api@vger.kernel.org, x86@kernel.org, bpf@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Deepak Gupta <debug@rivosinc.com>,
Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCHv3 perf/core] uprobes: Harden uretprobe syscall trampoline check
Date: Mon, 17 Feb 2025 13:09:43 +0100 [thread overview]
Message-ID: <Z7MnB3yf2u9eR1yp@krava> (raw)
In-Reply-To: <CALCETrVt=N-QG3zGyPspNCF=8tA4icC75RVVe70-DvJfsh7Sww@mail.gmail.com>
On Thu, Feb 13, 2025 at 09:58:29AM -0800, Andy Lutomirski wrote:
> On Thu, Feb 13, 2025 at 1:16 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Wed, Feb 12, 2025 at 05:37:11PM -0800, Andy Lutomirski wrote:
> > > On Wed, Feb 12, 2025 at 2:04 PM Jiri Olsa <jolsa@kernel.org> wrote:
> > > >
> > > > Jann reported [1] possible issue when trampoline_check_ip returns
> > > > address near the bottom of the address space that is allowed to
> > > > call into the syscall if uretprobes are not set up.
> > > >
> > > > Though the mmap minimum address restrictions will typically prevent
> > > > creating mappings there, let's make sure uretprobe syscall checks
> > > > for that.
> > >
> > > It would be a layering violation, but we could perhaps do better here:
> > >
> > > > - if (regs->ip != trampoline_check_ip())
> > > > + /* Make sure the ip matches the only allowed sys_uretprobe caller. */
> > > > + if (unlikely(regs->ip != trampoline_check_ip(tramp)))
> > > > goto sigill;
> > >
> > > Instead of SIGILL, perhaps this should do the seccomp action? So the
> > > logic in seccomp would be (sketchily, with some real mode1 mess):
> > >
> > > if (is_a_real_uretprobe())
> > > skip seccomp;
> >
> > IIUC you want to move the address check earlier to the seccomp path..
> > with the benefit that we would kill not allowed caller sooner?
>
> The benefit would be that seccomp users that want to do something
> other than killing a process (returning an error code, getting
> notified, etc) could retain that functionality without the new
> automatic hole being poked for uretprobe() in cases where uprobes
> aren't in use or where the calling address doesn't match the uprobe
> trampoline. IOW it would reduce the scope to which we're making
> seccomp behave unexpectedly.
Kees, any thoughts about this approach?
thanks,
jirka
>
> >
> > jirka
> >
> > >
> > > where is_a_real_uretprobe() is only true if the nr and arch match
> > > uretprobe *and* the address is right.
> > >
> > > --Andy
> >
next prev parent reply other threads:[~2025-02-17 12:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 22:04 [PATCHv3 perf/core] uprobes: Harden uretprobe syscall trampoline check Jiri Olsa
2025-02-13 0:10 ` Masami Hiramatsu
2025-02-13 1:37 ` Andy Lutomirski
2025-02-13 2:58 ` Eyal Birger
2025-02-13 9:12 ` Jiri Olsa
2025-02-13 17:58 ` Andy Lutomirski
2025-02-17 12:09 ` Jiri Olsa [this message]
2025-03-06 10:57 ` Jiri Olsa
2025-03-06 11:22 ` Ingo Molnar
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=Z7MnB3yf2u9eR1yp@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=debug@rivosinc.com \
--cc=eyal.birger@gmail.com \
--cc=jannh@google.com \
--cc=kees@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sfr@canb.auug.org.au \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).