Skip to content

Commit 7dce620

Browse files
jpoimboePeter Zijlstra
authored andcommitted
objtool: Make stack validation optional
Make stack validation an explicit cmdline option so that individual objtool features can be enabled individually by other arches. Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Link: https://lkml.kernel.org/r/52da143699574d756e65ca4c9d4acaffe9b0fe5f.1650300597.git.jpoimboe@redhat.com
1 parent 99c0beb commit 7dce620

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

scripts/Makefile.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ objtool_args = \
232232
$(if $(CONFIG_UNWINDER_ORC), --orc) \
233233
$(if $(CONFIG_RETPOLINE), --retpoline) \
234234
$(if $(CONFIG_SLS), --sls) \
235+
$(if $(CONFIG_STACK_VALIDATION), --stackval) \
235236
$(if $(CONFIG_X86_SMAP), --uaccess) \
236237
$(if $(part-of-module), --module) \
237238
$(if $(CONFIG_FRAME_POINTER),, --no-fp) \

scripts/link-vmlinux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ objtool_link()
126126
objtoolopt="${objtoolopt} --orc"
127127
fi
128128

129+
if is_enabled CONFIG_STACK_VALIDATION; then
130+
objtoolopt="${objtoolopt} --stackval"
131+
fi
132+
129133
objtoolopt="${objtoolopt} --lto"
130134
fi
131135

tools/objtool/builtin-check.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const struct option check_options[] = {
3939
OPT_BOOLEAN('o', "orc", &opts.orc, "generate ORC metadata"),
4040
OPT_BOOLEAN('r', "retpoline", &opts.retpoline, "validate and annotate retpoline usage"),
4141
OPT_BOOLEAN('l', "sls", &opts.sls, "validate straight-line-speculation mitigations"),
42+
OPT_BOOLEAN('s', "stackval", &opts.stackval, "validate stack unwinding rules"),
4243
OPT_BOOLEAN('u', "uaccess", &opts.uaccess, "validate uaccess rules for SMAP"),
4344
OPT_CALLBACK_OPTARG(0, "dump", NULL, NULL, "orc", "dump metadata", parse_dump),
4445

@@ -92,6 +93,7 @@ static bool opts_valid(void)
9293
opts.orc ||
9394
opts.retpoline ||
9495
opts.sls ||
96+
opts.stackval ||
9597
opts.uaccess) {
9698
if (opts.dump_orc) {
9799
fprintf(stderr, "--dump can't be combined with other options\n");

tools/objtool/check.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3899,25 +3899,27 @@ int check(struct objtool_file *file)
38993899
warnings += ret;
39003900
}
39013901

3902-
ret = validate_functions(file);
3903-
if (ret < 0)
3904-
goto out;
3905-
warnings += ret;
3906-
3907-
ret = validate_unwind_hints(file, NULL);
3908-
if (ret < 0)
3909-
goto out;
3910-
warnings += ret;
3902+
if (opts.stackval || opts.orc || opts.uaccess || opts.ibt || opts.sls) {
3903+
ret = validate_functions(file);
3904+
if (ret < 0)
3905+
goto out;
3906+
warnings += ret;
39113907

3912-
if (opts.ibt) {
3913-
ret = validate_ibt(file);
3908+
ret = validate_unwind_hints(file, NULL);
39143909
if (ret < 0)
39153910
goto out;
39163911
warnings += ret;
3912+
3913+
if (!warnings) {
3914+
ret = validate_reachable_instructions(file);
3915+
if (ret < 0)
3916+
goto out;
3917+
warnings += ret;
3918+
}
39173919
}
39183920

3919-
if (!warnings) {
3920-
ret = validate_reachable_instructions(file);
3921+
if (opts.ibt) {
3922+
ret = validate_ibt(file);
39213923
if (ret < 0)
39223924
goto out;
39233925
warnings += ret;

tools/objtool/include/objtool/builtin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct opts {
1818
bool orc;
1919
bool retpoline;
2020
bool sls;
21+
bool stackval;
2122
bool uaccess;
2223

2324
/* options: */

0 commit comments

Comments
 (0)