[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250411163242.GI5322@redhat.com>
Date: Fri, 11 Apr 2025 18:32:43 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, Andrii Nakryiko <andrii@...nel.org>,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org, x86@...nel.org,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Hao Luo <haoluo@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>
Subject: Re: [PATCHv2 perf/core 1/2] uprobes/x86: Add support to emulate nop
instructions
On 04/11, Andrii Nakryiko wrote:
>
> > --- a/arch/x86/kernel/uprobes.c
> > +++ b/arch/x86/kernel/uprobes.c
> > @@ -840,6 +840,12 @@ static int branch_setup_xol_ops(struct arch_uprobe *auprobe, struct insn *insn)
> > insn_byte_t p;
> > int i;
> >
> > + /* x86_nops[i]; same as jmp with .offs = 0 */
> > + for (i = 1; i <= ASM_NOP_MAX; ++i) {
>
> i <= ASM_NOP_MAX && i <= insn->length
>
> ?
>
> otherwise what prevents us from reading past the actual instruction bytes?
Well, copy_insn() just copies MAX_UINSN_BYTES into arch_uprobe.insn[].
If, say, the 1st 11 bytes of arch_uprobe.insn (or insn->kaddr) match
x86_nops[11] then insn->length must be 11, or insn_decode() is buggy?
> or, actually, shouldn't we just check memcmp(x86_nops[insn->length])
> if insn->length < ASM_NOP_MAX ?
Hmm... agreed.
Either way this check can't (doesn't even try to) detect, say,
"rep; BYTES_NOP5", so we do not care if insn->length == 6 in this case.
Good point!
Oleg.
Powered by blists - more mailing lists