Skip to content

Commit c8c301a

Browse files
author
Peter Zijlstra
committed
x86/ibt: Add ANNOTATE_NOENDBR
In order to have objtool warn about code references to !ENDBR instruction, we need an annotation to allow this for non-control-flow instances -- consider text range checks, text patching, or return trampolines etc. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com> Link: https://lore.kernel.org/r/20220308154317.578968224@infradead.org
1 parent 156ff4a commit c8c301a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

include/linux/objtool.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ struct unwind_hint {
7777
#define STACK_FRAME_NON_STANDARD_FP(func)
7878
#endif
7979

80+
#define ANNOTATE_NOENDBR \
81+
"986: \n\t" \
82+
".pushsection .discard.noendbr\n\t" \
83+
_ASM_PTR " 986b\n\t" \
84+
".popsection\n\t"
85+
8086
#else /* __ASSEMBLY__ */
8187

8288
/*
@@ -129,6 +135,13 @@ struct unwind_hint {
129135
.popsection
130136
.endm
131137

138+
.macro ANNOTATE_NOENDBR
139+
.Lhere_\@:
140+
.pushsection .discard.noendbr
141+
.quad .Lhere_\@
142+
.popsection
143+
.endm
144+
132145
#endif /* __ASSEMBLY__ */
133146

134147
#else /* !CONFIG_STACK_VALIDATION */
@@ -139,12 +152,15 @@ struct unwind_hint {
139152
"\n\t"
140153
#define STACK_FRAME_NON_STANDARD(func)
141154
#define STACK_FRAME_NON_STANDARD_FP(func)
155+
#define ANNOTATE_NOENDBR
142156
#else
143157
#define ANNOTATE_INTRA_FUNCTION_CALL
144158
.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0
145159
.endm
146160
.macro STACK_FRAME_NON_STANDARD func:req
147161
.endm
162+
.macro ANNOTATE_NOENDBR
163+
.endm
148164
#endif
149165

150166
#endif /* CONFIG_STACK_VALIDATION */

tools/include/linux/objtool.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ struct unwind_hint {
7777
#define STACK_FRAME_NON_STANDARD_FP(func)
7878
#endif
7979

80+
#define ANNOTATE_NOENDBR \
81+
"986: \n\t" \
82+
".pushsection .discard.noendbr\n\t" \
83+
_ASM_PTR " 986b\n\t" \
84+
".popsection\n\t"
85+
8086
#else /* __ASSEMBLY__ */
8187

8288
/*
@@ -129,6 +135,13 @@ struct unwind_hint {
129135
.popsection
130136
.endm
131137

138+
.macro ANNOTATE_NOENDBR
139+
.Lhere_\@:
140+
.pushsection .discard.noendbr
141+
.quad .Lhere_\@
142+
.popsection
143+
.endm
144+
132145
#endif /* __ASSEMBLY__ */
133146

134147
#else /* !CONFIG_STACK_VALIDATION */
@@ -139,12 +152,15 @@ struct unwind_hint {
139152
"\n\t"
140153
#define STACK_FRAME_NON_STANDARD(func)
141154
#define STACK_FRAME_NON_STANDARD_FP(func)
155+
#define ANNOTATE_NOENDBR
142156
#else
143157
#define ANNOTATE_INTRA_FUNCTION_CALL
144158
.macro UNWIND_HINT sp_reg:req sp_offset=0 type:req end=0
145159
.endm
146160
.macro STACK_FRAME_NON_STANDARD func:req
147161
.endm
162+
.macro ANNOTATE_NOENDBR
163+
.endm
148164
#endif
149165

150166
#endif /* CONFIG_STACK_VALIDATION */

0 commit comments

Comments
 (0)