On Fri, Jun 26, 2026 at 11:43:20AM +0200, Oleg Nesterov wrote:
> On 05/26, Jiri Olsa wrote:
> >
> > which means we need to allow 0x2e prefix which maps to INAT_PFX_CS
> > attribute in is_prefix_bad function.
>
> ...
>
> > --- a/arch/x86/kernel/uprobes.c
> > +++ b/arch/x86/kernel/uprobes.c
> > @@ -266,7 +266,6 @@ static bool is_prefix_bad(struct insn *insn)
> > attr = inat_get_opcode_attribute(p);
> > switch (attr) {
> > case INAT_MAKE_PREFIX(INAT_PFX_ES):
> > - case INAT_MAKE_PREFIX(INAT_PFX_CS):
>
> I know nothing about how x86 CPU works, so let me ask...
>
> What if insn->x86_64 is false? Is it safe to allow the CS prefix in
> this case?
>
> Oleg.
>
hum, right.. I think we could make it x86_64 specific
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 04cd2cdce8c8..de60ec1eeee7 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -265,6 +265,10 @@ static bool is_prefix_bad(struct insn *insn)
attr = inat_get_opcode_attribute(p);
switch (attr) {
+ case INAT_MAKE_PREFIX(INAT_PFX_CS):
+ if (insn->x86_64)
+ break;
+ fallthrough;
case INAT_MAKE_PREFIX(INAT_PFX_ES):
case INAT_MAKE_PREFIX(INAT_PFX_DS):
case INAT_MAKE_PREFIX(INAT_PFX_SS):
or we could just skip it for nop10.. maybe that's better
jirka
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 04cd2cdce8c8..21f26e6fd452 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -285,7 +285,7 @@ static int uprobe_init_insn(struct arch_uprobe *auprobe,
struct insn *insn, bool
if (ret < 0)
return -ENOEXEC;
- if (is_prefix_bad(insn))
+ if (!is_optimizable_nop10(insn) && is_prefix_bad(insn))
return -ENOTSUPP;
/* We should not singlestep on the exception masking instructions */