Marco Elver 6d5a88cd0c lkdtm: disable KASAN for rodata.o
Building lkdtm with KASAN and Clang 11 or later results in the following
error when attempting to load the module:

  kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
  BUG: unable to handle page fault for address: ffffffffc019cd70
  #PF: supervisor instruction fetch in kernel mode
  #PF: error_code(0x0011) - permissions violation
  ...
  RIP: 0010:asan.module_ctor+0x0/0xffffffffffffa290 [lkdtm]
  ...
  Call Trace:
   do_init_module+0x17c/0x570
   load_module+0xadee/0xd0b0
   __x64_sys_finit_module+0x16c/0x1a0
   do_syscall_64+0x34/0x50
   entry_SYSCALL_64_after_hwframe+0x44/0xa9

The reason is that rodata.o generates a dummy function that lives in
.rodata to validate that .rodata can't be executed; however, Clang 11 adds
KASAN globals support by generating module constructors to initialize
globals redzones.  When Clang 11 adds a module constructor to rodata.o, it
is also added to .rodata: any attempt to call it on initialization results
in the above error.

Therefore, disable KASAN instrumentation for rodata.o.

Link: https://lkml.kernel.org/r/20201214191413.3164796-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-15 12:13:42 -08:00
..
2020-11-27 10:44:59 -08:00
2020-10-30 14:51:01 -07:00
2020-11-18 16:42:07 -08:00
2020-11-15 10:15:17 -08:00
2020-11-20 10:23:49 -08:00
2020-12-15 12:13:37 -08:00
2020-12-15 12:13:37 -08:00
2020-12-15 12:13:37 -08:00
2020-11-16 15:02:33 -08:00
2020-12-03 10:00:23 +01:00
2020-12-09 09:59:14 -08:00
2020-10-16 12:21:15 -07:00
2020-10-24 10:39:22 -07:00
2020-12-13 10:36:23 -08:00
2020-12-08 08:15:49 +01:00
2020-10-24 10:39:22 -07:00
2020-09-28 12:17:36 +02:00
2020-10-14 15:56:58 -07:00
2020-12-15 12:13:42 -08:00
2020-10-25 11:12:31 -07:00
2020-12-15 12:13:37 -08:00
2020-10-27 19:23:04 +01:00
2020-10-24 10:33:08 -07:00
2020-10-22 12:56:33 -07:00
2020-10-24 10:39:22 -07:00
2020-10-22 12:58:21 -07:00
2020-10-21 11:22:08 -07:00
2020-12-12 12:57:12 -08:00
2020-11-26 22:07:22 +01:00
2020-10-01 22:59:55 +02:00
2020-11-25 10:35:44 -08:00
2020-11-20 16:24:28 -08:00
2020-11-27 14:48:03 -08:00
2020-12-04 17:39:58 +01:00
2020-12-15 12:13:37 -08:00
2020-11-23 15:29:03 -08:00
2020-10-23 11:00:57 -07:00
2020-10-24 10:33:08 -07:00