Skip to content

objtool: UACCESS validation v2

Peter Zijlstra lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 39 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8kasan,x86: Frob kasan_report() in an exceptionarch/x86/include/asm/bug.h arch/x86/include/asm/kasan.h include/asm-generic/bug.h +5 more+51 -2225 replies
2/8x86/ia32: Fix ia32_restore_sigcontext AC leakarch/x86/ia32/ia32_signal.c+17 -120 replies
3/8objtool: Set insn->func for alternativestools/objtool/check.c+1 -00 replies
4/8objtool: Hande function aliasestools/objtool/elf.c tools/objtool/elf.h+12 -50 replies
5/8objtool: Rewrite add_ignores()tools/objtool/check.c tools/objtool/check.h+20 -320 replies
6/8i915,uaccess: Fix redundant CLACdrivers/gpu/drm/i915/i915_gem_execbuffer.c+1 -214 replies
7/8objtool: Add UACCESS validationinclude/linux/frame.h tools/objtool/arch.h tools/objtool/arch/x86/decode.c +3 more+158 -120 replies
8/8objtool: Add Direction Flag validationtools/objtool/arch.h tools/objtool/arch/x86/decode.c tools/objtool/check.c +1 more+33 -20 replies

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by.

PatchChris Wilson
1/8
2/8
3/8
4/8
5/8
6/8R-b
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/8] objtool: UACCESS validation v2

Teach objtool to validate the UACCESS (SMAP, PAN) rules with 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 an annotation to mark (a very limited) set of functions as UACCESS-safe (eg. the planned:
unsafe_copy_{to,from}_user()).

This set now compiles x86_64-allmodconfig _almost_ clean:

arch/x86/lib/usercopy_64.o: warning: objtool: .altinstr_replacement+0x30: redundant UACCESS disable drivers/xen/privcmd.o: warning: objtool: privcmd_ioctl()+0x1c0: call to {dynamic}() with UACCESS enabled drivers/xen/privcmd.o: warning: objtool: privcmd_ioctl()+0x8f8: call to hypercall_page() with UACCESS enabled

Also; I found the UACCESS_SAFE() annotation as presented in these patches to be inadequate; so I might go back to the STH_STRTAB variant for this. Alternatively, we can simply keep the hard-coded list we have now. There really should not be many more function on there.

*compile tested only*, esp. the KASAN changes have not been verified to actually *work*.

---
 arch/x86/ia32/ia32_signal.c                |  29 +++--
 arch/x86/include/asm/bug.h                 |  28 ++--
 arch/x86/include/asm/kasan.h               |  15 +++
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   3 +-
 include/asm-generic/bug.h                  |   1 +
 include/linux/frame.h                      |  23 ++++
 include/linux/kasan.h                      |  12 +-
 lib/bug.c                                  |   9 +-
 mm/kasan/generic.c                         |   4 +-
 mm/kasan/kasan.h                           |   2 +-
 mm/kasan/report.c                          |   2 +-
 tools/objtool/arch.h                       |   6 +-
 tools/objtool/arch/x86/decode.c            |  22 +++-
 tools/objtool/check.c                      | 197 +++++++++++++++++++++++------
 tools/objtool/check.h                      |   3 +-
 tools/objtool/elf.c                        |  15 ++-
 tools/objtool/elf.h                        |   3 +-
 17 files changed, 290 insertions(+), 84 deletions(-)