lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240709231017.e8d5a37c96d126d1f7591a0e@kernel.org>
Date: Tue, 9 Jul 2024 23:10:17 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Andrii Nakryiko <andrii@...nel.org>, linux-trace-kernel@...r.kernel.org,
 rostedt@...dmis.org, mhiramat@...nel.org, x86@...nel.org, mingo@...hat.com,
 tglx@...utronix.de, jpoimboe@...hat.com, linux-kernel@...r.kernel.org,
 bpf@...r.kernel.org, rihams@...com, linux-perf-users@...r.kernel.org
Subject: Re: [PATCH v4] perf,x86: avoid missing caller address in stack
 traces captured in uprobe

On Tue, 9 Jul 2024 12:11:33 +0200
Peter Zijlstra <peterz@...radead.org> wrote:

> On Mon, Jul 08, 2024 at 04:11:27PM -0700, Andrii Nakryiko wrote:
> > +#ifdef CONFIG_UPROBES
> > +/*
> > + * Heuristic-based check if uprobe is installed at the function entry.
> > + *
> > + * Under assumption of user code being compiled with frame pointers,
> > + * `push %rbp/%ebp` is a good indicator that we indeed are.
> > + *
> > + * Similarly, `endbr64` (assuming 64-bit mode) is also a common pattern.
> > + * If we get this wrong, captured stack trace might have one extra bogus
> > + * entry, but the rest of stack trace will still be meaningful.
> > + */
> > +static bool is_uprobe_at_func_entry(struct pt_regs *regs)
> > +{
> > +	struct arch_uprobe *auprobe;
> > +
> > +	if (!current->utask)
> > +		return false;
> > +
> > +	auprobe = current->utask->auprobe;
> > +	if (!auprobe)
> > +		return false;
> > +
> > +	/* push %rbp/%ebp */
> > +	if (auprobe->insn[0] == 0x55)
> > +		return true;
> > +
> > +	/* endbr64 (64-bit only) */
> > +	if (user_64bit_mode(regs) && *(u32 *)auprobe->insn == 0xfa1e0ff3)
> > +		return true;
> 
> I meant to reply to Josh suggesting this, but... how can this be? If you
> scribble the ENDBR with an INT3 things will #CP and we'll never get to
> the #BP.

Hmm, kprobes checks the instruction and reject if it is ENDBR.
Shouldn't uprobe also skip the ENDBR too?

Thank you,

> 
> Also, we tried very hard to not have a literal encode ENDBR (I really
> should teach objtool about this one :/). If it somehow makes sense to
> keep this clause, please use: gen_endbr()


-- 
Masami Hiramatsu (Google) <mhiramat@...nel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ