Skip to content

objtool: UACCESS validation v4

Peter Zijlstra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest25 patches 32 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/25x86: Make SMAP 64-bit onlyarch/x86/Kconfig+2 -09 replies
1/25sched/x86: Save [ER]FLAGS on context switcharch/x86/entry/entry_32.S arch/x86/entry/entry_64.S arch/x86/include/asm/switch_to.h +2 more+20 -00 replies
2/25tracing: Improve "if" macro code generationinclude/linux/compiler.h+1 -118 replies
3/25x86/ia32: Fix ia32_restore_sigcontext AC leakarch/x86/ia32/ia32_signal.c+17 -120 replies
4/25i915,uaccess: Fix redundant CLACdrivers/gpu/drm/i915/i915_gem_execbuffer.c+4 -20 replies
5/25x86/uaccess: Move copy_user_handle_tail into asmarch/x86/include/asm/asm.h arch/x86/include/asm/uaccess_64.h arch/x86/lib/copy_user_64.S +1 more+48 -470 replies
6/25x86/uaccess: Fix up the fixuparch/x86/lib/memcpy_64.S+2 -10 replies
7/25x86/nospec,objtool: Introduce ANNOTATE_IGNORE_ALTERNATIVEarch/x86/include/asm/alternative-asm.h arch/x86/include/asm/alternative.h arch/x86/include/asm/nospec-branch.h +1 more+34 -230 replies
8/25x86/uaccess,xen: Suppress SMAP warningsarch/x86/include/asm/xen/hypercall.h+20 -40 replies
9/25x86/uaccess: Always inline user_access_begin()arch/x86/include/asm/uaccess.h+1 -10 replies
10/25x86/uaccess,signal: Fix AC=1 bloatarch/x86/kernel/signal.c+17 -120 replies
11/25x86/uaccess: Introduce user_access_{save,restore}()arch/x86/include/asm/smap.h arch/x86/include/asm/uaccess.h include/linux/uaccess.h+25 -00 replies
12/25x86/smap: Ditch __stringify()arch/x86/include/asm/smap.h+9 -100 replies
13/25x86/uaccess,kasan: Fix KASAN vs SMAPmm/kasan/Makefile mm/kasan/common.c mm/kasan/report.c+14 -20 replies
14/25x86/uaccess,ubsan: Fix UBSAN vs SMAPlib/Makefile lib/ubsan.c+5 -00 replies
15/25x86/uaccess,ftrace: Fix ftrace_likely_update() vs SMAPkernel/trace/trace_branch.c+4 -00 replies
16/25x86/uaccess,kcov: Disable stack protectorkernel/Makefile+1 -00 replies
17/25objtool: Set insn->func for alternativestools/objtool/check.c+1 -00 replies
18/25objtool: Handle function aliasestools/objtool/elf.c tools/objtool/elf.h+12 -50 replies
19/25objtool: Rewrite add_ignores()tools/objtool/check.c tools/objtool/check.h+20 -320 replies
20/25objtool: Add --backtrace supporttools/objtool/builtin-check.c tools/objtool/builtin.h tools/objtool/check.c +1 more+25 -60 replies
21/25objtool: Rewrite alt->skip_origtools/objtool/check.c+10 -60 replies
22/25objtool: Fix sibling call detectiontools/objtool/check.c+55 -310 replies
23/25objtool: Add UACCESS validationscripts/Makefile.build tools/objtool/arch.h tools/objtool/arch/x86/decode.c +7 more+196 -162 replies
24/25objtool: uaccess PUSHF/POPF supporttools/objtool/arch.h tools/objtool/arch/x86/decode.c tools/objtool/check.c +1 more+31 -60 replies
25/25objtool: Add Direction Flag validationtools/objtool/arch.h tools/objtool/arch/x86/decode.c tools/objtool/check.c +1 more+37 -20 replies

Reviews trailers per patch

5 of 26 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJuergen GrossAndy LutomirskiSteven Rostedt (VMware)Josh Poimboeuf
SeriesA-b
1/25A-b
1/25A-b
2/25A-b A-b
3/25
4/25
5/25
6/25
7/25
8/25R-b
9/25
10/25R-b
11/25
12/25
13/25
14/25
15/25
16/25
17/25
18/25
19/25
20/25
21/25
22/25
23/25
24/25
25/25

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v1 thread

Cover letter [PATCH 00/25] objtool: UACCESS validation v4

Teach objtool to validate the UACCESS (SMAP, PAN) rules which are currently unenforced and (therefore obviously) violated.

UACCESS sections should be small; we want to limit the amount of code that can touch userspace. Furthermore, UACCESS state isn't scheduled, this means that anything that directly calls into the scheduler will result in random code running with UACCESS enabled and possibly getting back into the UACCESS region with UACCESS disabled and causing faults.

Forbid any CALL/RET while UACCESS is enabled; but provide a few exceptions.

This builds x86_64-allmodconfig and lots of x86_64-randconfig clean.

Changes since -v3:

- removed a bunch of functions from the UACCESS-safe list due to the removal of CONFIG_KASAN_EXTRA=y.

- hopefully addressed all the feedback from Josh

- realized objtool doesn't cover x86_32

- some added additional annotations/fixes: kcov, signal

- retains the DF check for now, Linus, do you (still) think it is worth doing that DF check?

---
 arch/x86/Kconfig                           |   2 +
 arch/x86/ia32/ia32_signal.c                |  29 ++-
 arch/x86/include/asm/alternative-asm.h     |  11 +
 arch/x86/include/asm/alternative.h         |  10 +
 arch/x86/include/asm/asm.h                 |  24 --
 arch/x86/include/asm/nospec-branch.h       |  28 +-
 arch/x86/include/asm/smap.h                |  37 ++-
 arch/x86/include/asm/uaccess.h             |   5 +-
 arch/x86/include/asm/uaccess_64.h          |   3 -
 arch/x86/include/asm/xen/hypercall.h       |  24 +-
 arch/x86/kernel/signal.c                   |  29 ++-
 arch/x86/lib/copy_user_64.S                |  48 ++++
 arch/x86/lib/memcpy_64.S                   |   3 +-
 arch/x86/lib/usercopy_64.c                 |  20 --
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   6 +-
 include/linux/compiler.h                   |   2 +-
 include/linux/uaccess.h                    |   2 +
 kernel/Makefile                            |   1 +
 kernel/trace/trace_branch.c                |   4 +
 lib/Makefile                               |   1 +
 lib/ubsan.c                                |   4 +
 mm/kasan/Makefile                          |   3 +
 mm/kasan/common.c                          |  10 +
 mm/kasan/report.c                          |   3 +-
 scripts/Makefile.build                     |   3 +
 tools/objtool/arch.h                       |   8 +-
 tools/objtool/arch/x86/decode.c            |  21 +-
 tools/objtool/builtin-check.c              |   4 +-
 tools/objtool/builtin.h                    |   2 +-
 tools/objtool/check.c                      | 400 ++++++++++++++++++++++-------
 tools/objtool/check.h                      |   4 +-
 tools/objtool/elf.c                        |  15 +-
 tools/objtool/elf.h                        |   3 +-
 tools/objtool/special.c                    |  18 ++
 tools/objtool/special.h                    |   1 +
 tools/objtool/warn.h                       |   8 +
 36 files changed, 584 insertions(+), 212 deletions(-)