Re: [PATCH v2 16/19] objtool: Implement noinstr validation

From: Josh Poimboeuf
Date: Tue Mar 17 2020 - 17:00:37 EST


On Tue, Mar 17, 2020 at 06:02:50PM +0100, Peter Zijlstra wrote:
> Validate that any call out of .noinstr.text is in between
> instr_begin() and instr_end() annotations.
>
> This annotation is useful to ensure correct behaviour wrt tracing
> sensitive code like entry/exit and idle code. When we run code in a
> sensitive context we want a guarantee no unknown code is ran.
>
> Since this validation relies on knowing the section of call
> destination symbols, we must run it on vmlinux.o instead of on
> individual object files.
>
> Add two options:
>
> -d/--duplicate "duplicate validation for vmlinux"
> -l/--vmlinux "vmlinux.o validation"

I'm not sure I see the point of the --vmlinux option, when it will be
autodetected anyway?

> @@ -46,5 +49,9 @@ int cmd_check(int argc, const char **arg
>
> objname = argv[0];
>
> + s = strstr(objname, "vmlinux.o");
> + if (s && !s[9])
> + vmlinux = true;
> +

I think this would be slightly cleaner:

if (!strcmp(basename(objname), "vmlinux.o"))
vmlinux = true;

--
Josh