linux-stable/drivers/misc
Mark Rutland e624efe36e lkdtm: don't move ctors to .rodata
commit 3f618ab332 upstream.

When building with KASAN and LKDTM, clang may implictly generate an
asan.module_ctor function in the LKDTM rodata object. The Makefile moves
the lkdtm_rodata_do_nothing() function into .rodata by renaming the
file's .text section to .rodata, and consequently also moves the ctor
function into .rodata, leading to a boot time crash (splat below) when
the ctor is invoked by do_ctors().

Let's prevent this by marking the function as noinstr rather than
notrace, and renaming the file's .noinstr.text to .rodata. Marking the
function as noinstr will prevent tracing and kprobes, and will inhibit
any undesireable compiler instrumentation.

The ctor function (if any) will be placed in .text and will work
correctly.

Example splat before this patch is applied:

[    0.916359] Unable to handle kernel execute from non-executable memory at virtual address ffffa0006b60f5ac
[    0.922088] Mem abort info:
[    0.922828]   ESR = 0x8600000e
[    0.923635]   EC = 0x21: IABT (current EL), IL = 32 bits
[    0.925036]   SET = 0, FnV = 0
[    0.925838]   EA = 0, S1PTW = 0
[    0.926714] swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000427b3000
[    0.928489] [ffffa0006b60f5ac] pgd=000000023ffff003, p4d=000000023ffff003, pud=000000023fffe003, pmd=0068000042000f01
[    0.931330] Internal error: Oops: 8600000e [#1] PREEMPT SMP
[    0.932806] Modules linked in:
[    0.933617] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.10.0-rc7 #2
[    0.935620] Hardware name: linux,dummy-virt (DT)
[    0.936924] pstate: 40400005 (nZcv daif +PAN -UAO -TCO BTYPE=--)
[    0.938609] pc : asan.module_ctor+0x0/0x14
[    0.939759] lr : do_basic_setup+0x4c/0x70
[    0.940889] sp : ffff27b600177e30
[    0.941815] x29: ffff27b600177e30 x28: 0000000000000000
[    0.943306] x27: 0000000000000000 x26: 0000000000000000
[    0.944803] x25: 0000000000000000 x24: 0000000000000000
[    0.946289] x23: 0000000000000001 x22: 0000000000000000
[    0.947777] x21: ffffa0006bf4a890 x20: ffffa0006befb6c0
[    0.949271] x19: ffffa0006bef9358 x18: 0000000000000068
[    0.950756] x17: fffffffffffffff8 x16: 0000000000000000
[    0.952246] x15: 0000000000000000 x14: 0000000000000000
[    0.953734] x13: 00000000838a16d5 x12: 0000000000000001
[    0.955223] x11: ffff94000da74041 x10: dfffa00000000000
[    0.956715] x9 : 0000000000000000 x8 : ffffa0006b60f5ac
[    0.958199] x7 : f9f9f9f9f9f9f9f9 x6 : 000000000000003f
[    0.959683] x5 : 0000000000000040 x4 : 0000000000000000
[    0.961178] x3 : ffffa0006bdc15a0 x2 : 0000000000000005
[    0.962662] x1 : 00000000000000f9 x0 : ffffa0006bef9350
[    0.964155] Call trace:
[    0.964844]  asan.module_ctor+0x0/0x14
[    0.965895]  kernel_init_freeable+0x158/0x198
[    0.967115]  kernel_init+0x14/0x19c
[    0.968104]  ret_from_fork+0x10/0x30
[    0.969110] Code: 00000003 00000000 00000000 00000000 (00000000)
[    0.970815] ---[ end trace b5339784e20d015c ]---

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Kees Cook <keescook@chromium.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20201207170533.10738-1-mark.rutland@arm.com
Cc: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-02-17 11:02:24 +01:00
..
altera-stapl
c2port misc: c2port: core: Ensure source size does not equal destination size in strncpy() 2020-06-29 18:45:52 +02:00
cardreader misc: rtsx: Add power saving functions and fix driving parameter 2020-09-16 17:30:37 +02:00
cb710 misc: cb710: sgbuf2: Add missing documentation for cb710_sg_dwiter_write_next_block()'s 'data' arg 2020-06-29 18:45:53 +02:00
cxl cxl: Rework error message for incompatible slots 2020-08-25 01:31:32 +10:00
echo char: Replace HTTP links with HTTPS ones 2020-07-23 09:44:15 +02:00
eeprom misc: eeprom: at24: fix NVMEM name with custom AT24 device name 2020-12-04 10:46:36 +01:00
genwqe pci-v5.9-changes 2020-08-07 18:48:15 -07:00
habanalabs habanalabs: disable FW events on device removal 2021-02-07 15:37:17 +01:00
ibmasm misc: ibmasm: dot_command: Demote function headers from kerneldoc 2020-07-01 15:08:03 +02:00
lis3lv02d
lkdtm lkdtm: don't move ctors to .rodata 2021-02-17 11:02:24 +01:00
mei Revert "mei: virtio: virtualization frontend driver" 2020-12-06 10:36:17 +01:00
ocxl powerpc updates for 5.10 2020-10-16 12:21:15 -07:00
sgi-gru x86/platform/uv: Update Copyrights to conform to HPE standards 2020-10-07 09:10:07 +02:00
sgi-xp x86/platform/uv: Update Copyrights to conform to HPE standards 2020-10-07 09:10:07 +02:00
ti-st misc: ti-st: st_kim: Tidy-up bespoke commentry 2020-06-29 18:45:52 +02:00
uacce Char/Misc driver patches for 5.10-rc1 2020-10-15 10:01:51 -07:00
vmw_vmci misc: vmw_vmci: fix kernel info-leak by initializing dbells in vmci_ctx_get_chkpt_doorbells() 2021-01-06 14:56:52 +01:00
ad525x_dpot-i2c.c
ad525x_dpot-spi.c
ad525x_dpot.c docs: misc-devices/pci-endpoint-test.txt: convert to ReST 2020-06-19 14:05:49 -06:00
ad525x_dpot.h
apds990x.c
apds9802als.c
atmel-ssc.c misc: atmel-ssc: lock with mutex instead of spinlock 2020-06-29 19:10:51 +02:00
atmel_tclib.c
bh1770glc.c
cs5535-mfgpt.c
ds1682.c
dummy-irq.c
enclosure.c misc: enclosure: Update enclosure_remove_device() documentation to match reality 2020-07-01 15:05:37 +02:00
fastrpc.c misc: fastrpc: add ioctl for attaching to sensors pd 2020-09-16 17:30:37 +02:00
hisi_hikey_usb.c misc: hisi_hikey_usb: delete a stray tab 2020-09-22 18:54:00 +02:00
hmc6352.c
hpilo.c misc: hpilo: avoid a useless memset 2020-07-23 12:56:49 +02:00
hpilo.h hpilo: Replace one-element array with flexible-array member 2020-07-14 18:21:25 +02:00
ibmvmc.c mm, treewide: rename kzfree() to kfree_sensitive() 2020-08-07 11:33:22 -07:00
ibmvmc.h
ics932s401.c
isl29003.c
isl29020.c
Kconfig misc: mic: remove the MIC drivers 2020-10-28 19:12:03 +01:00
kgdbts.c kgdbts: switch to kernel_clone() 2020-08-20 13:12:59 +02:00
lattice-ecp3-config.c misc: lattice-ecp3-config: Remove set but clearly unused variable 'ret' 2020-07-01 15:05:37 +02:00
Makefile misc: mic: remove the MIC drivers 2020-10-28 19:12:03 +01:00
pch_phub.c misc: pch_phub: Remove superfluous descriptions to non-existent args 'offset_address' 2020-07-01 15:05:37 +02:00
pci_endpoint_test.c misc: pci_endpoint_test: fix return value of error branch 2020-12-30 11:53:45 +01:00
phantom.c misc/phantom.c: use generic power management 2020-06-29 18:43:42 +02:00
pti.c misc: pti: Remove unparsable empty line in function header 2020-07-01 15:05:36 +02:00
pvpanic.c misc: pvpanic: Use devm_platform_ioremap_resource() 2020-09-22 18:53:30 +02:00
qcom-coincell.c
sram-exec.c char: Replace HTTP links with HTTPS ones 2020-07-23 09:44:15 +02:00
sram.c
sram.h
tifm_7xx1.c misc/tifm_7xx1.c: use generic power management 2020-06-29 18:43:42 +02:00
tifm_core.c
tsl2550.c
vmw_balloon.c
xilinx_sdfec.c misc: xilinx-sdfec: convert get_user_pages() --> pin_user_pages() 2020-05-27 11:09:26 +02:00