[PATCH v4 00/45] x86: Kernel IBT

Peter Zijlstra posted 45 patches 4 years, 3 months ago
Only 0 patches received!
[PATCH v4 00/45] x86: Kernel IBT
Posted by Peter Zijlstra 4 years, 3 months ago
Hopefully last posting...

Since last time:

 - updated the ftrace_location() patch (naveen, rostedt)
 - added a few comments and clarifications (bpetkov)
 - disable jump-tables (joao)
 - verified clang-14-rc2 works
 - fixed a whole bunch of objtool unreachable insn issue
 - picked up a few more tags

Patches go on top of tip/master + arm64/for-next/linkage. Also available here:

  git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.ibt

Enjoy!
Re: [PATCH v4 00/45] x86: Kernel IBT
Posted by Alexei Starovoitov 4 years, 3 months ago
On Tue, Mar 08, 2022 at 04:30:11PM +0100, Peter Zijlstra wrote:
> Hopefully last posting...
> 
> Since last time:
> 
>  - updated the ftrace_location() patch (naveen, rostedt)
>  - added a few comments and clarifications (bpetkov)
>  - disable jump-tables (joao)
>  - verified clang-14-rc2 works
>  - fixed a whole bunch of objtool unreachable insn issue
>  - picked up a few more tags
> 
> Patches go on top of tip/master + arm64/for-next/linkage. Also available here:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.ibt

I've tried to test it.
Applied the first 23 patches, since patch 24 failed to apply to bpf and bpf-next trees.
selftest/bpf/test_progs
shows that all bpf trampoline tests are failing and
eventually the kernel is crashing:
[   53.040582] RIP: 0010:do_init_module+0x9/0x6f0
[   53.052044] Call Trace:
[   53.052319]  <TASK>
[   53.052559]  bpf_trampoline_6442471381_0+0x32/0x1000
[   53.053117]  do_init_module+0x5/0x6f0
[   53.053550]  load_module+0x77c0/0x9c00

I havne't had time to debug what's going on.
Re: [PATCH v4 00/45] x86: Kernel IBT
Posted by Josh Poimboeuf 4 years, 3 months ago
On Tue, Mar 08, 2022 at 04:30:11PM +0100, Peter Zijlstra wrote:
> Hopefully last posting...
> 
> Since last time:
> 
>  - updated the ftrace_location() patch (naveen, rostedt)
>  - added a few comments and clarifications (bpetkov)
>  - disable jump-tables (joao)
>  - verified clang-14-rc2 works
>  - fixed a whole bunch of objtool unreachable insn issue
>  - picked up a few more tags
> 
> Patches go on top of tip/master + arm64/for-next/linkage. Also available here:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.ibt

<applause>  Nice work!!!  kernel shadow stacks next? ;-)

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>

As talked about on IRC there are still a few outstanding issues, that
I'm fine with fixing after the merge window during the upcoming -next
cycle:

- xen hypercall page functions need 'ret' - (I think you already fixed)

- why don't unreachables need to fill up the entire sym hole?

- get rid of the 'c_file' hack

- improve cmdline option intuitive-ness

- properly integrate the retpoline "demotion" with the new Spectre BHI
  related patches - probably still needs more discussion - for example
  we might instead want to disable IBT and warn

-- 
Josh
Re: [PATCH v4 00/45] x86: Kernel IBT
Posted by Josh Poimboeuf 4 years, 3 months ago
On Tue, Mar 08, 2022 at 12:06:18PM -0800, Josh Poimboeuf wrote:
> As talked about on IRC there are still a few outstanding issues, that
> I'm fine with fixing after the merge window during the upcoming -next
> cycle:
> 
> - xen hypercall page functions need 'ret' - (I think you already fixed)
> 
> - why don't unreachables need to fill up the entire sym hole?
> 
> - get rid of the 'c_file' hack
> 
> - improve cmdline option intuitive-ness
> 
> - properly integrate the retpoline "demotion" with the new Spectre BHI
>   related patches - probably still needs more discussion - for example
>   we might instead want to disable IBT and warn

One more:

- Changing objtool should force a vmlinux re-link.

-- 
Josh
RE: [PATCH v4 00/45] x86: Kernel IBT
Posted by David Laight 4 years, 3 months ago
From: Josh Poimboeuf
> Sent: 09 March 2022 06:57
> 
> On Tue, Mar 08, 2022 at 12:06:18PM -0800, Josh Poimboeuf wrote:
> > As talked about on IRC there are still a few outstanding issues, that
> > I'm fine with fixing after the merge window during the upcoming -next
> > cycle:
> >
> > - xen hypercall page functions need 'ret' - (I think you already fixed)
> >
> > - why don't unreachables need to fill up the entire sym hole?
> >
> > - get rid of the 'c_file' hack
> >
> > - improve cmdline option intuitive-ness
> >
> > - properly integrate the retpoline "demotion" with the new Spectre BHI
> >   related patches - probably still needs more discussion - for example
> >   we might instead want to disable IBT and warn
> 
> One more:
> 
> - Changing objtool should force a vmlinux re-link.

I'm wondering what actually happens to loadable modules?

Especially those built 'out of tree',
potentially with a different compiler,
and maybe containing binary 'blobs'.

The requirement to run programs on old distributions means
that things get compiled with quite old versions of gcc.
For instance RHEL7 is gcc 4.8.5.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Re: [PATCH v4 00/45] x86: Kernel IBT
Posted by Miroslav Benes 4 years, 3 months ago
On Tue, 8 Mar 2022, Peter Zijlstra wrote:

> Hopefully last posting...
> 
> Since last time:
> 
>  - updated the ftrace_location() patch (naveen, rostedt)
>  - added a few comments and clarifications (bpetkov)
>  - disable jump-tables (joao)
>  - verified clang-14-rc2 works
>  - fixed a whole bunch of objtool unreachable insn issue
>  - picked up a few more tags
> 
> Patches go on top of tip/master + arm64/for-next/linkage. Also available here:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/wip.ibt

FWIW objtool changes look good to me. 

I only came across 

arch/x86/kernel/head_64.o: warning: objtool: .noinstr.text: unexpected end of section

with CC_HAS_IBT=n, which you already know about.

CC_HAS_IBT=y compilation gives

vmlinux.o: warning: objtool: xen_vcpu_setup()+0xa3: unreachable instruction

Miroslav