Re: [PATCH] lkdtm: Keep the rodata test from causing retbleed WARNINGS
From: Kees Cook
Date: Wed Jul 20 2022 - 23:06:33 EST
On Wed, Jul 20, 2022 at 03:58:09PM -0700, Josh Poimboeuf wrote:
> On Wed, Jul 20, 2022 at 03:56:18PM -0700, Josh Poimboeuf wrote:
> > On Wed, Jul 20, 2022 at 01:13:05PM -0700, Kees Cook wrote:
> > > On Wed, Jul 20, 2022 at 03:55:07PM -0400, Steven Rostedt wrote:
> > > > From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>
> > > >
> > > > The rodata test checks if executable code in the .rodata section will not
> > > > execute. But this also means that fix ups that the return hook code does
> > > > will not be able to change this code at boot up, and this causes a
> > > > warning.
> > > >
> > > > By removing the RETHOOK_CFLAGS from the compilation of the rodata function
> > > > makes it hidden from objtool and it will not add its return hook into the
> > > > .returns section. This keeps the fix up code from trying and failing on
> > > > modifying the rodata return call.
> > > >
> > > > Link: https://lore.kernel.org/all/20220720125736.48164a14@xxxxxxxxxxxxxxxxxx/
> > > >
> > > > Fixes: ee88d363d1561 ("x86,static_call: Use alternative RET encoding")
> > > > Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
> > >
> > > Yeah, this matches a portion of what was suggested:
> > > https://lore.kernel.org/lkml/20220713213133.455599-1-keescook@xxxxxxxxxxxx/
> > >
> > > But it still needed objtool fixes:
> > > https://lore.kernel.org/lkml/20220715032333.neywlazczbb35w3b@treble/
> > >
> > > Perhaps objtool has already had patches landed for this? (Otherwise the
> > > patch you suggested would fail to build on x86 with rethunk support.)
> >
> > I send this patch out a few days ago, nobody picked it up yet:
> >
> > https://lkml.kernel.org/lkml/8ec0039712f252693049c70ed3891d39a2357112.1658155446.git.jpoimboe@xxxxxxxxxx
>
> Actually Peter said he grabbed it and is planning to push it to -tip
> tomorrow.
Ah perfect; thank you!
--
Kees Cook