linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] objtool: UACCESS validation v2
@ 2019-02-28 14:54 Peter Zijlstra
  2019-02-28 14:54 ` [PATCH 1/8] kasan,x86: Frob kasan_report() in an exception Peter Zijlstra
                   ` (7 more replies)
  0 siblings, 8 replies; 48+ messages in thread
From: Peter Zijlstra @ 2019-02-28 14:54 UTC (permalink / raw)
  To: torvalds, tglx, hpa, julien.thierry, will.deacon, luto, mingo,
	catalin.marinas, james.morse, valentin.schneider, brgerst,
	jpoimboe, luto, bp, dvlasenk
  Cc: linux-kernel, peterz

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(-)


^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2019-03-07 13:49 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-28 14:54 [PATCH 0/8] objtool: UACCESS validation v2 Peter Zijlstra
2019-02-28 14:54 ` [PATCH 1/8] kasan,x86: Frob kasan_report() in an exception Peter Zijlstra
2019-02-28 15:22   ` Dmitry Vyukov
2019-02-28 15:45     ` Peter Zijlstra
2019-02-28 15:52       ` Dmitry Vyukov
2019-02-28 16:01         ` Andrey Ryabinin
2019-02-28 16:03       ` Dmitry Vyukov
2019-02-28 17:46         ` Peter Zijlstra
2019-02-28 18:18           ` Dmitry Vyukov
2019-03-01 14:45     ` Peter Zijlstra
2019-03-01 15:06       ` Dmitry Vyukov
2019-03-01 15:23         ` Peter Zijlstra
2019-03-06 13:13           ` Peter Zijlstra
2019-03-06 13:39             ` Dmitry Vyukov
2019-03-06 13:57               ` Peter Zijlstra
2019-03-06 14:01                 ` Dmitry Vyukov
2019-03-06 14:12                   ` Peter Zijlstra
2019-03-06 14:34                     ` Peter Zijlstra
2019-03-06 14:40                       ` Dmitry Vyukov
2019-03-06 14:41                         ` Dmitry Vyukov
2019-03-06 14:55                         ` Peter Zijlstra
2019-03-06 15:01                           ` Dmitry Vyukov
2019-03-06 17:14             ` Peter Zijlstra
2019-03-06 17:27               ` Linus Torvalds
2019-03-06 17:37               ` Peter Zijlstra
2019-03-06 17:59                 ` Linus Torvalds
2019-03-07 13:49                   ` Peter Zijlstra
2019-02-28 14:54 ` [PATCH 2/8] x86/ia32: Fix ia32_restore_sigcontext AC leak Peter Zijlstra
2019-02-28 14:54 ` [PATCH 3/8] objtool: Set insn->func for alternatives Peter Zijlstra
2019-02-28 14:54 ` [PATCH 4/8] objtool: Hande function aliases Peter Zijlstra
2019-02-28 14:54 ` [PATCH 5/8] objtool: Rewrite add_ignores() Peter Zijlstra
2019-02-28 14:54 ` [PATCH 6/8] i915,uaccess: Fix redundant CLAC Peter Zijlstra
2019-02-28 15:10   ` Chris Wilson
2019-02-28 15:24     ` Peter Zijlstra
2019-02-28 16:49   ` Linus Torvalds
2019-02-28 17:51     ` Peter Zijlstra
2019-02-28 18:01       ` Peter Zijlstra
2019-02-28 18:29         ` Linus Torvalds
2019-02-28 19:01           ` Peter Zijlstra
2019-03-01 10:34             ` Peter Zijlstra
2019-03-01 12:27               ` Peter Zijlstra
2019-03-01 12:57                 ` Peter Zijlstra
2019-03-01 14:38                   ` Peter Zijlstra
2019-03-01 15:27                     ` Andy Lutomirski
2019-03-01 16:15                   ` Linus Torvalds
2019-03-01 16:17               ` Linus Torvalds
2019-02-28 14:54 ` [PATCH 7/8] objtool: Add UACCESS validation Peter Zijlstra
2019-02-28 14:54 ` [PATCH 8/8] objtool: Add Direction Flag validation Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).