Re: [RFC][PATCH 00/16] objtool: vmlinux.o and noinstr validation

Peter Zijlstra
2020-03-17T12:14:39Z

On Tue, Mar 17, 2020 at 09:56:28AM +0900, Masami Hiramatsu wrote:
> On Thu, 12 Mar 2020 17:23:37 +0100
> Peter Zijlstra <peterz@infradead.org> wrote:

> > So one of the problem i've ran into while playing with this and Thomas'
> > patches is that it is 'difficult' to deal with indirect function calls.
> >
> > objtool basically gives up instantly.
>
> Can we introduce a "safe-call" wrapper function instead of indirect
> call, and if objtool found an indirect call without safe-call function,
> it can make it an error?
>
> static int __noinstr safe_indirect_callback(int (*fn)(...), real-args)
> {
> if (!is_instr_text(fn))
> return -ERANGE;
> return fn(real-args)
> }

That is a runtime test and as such susceptible to code coverage issues.

I could probably frob a few cases manually in objtool; so far I've
managed to just make them go away.

> BTW, out of curiously, if BUG*() or WARN*() cases happens in the noinstr
> section, do we also need to move them (register dump, stack unwinding,
> printk, console output, etc.) all into noinstr section?

Since BUG/WARN should not happen, we've added instr_begin()/instr_end()
to their slow path. If those trigger, we've got bigger issues.