lkml.org 
[lkml]   [2022]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 24/29] x86/text-patching: Make text_gen_insn() IBT aware
> +#ifdef CONFIG_X86_IBT
> + if (is_endbr(dest))
> + dest += 4;
> +#endif

Hi, FWIIW I saw this snippet trigger a bug in the jump_label infra where
the target displacement would not fit in a JMP8 operand. The behavior
was seen because clang, for whatever reason (probably a bug?) inlined an
ENDBR function along with a function, thus the JMP8 target was
incremented. I compared the faulty kernel to one compiled with GCC and
the latter wont emit/inline the ENDBR.

The displacement I'm using in my experimentation is a few bytes more
than just 4, because I'm also adding extra instrumentation that should
be skipped when not reached indirectly. Of course this is more prone to
triggering the bug, but I don't think it is impossible to happen in the
current implementation.

For these cases perhaps we can verify if the displacement fits the
operand and, if not, simply ignore and lose the decode cycle which may
not be a huge problem and remains semantically correct. Seems more
sensible than padding jump tables with nops. In the meantime I'll
investigate clang's behavior and if it is really a bug, I'll work on a
patch.

\
 
 \ /
  Last update: 2022-02-24 02:35    [W:0.596 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site