lkdtm: Keep the rodata test from causing retbleed WARNINGS
Subsystems (3)
PATCH 1/1 lkdtm: Keep the rodata test from causing retbleed WARNINGS
From: "Steven Rostedt (Google)" <[email protected]>
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.
---
[ Note, my tests are still running with this, but it passed the test that
caused the failure, so I decided to post this now. ]
arch/x86/Makefile | 1 + drivers/misc/lkdtm/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
arch/x86/Makefile +1 -0
@@ -25,6 +25,7 @@ endif ifdef CONFIG_RETHUNK RETHUNK_CFLAGS := -mfunction-return=thunk-extern RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) +export RETHUNK_CFLAGS endif export RETPOLINE_CFLAGS
drivers/misc/lkdtm/Makefile +1 -1
@@ -16,7 +16,7 @@ lkdtm-$(CONFIG_PPC_64S_HASH_MMU) += powerpc.o KASAN_SANITIZE_rodata.o := n KASAN_SANITIZE_stackleak.o := n KCOV_INSTRUMENT_rodata.o := n -CFLAGS_REMOVE_rodata.o += $(CC_FLAGS_LTO) +CFLAGS_REMOVE_rodata.o += $(CC_FLAGS_LTO) $(RETHUNK_CFLAGS) OBJCOPYFLAGS := OBJCOPYFLAGS_rodata_objcopy.o := \
Signature · 1 line
2.35.1
Quoted 12 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
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_CFLAGSfrom 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.
Quoted 4 lines
Fixes ee88d363d1561 ("x86,static_call: Use alternative RET encoding")Signed-off-by Steven Rostedt (Google) <[email protected]>
Yeah, this matches a portion of what was suggested:
https://lore.kernel.org/lkml/[email protected]/
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.)
-Kees
Quoted 37 lines
---
[ Note, my tests are still running with this, but it passed the test that
caused the failure, so I decided to post this now. ]arch/x86/Makefile | 1 + drivers/misc/lkdtm/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)arch/x86/Makefile +1
-0@@ -25,6 +25,7 @@ endif ifdef CONFIG_RETHUNK RETHUNK_CFLAGS := -mfunction-return=thunk-extern RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS) +export RETHUNK_CFLAGS endif export RETPOLINE_CFLAGSdrivers/misc/lkdtm/Makefile +1
-1@@ -16,7 +16,7 @@ lkdtm-$(CONFIG_PPC_64S_HASH_MMU) += powerpc.o KASAN_SANITIZE_rodata.o := n KASAN_SANITIZE_stackleak.o := n KCOV_INSTRUMENT_rodata.o := n -CFLAGS_REMOVE_rodata.o += $(CC_FLAGS_LTO) +CFLAGS_REMOVE_rodata.o += $(CC_FLAGS_LTO) $(RETHUNK_CFLAGS) OBJCOPYFLAGS := OBJCOPYFLAGS_rodata_objcopy.o := \Signature · 1 line
2.35.1
Signature · 1 line
Kees Cook
Quoted 18 lines · Kees Cook
Quoted 12 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
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_CFLAGSfrom 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.Quoted 4 lines
Fixes ee88d363d1561 ("x86,static_call: Use alternative RET encoding")Signed-off-by Steven Rostedt (Google) <[email protected]>
Quoted 8 lines
Yeah, this matches a portion of what was suggested:
https://lore.kernel.org/lkml/[email protected]/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:
Signature · 1 line
Josh
Quoted 25 lines · Josh Poimboeuf
Quoted 24 lines · Kees Cook
Quoted 12 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
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_CFLAGSfrom 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.Quoted 4 lines
Fixes ee88d363d1561 ("x86,static_call: Use alternative RET encoding")Signed-off-by Steven Rostedt (Google) <[email protected]>Yeah, this matches a portion of what was suggested:
https://lore.kernel.org/lkml/[email protected]/But it still needed objtool fixes:
https://lore.kernel.org/lkml/20220715032333.neywlazczbb35w3b@treble/
Quoted 6 lines
Quoted 2 lines
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:
Actually Peter said he grabbed it and is planning to push it to -tip tomorrow.
Signature · 1 line
Josh
Quoted 29 lines · Josh Poimboeuf
Quoted 28 lines · Josh Poimboeuf
Quoted 26 lines · Kees Cook
Quoted 12 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
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_CFLAGSfrom 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.Quoted 4 lines
Fixes ee88d363d1561 ("x86,static_call: Use alternative RET encoding")Signed-off-by Steven Rostedt (Google) <[email protected]>Yeah, this matches a portion of what was suggested:
https://lore.kernel.org/lkml/[email protected]/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.)
Quoted 6 lines
Quoted 3 lines
I send this patch out a few days ago, nobody picked it up yet:
Actually Peter said he grabbed it and is planning to push it to -tip tomorrow.
Ah perfect; thank you!
Signature · 1 line
Kees Cook
Quoted 2 lines · Josh Poimboeuf
Actually Peter said he grabbed it and is planning to push it to -tip tomorrow.
Robots were happy, all pushed now.
Quoted 5 lines · On Thu, 21 Jul 2022 10:47:09 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 2 lines · Josh Poimboeuf
Actually Peter said he grabbed it and is planning to push it to -tip tomorrow.
Robots were happy, all pushed now.
What tree is this against. I tried to add it to v5.19-rc7 but it fails to apply.
-- Steve
Quoted 11 lines · Steven Rostedt
Quoted 5 lines · On Thu, 21 Jul 2022 10:47:09 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 2 lines · Josh Poimboeuf
Actually Peter said he grabbed it and is planning to push it to -tip tomorrow.
Robots were happy, all pushed now.
What tree is this against. I tried to add it to v5.19-rc7 but it fails to apply.
I can cleanly merge tip/x86/urgent into v5.19-rc7 (ff merge)
Quoted 4 lines · On Thu, 21 Jul 2022 17:58:13 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 2 lines
What tree is this against. I tried to add it to v5.19-rc7 but it fails to apply.
I can cleanly merge tip/x86/urgent into v5.19-rc7 (ff merge)
There's probably other commits in urgent that touch that code. I just tried to apply the patch directly, because that's all I wanted to test.
-- Steve