linux-stable/drivers/misc
Marco Elver aebc7b0d8d list: Introduce CONFIG_LIST_HARDENED
Numerous production kernel configs (see [1, 2]) are choosing to enable
CONFIG_DEBUG_LIST, which is also being recommended by KSPP for hardened
configs [3]. The motivation behind this is that the option can be used
as a security hardening feature (e.g. CVE-2019-2215 and CVE-2019-2025
are mitigated by the option [4]).

The feature has never been designed with performance in mind, yet common
list manipulation is happening across hot paths all over the kernel.

Introduce CONFIG_LIST_HARDENED, which performs list pointer checking
inline, and only upon list corruption calls the reporting slow path.

To generate optimal machine code with CONFIG_LIST_HARDENED:

  1. Elide checking for pointer values which upon dereference would
     result in an immediate access fault (i.e. minimal hardening
     checks).  The trade-off is lower-quality error reports.

  2. Use the __preserve_most function attribute (available with Clang,
     but not yet with GCC) to minimize the code footprint for calling
     the reporting slow path. As a result, function size of callers is
     reduced by avoiding saving registers before calling the rarely
     called reporting slow path.

     Note that all TUs in lib/Makefile already disable function tracing,
     including list_debug.c, and __preserve_most's implied notrace has
     no effect in this case.

  3. Because the inline checks are a subset of the full set of checks in
     __list_*_valid_or_report(), always return false if the inline
     checks failed.  This avoids redundant compare and conditional
     branch right after return from the slow path.

As a side-effect of the checks being inline, if the compiler can prove
some condition to always be true, it can completely elide some checks.

Since DEBUG_LIST is functionally a superset of LIST_HARDENED, the
Kconfig variables are changed to reflect that: DEBUG_LIST selects
LIST_HARDENED, whereas LIST_HARDENED itself has no dependency on
DEBUG_LIST.

Running netperf with CONFIG_LIST_HARDENED (using a Clang compiler with
"preserve_most") shows throughput improvements, in my case of ~7% on
average (up to 20-30% on some test cases).

Link: https://r.android.com/1266735 [1]
Link: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/blob/main/config [2]
Link: https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project/Recommended_Settings [3]
Link: https://googleprojectzero.blogspot.com/2019/11/bad-binder-android-in-wild-exploit.html [4]
Signed-off-by: Marco Elver <elver@google.com>
Link: https://lore.kernel.org/r/20230811151847.1594958-3-elver@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
2023-08-15 14:57:25 -07:00
..
altera-stapl misc: add HAS_IOPORT dependencies 2023-05-29 15:05:00 +01:00
bcm-vk misc: bcm_vk: Remove usage of deprecated functions 2022-09-01 16:29:32 +02:00
c2port driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
cardreader misc: alcor_pci: remove unused alcor functions 2023-03-29 12:20:32 +02:00
cb710
cxl driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
echo
eeprom Char/Misc and other driver subsystem updates for 6.5-rc1 2023-07-03 12:46:47 -07:00
genwqe - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
ibmasm
lis3lv02d misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
lkdtm list: Introduce CONFIG_LIST_HARDENED 2023-08-15 14:57:25 -07:00
mchp_pci1xxxx misc: microchip: pci1xxxx: Convert to immutable irqchip 2023-03-09 18:07:29 +01:00
mei Char/Misc and other driver subsystem updates for 6.5-rc1 2023-07-03 12:46:47 -07:00
ocxl driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
pvpanic
sgi-gru mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
sgi-xp sgi-xp: simplify sysctl registration 2023-03-09 17:32:13 +01:00
ti-st drivers: misc: ti-st: Fix a typo ("unknow") 2023-01-31 13:02:46 +01:00
uacce uacce: vma_close clears q->qfrs when freeing qfrs 2023-05-31 19:00:26 +01:00
vmw_vmci Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
Kconfig misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
Makefile misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
ad525x_dpot-i2c.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
ad525x_dpot-spi.c
ad525x_dpot.c
ad525x_dpot.h
apds990x.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
apds9802als.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
atmel-ssc.c misc: update maintainer email address and description for atmel-ssc 2022-08-03 11:03:03 +02:00
bh1770glc.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
cs5535-mfgpt.c
ds1682.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
dummy-irq.c
dw-xdata-pcie.c
enclosure.c drivers: remove struct module * setting from struct class 2023-03-17 15:16:27 +01:00
fastrpc.c misc: fastrpc: check return value of devm_kasprintf() 2023-06-19 17:13:24 +02:00
gehc-achc.c
hi6421v600-irq.c
hisi_hikey_usb.c
hmc6352.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
hpilo.c Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
hpilo.h
ibmvmc.c ibmvmc: don't open-code file_inode() 2022-09-01 17:42:27 -04:00
ibmvmc.h
ics932s401.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
isl29003.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
isl29020.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
kgdbts.c
lattice-ecp3-config.c
open-dice.c mm: replace vma->vm_flags direct modifications with modifier calls 2023-02-09 16:51:39 -08:00
pch_phub.c
pci_endpoint_test.c misc: pci_endpoint_test: Simplify pci_endpoint_test_msi_irq() 2023-06-23 15:04:15 -05:00
phantom.c driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
qcom-coincell.c
smpro-errmon.c misc: smpro-errmon: Remove the unneeded include <linux/i2c.h> 2023-05-31 19:00:10 +01:00
smpro-misc.c misc: smpro-misc: Add Ampere's Altra SMpro misc driver 2022-11-10 19:03:03 +01:00
sram-exec.c mm: Introduce set_memory_rox() 2022-12-15 10:37:26 -08:00
sram.c misc: sram: Generate unique names for subpools 2023-05-31 20:35:21 +01:00
sram.h misc: sram: Improve and simplify clk handling 2023-03-09 17:31:53 +01:00
tifm_7xx1.c misc: tifm: fix possible memory leak in tifm_7xx1_switch_media() 2022-11-23 19:55:26 +01:00
tifm_core.c driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
tps6594-esm.c misc: tps6594-esm: Add driver for TI TPS6594 ESM 2023-06-15 13:41:53 +02:00
tps6594-pfsm.c misc: tps6594-pfsm: Add driver for TI TPS6594 PFSM 2023-06-15 13:41:53 +02:00
tsl2550.c misc: Switch i2c drivers back to use .probe() 2023-05-29 15:04:52 +01:00
vcpu_stall_detector.c misc: Add a mechanism to detect stalls on guest vCPUs 2022-07-14 16:54:17 +02:00
vmw_balloon.c misc: vmw_balloon: fix memory leak with using debugfs_lookup() 2023-02-08 13:24:22 +01:00
xilinx_sdfec.c misc/xilinx_sdfec: remove redundant _{open, release} function 2023-05-31 18:59:56 +01:00
xilinx_tmr_inject.c drivers: misc: Add Support for TMR Inject IP 2023-01-20 13:10:15 +01:00
xilinx_tmr_manager.c drivers: misc: Add Support for TMR Manager 2023-01-20 13:09:30 +01:00