* [PATCH -v2 0/7] module: Strict per-modname namespaces
@ 2024-12-02 14:59 Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 1/7] module: Convert symbol namespace to string literal Peter Zijlstra
` (9 more replies)
0 siblings, 10 replies; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
Hi!
Implement a means for exports to be available only to an explicit list of named
modules. By explicitly limiting the usage of certain exports, the abuse
potential/risk is greatly reduced.
The first 'patch' is an awk scripts that cleans up the existing module
namespace code along the same lines of commit 33def8498fdd ("treewide: Convert
macro and uses of __section(foo) to __section("foo")") and for the same reason,
it is not desired for the namespace argument to be a macro expansion itself.
The remainder of the patches introduce the special "MODULE_<modname-list>"
namespace, which shall be forbidden from being explicitly imported. A module
that matches the simple modname-list will get an implicit import.
Lightly tested with something like:
git grep -l EXPORT_SYMBOL arch/x86/kvm/ | while read file;
do
sed -i -e 's/EXPORT_SYMBOL_GPL(\(.[^)]*\))/EXPORT_SYMBOL_GPL_FOR(\1, "kvm,kvm-intel,kvm-amd")/g' $file;
done
With that, some configs generate:
ERROR: modpost: module kvmgt uses symbol kvm_write_track_add_gfn from namespace MODULE_kvm,kvm-intel,kvm-amd, but does not import it.
ERROR: modpost: module kvmgt uses symbol kvm_write_track_remove_gfn from namespace MODULE_kvm,kvm-intel,kvm-amd, but does not import it.
ERROR: modpost: module kvmgt uses symbol kvm_page_track_register_notifier from namespace MODULE_kvm,kvm-intel,kvm-amd, but does not import it.
ERROR: modpost: module kvmgt uses symbol kvm_page_track_unregister_notifier from namespace MODULE_kvm,kvm-intel,kvm-amd, but does not import it.
Showing it works :-). Also verified that once booted, the module kvm_intel does
actually load.
Also available at:
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git module/namespace
Changes since RFC/v1:
- use awk instead of sed so all changes are a single script (hch)
- deal with kbuild mangling the module names like s/-/_/g (sean)
- fixup clang-ias 'funnies'
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2024-12-02 15:15 ` Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 2/7] module/modpost: Use for() loop Peter Zijlstra
` (8 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Clean up the existing export namespace code along the same lines of
33def8498fdd ("treewide: Convert macro and uses of __section(foo) to
__section("foo")") and for the same reason, it is not desired for the
namespace argument to be a macro expansion itself.
git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
do
awk -i inplace '
/^#define EXPORT_SYMBOL_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/^#define MODULE_IMPORT_NS/ {
gsub(/__stringify\(ns\)/, "ns");
print;
next;
}
/MODULE_IMPORT_NS/ {
$0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
}
/EXPORT_SYMBOL_NS/ {
if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
$0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
$0 !~ /^my/) {
getline line;
gsub(/[[:space:]]*\\$/, "");
gsub(/[[:space:]]/, "", line);
$0 = $0 " " line;
}
$0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
"\\1(\\2, \"\\3\")", "g");
}
}
{ print }' $file;
done
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
Documentation/core-api/symbol-namespaces.rst | 8 -
Documentation/translations/it_IT/core-api/symbol-namespaces.rst | 8 -
Documentation/translations/zh_CN/core-api/symbol-namespaces.rst | 8 -
arch/arm64/crypto/aes-ce-ccm-glue.c | 2
arch/arm64/crypto/aes-glue.c | 2
arch/powerpc/crypto/vmx.c | 2
arch/s390/crypto/aes_s390.c | 2
arch/x86/mm/pat/set_memory.c | 4
crypto/adiantum.c | 2
crypto/ansi_cprng.c | 2
crypto/ccm.c | 2
crypto/cipher.c | 6
crypto/cmac.c | 2
crypto/ctr.c | 2
crypto/drbg.c | 2
crypto/ecb.c | 2
crypto/essiv.c | 2
crypto/hctr2.c | 2
crypto/keywrap.c | 2
crypto/pcbc.c | 2
crypto/skcipher.c | 2
crypto/testmgr.c | 2
crypto/vmac.c | 2
crypto/xcbc.c | 2
crypto/xctr.c | 2
crypto/xts.c | 2
drivers/accel/habanalabs/common/memory.c | 2
drivers/accel/qaic/qaic_drv.c | 2
drivers/acpi/apei/einj-cxl.c | 8 -
drivers/acpi/apei/ghes.c | 6
drivers/acpi/numa/hmat.c | 2
drivers/acpi/thermal.c | 2
drivers/acpi/thermal_lib.c | 8 -
drivers/auxdisplay/ht16k33.c | 2
drivers/auxdisplay/img-ascii-lcd.c | 2
drivers/auxdisplay/line-display.c | 4
drivers/auxdisplay/max6959.c | 2
drivers/auxdisplay/seg-led-gpio.c | 2
drivers/base/firmware_loader/builtin/main.c | 2
drivers/base/firmware_loader/fallback_table.c | 6
drivers/base/firmware_loader/sysfs.h | 2
drivers/cdx/cdx.c | 8 -
drivers/cdx/cdx_msi.c | 2
drivers/cdx/controller/cdx_controller.c | 2
drivers/clk/meson/a1-peripherals.c | 2
drivers/clk/meson/a1-pll.c | 2
drivers/clk/meson/axg-aoclk.c | 2
drivers/clk/meson/axg-audio.c | 2
drivers/clk/meson/axg.c | 2
drivers/clk/meson/c3-peripherals.c | 2
drivers/clk/meson/c3-pll.c | 2
drivers/clk/meson/clk-cpu-dyndiv.c | 4
drivers/clk/meson/clk-dualdiv.c | 6
drivers/clk/meson/clk-mpll.c | 6
drivers/clk/meson/clk-phase.c | 8 -
drivers/clk/meson/clk-pll.c | 8 -
drivers/clk/meson/clk-regmap.c | 14 -
drivers/clk/meson/g12a-aoclk.c | 2
drivers/clk/meson/g12a.c | 2
drivers/clk/meson/gxbb-aoclk.c | 2
drivers/clk/meson/gxbb.c | 2
drivers/clk/meson/meson-aoclk.c | 4
drivers/clk/meson/meson-clkc-utils.c | 4
drivers/clk/meson/meson-eeclk.c | 4
drivers/clk/meson/s4-peripherals.c | 2
drivers/clk/meson/s4-pll.c | 2
drivers/clk/meson/sclk-div.c | 4
drivers/clk/meson/vclk.c | 6
drivers/clk/meson/vid-pll-div.c | 4
drivers/clk/microchip/clk-mpfs.c | 2
drivers/clk/sunxi-ng/ccu-sun20i-d1-r.c | 2
drivers/clk/sunxi-ng/ccu-sun20i-d1.c | 2
drivers/clk/sunxi-ng/ccu-sun4i-a10.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-a100-r.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-a100.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-h6-r.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 2
drivers/clk/sunxi-ng/ccu-sun50i-h616.c | 2
drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 2
drivers/clk/sunxi-ng/ccu-sun6i-rtc.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-a23.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-a33.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-a83t.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-de2.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-h3.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-r.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-r40.c | 2
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2
drivers/clk/sunxi-ng/ccu-sun9i-a80-de.c | 2
drivers/clk/sunxi-ng/ccu-sun9i-a80-usb.c | 2
drivers/clk/sunxi-ng/ccu-sun9i-a80.c | 2
drivers/clk/sunxi-ng/ccu-suniv-f1c100s.c | 2
drivers/clk/sunxi-ng/ccu_common.c | 8 -
drivers/clk/sunxi-ng/ccu_div.c | 2
drivers/clk/sunxi-ng/ccu_frac.c | 12 -
drivers/clk/sunxi-ng/ccu_gate.c | 8 -
drivers/clk/sunxi-ng/ccu_mp.c | 4
drivers/clk/sunxi-ng/ccu_mult.c | 2
drivers/clk/sunxi-ng/ccu_mux.c | 12 -
drivers/clk/sunxi-ng/ccu_nk.c | 2
drivers/clk/sunxi-ng/ccu_nkm.c | 2
drivers/clk/sunxi-ng/ccu_nkmp.c | 2
drivers/clk/sunxi-ng/ccu_nm.c | 2
drivers/clk/sunxi-ng/ccu_phase.c | 2
drivers/clk/sunxi-ng/ccu_reset.c | 2
drivers/clk/sunxi-ng/ccu_sdm.c | 12 -
drivers/counter/104-quad-8.c | 2
drivers/counter/counter-chrdev.c | 2
drivers/counter/counter-core.c | 14 -
drivers/counter/ftm-quaddec.c | 2
drivers/counter/i8254.c | 4
drivers/counter/intel-qep.c | 2
drivers/counter/interrupt-cnt.c | 2
drivers/counter/microchip-tcb-capture.c | 2
drivers/counter/rz-mtu3-cnt.c | 2
drivers/counter/stm32-lptimer-cnt.c | 2
drivers/counter/stm32-timer-cnt.c | 2
drivers/counter/ti-ecap-capture.c | 2
drivers/counter/ti-eqep.c | 2
drivers/crypto/geode-aes.c | 2
drivers/crypto/inside-secure/safexcel.c | 2
drivers/crypto/intel/iaa/iaa_crypto_main.c | 2
drivers/crypto/intel/qat/qat_420xx/adf_drv.c | 2
drivers/crypto/intel/qat/qat_4xxx/adf_drv.c | 2
drivers/crypto/intel/qat/qat_c3xxx/adf_drv.c | 2
drivers/crypto/intel/qat/qat_c3xxxvf/adf_drv.c | 2
drivers/crypto/intel/qat/qat_c62x/adf_drv.c | 2
drivers/crypto/intel/qat/qat_c62xvf/adf_drv.c | 2
drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c | 2
drivers/crypto/intel/qat/qat_dh895xcc/adf_drv.c | 2
drivers/crypto/intel/qat/qat_dh895xccvf/adf_drv.c | 2
drivers/crypto/marvell/octeontx2/cn10k_cpt.c | 14 -
drivers/crypto/marvell/octeontx2/otx2_cpt_mbox_common.c | 20 +-
drivers/crypto/marvell/octeontx2/otx2_cptlf.c | 20 +-
drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c | 2
drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c | 2
drivers/cxl/acpi.c | 4
drivers/cxl/core/cdat.c | 6
drivers/cxl/core/hdm.c | 12 -
drivers/cxl/core/mbox.c | 22 +-
drivers/cxl/core/memdev.c | 20 +-
drivers/cxl/core/pci.c | 18 +-
drivers/cxl/core/pmem.c | 14 -
drivers/cxl/core/pmu.c | 2
drivers/cxl/core/port.c | 72 ++++-----
drivers/cxl/core/region.c | 14 -
drivers/cxl/core/regs.c | 22 +-
drivers/cxl/core/suspend.c | 4
drivers/cxl/mem.c | 2
drivers/cxl/pci.c | 2
drivers/cxl/pmem.c | 2
drivers/cxl/port.c | 2
drivers/dax/cxl.c | 2
drivers/dma-buf/dma-buf.c | 42 ++---
drivers/dma/idxd/compat.c | 2
drivers/dma/idxd/device.c | 14 -
drivers/dma/idxd/init.c | 2
drivers/dma/idxd/submit.c | 6
drivers/firmware/cirrus/cs_dsp.c | 68 ++++-----
drivers/firmware/efi/efi-pstore.c | 2
drivers/firmware/efi/embedded-firmware.c | 4
drivers/firmware/efi/vars.c | 16 +-
drivers/fpga/intel-m10-bmc-sec-update.c | 2
drivers/gpio/gpio-104-dio-48e.c | 4
drivers/gpio/gpio-104-idio-16.c | 2
drivers/gpio/gpio-elkhartlake.c | 2
drivers/gpio/gpio-gpio-mm.c | 2
drivers/gpio/gpio-i8255.c | 2
drivers/gpio/gpio-ljca.c | 2
drivers/gpio/gpio-menz127.c | 2
drivers/gpio/gpio-merrifield.c | 2
drivers/gpio/gpio-pci-idio-16.c | 2
drivers/gpio/gpio-tangier.c | 2
drivers/gpio/gpiolib-swnode.c | 2
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2
drivers/gpu/drm/armada/armada_gem.c | 2
drivers/gpu/drm/drm_gem_dma_helper.c | 2
drivers/gpu/drm/drm_gem_framebuffer_helper.c | 2
drivers/gpu/drm/drm_gem_shmem_helper.c | 4
drivers/gpu/drm/drm_prime.c | 2
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c | 2
drivers/gpu/drm/exynos/exynos_drm_gem.c | 2
drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 2
drivers/gpu/drm/i915/gvt/kvmgt.c | 4
drivers/gpu/drm/i915/intel_gvt.c | 74 +++++-----
drivers/gpu/drm/i915/intel_gvt_mmio_table.c | 2
drivers/gpu/drm/imagination/pvr_drv.c | 2
drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c | 2
drivers/gpu/drm/solomon/ssd130x-i2c.c | 2
drivers/gpu/drm/solomon/ssd130x-spi.c | 2
drivers/gpu/drm/solomon/ssd130x.c | 2
drivers/gpu/drm/tegra/gem.c | 2
drivers/gpu/drm/vmwgfx/ttm_object.c | 2
drivers/gpu/drm/xe/tests/xe_live_test_mod.c | 2
drivers/gpu/drm/xe/tests/xe_test_mod.c | 2
drivers/gpu/drm/xe/xe_dma_buf.c | 2
drivers/hid/hid-uclogic-rdesc-test.c | 2
drivers/hwmon/hwmon.c | 2
drivers/hwmon/intel-m10-bmc-hwmon.c | 2
drivers/hwmon/nct6775-i2c.c | 2
drivers/hwmon/nct6775-platform.c | 2
drivers/hwmon/peci/cputemp.c | 2
drivers/hwmon/peci/dimmtemp.c | 2
drivers/hwmon/pmbus/acbel-fsg032.c | 2
drivers/hwmon/pmbus/adm1266.c | 2
drivers/hwmon/pmbus/adm1275.c | 2
drivers/hwmon/pmbus/adp1050.c | 2
drivers/hwmon/pmbus/bel-pfe.c | 2
drivers/hwmon/pmbus/bpa-rs600.c | 2
drivers/hwmon/pmbus/delta-ahe50dc-fan.c | 2
drivers/hwmon/pmbus/dps920ab.c | 2
drivers/hwmon/pmbus/fsp-3y.c | 2
drivers/hwmon/pmbus/ibm-cffps.c | 2
drivers/hwmon/pmbus/inspur-ipsps.c | 2
drivers/hwmon/pmbus/ir35221.c | 2
drivers/hwmon/pmbus/ir36021.c | 2
drivers/hwmon/pmbus/ir38064.c | 2
drivers/hwmon/pmbus/irps5401.c | 2
drivers/hwmon/pmbus/isl68137.c | 2
drivers/hwmon/pmbus/lm25066.c | 2
drivers/hwmon/pmbus/lt7182s.c | 2
drivers/hwmon/pmbus/ltc2978.c | 2
drivers/hwmon/pmbus/ltc3815.c | 2
drivers/hwmon/pmbus/max15301.c | 2
drivers/hwmon/pmbus/max16064.c | 2
drivers/hwmon/pmbus/max16601.c | 2
drivers/hwmon/pmbus/max20730.c | 2
drivers/hwmon/pmbus/max20751.c | 2
drivers/hwmon/pmbus/max31785.c | 2
drivers/hwmon/pmbus/max34440.c | 2
drivers/hwmon/pmbus/max8688.c | 2
drivers/hwmon/pmbus/mp2856.c | 2
drivers/hwmon/pmbus/mp2888.c | 2
drivers/hwmon/pmbus/mp2891.c | 2
drivers/hwmon/pmbus/mp2975.c | 2
drivers/hwmon/pmbus/mp2993.c | 2
drivers/hwmon/pmbus/mp5023.c | 2
drivers/hwmon/pmbus/mp5920.c | 2
drivers/hwmon/pmbus/mp5990.c | 2
drivers/hwmon/pmbus/mp9941.c | 2
drivers/hwmon/pmbus/mpq7932.c | 2
drivers/hwmon/pmbus/mpq8785.c | 2
drivers/hwmon/pmbus/pim4328.c | 2
drivers/hwmon/pmbus/pli1209bc.c | 2
drivers/hwmon/pmbus/pm6764tr.c | 2
drivers/hwmon/pmbus/pmbus.c | 2
drivers/hwmon/pmbus/pmbus_core.c | 42 ++---
drivers/hwmon/pmbus/pxe1610.c | 2
drivers/hwmon/pmbus/q54sj108a2.c | 2
drivers/hwmon/pmbus/stpddc60.c | 2
drivers/hwmon/pmbus/tda38640.c | 2
drivers/hwmon/pmbus/tps40422.c | 2
drivers/hwmon/pmbus/tps53679.c | 2
drivers/hwmon/pmbus/tps546d24.c | 2
drivers/hwmon/pmbus/ucd9000.c | 2
drivers/hwmon/pmbus/ucd9200.c | 2
drivers/hwmon/pmbus/xdp710.c | 2
drivers/hwmon/pmbus/xdpe12284.c | 2
drivers/hwmon/pmbus/xdpe152c4.c | 2
drivers/hwmon/pmbus/zl6100.c | 2
drivers/i2c/busses/i2c-amd-asf-plat.c | 2
drivers/i2c/busses/i2c-designware-master.c | 2
drivers/i2c/busses/i2c-designware-pcidrv.c | 4
drivers/i2c/busses/i2c-designware-platdrv.c | 4
drivers/i2c/busses/i2c-designware-slave.c | 2
drivers/i2c/busses/i2c-ljca.c | 2
drivers/i2c/busses/i2c-piix4.c | 8 -
drivers/i2c/i2c-atr.c | 12 -
drivers/i2c/i2c-core-of-prober.c | 10 -
drivers/iio/accel/adis16201.c | 2
drivers/iio/accel/adis16209.c | 2
drivers/iio/accel/adxl313_core.c | 16 +-
drivers/iio/accel/adxl313_i2c.c | 2
drivers/iio/accel/adxl313_spi.c | 2
drivers/iio/accel/adxl345_core.c | 2
drivers/iio/accel/adxl345_i2c.c | 2
drivers/iio/accel/adxl345_spi.c | 2
drivers/iio/accel/adxl355_core.c | 8 -
drivers/iio/accel/adxl355_i2c.c | 2
drivers/iio/accel/adxl355_spi.c | 2
drivers/iio/accel/adxl367.c | 2
drivers/iio/accel/adxl367_i2c.c | 2
drivers/iio/accel/adxl367_spi.c | 2
drivers/iio/accel/adxl372.c | 4
drivers/iio/accel/adxl372_i2c.c | 2
drivers/iio/accel/adxl372_spi.c | 2
drivers/iio/accel/adxl380.c | 8 -
drivers/iio/accel/adxl380_i2c.c | 2
drivers/iio/accel/adxl380_spi.c | 2
drivers/iio/accel/bma400_core.c | 4
drivers/iio/accel/bma400_i2c.c | 2
drivers/iio/accel/bma400_spi.c | 2
drivers/iio/accel/bmc150-accel-core.c | 8 -
drivers/iio/accel/bmc150-accel-i2c.c | 2
drivers/iio/accel/bmc150-accel-spi.c | 2
drivers/iio/accel/bmi088-accel-core.c | 6
drivers/iio/accel/bmi088-accel-i2c.c | 2
drivers/iio/accel/bmi088-accel-spi.c | 2
drivers/iio/accel/fxls8962af-core.c | 6
drivers/iio/accel/fxls8962af-i2c.c | 2
drivers/iio/accel/fxls8962af-spi.c | 2
drivers/iio/accel/hid-sensor-accel-3d.c | 2
drivers/iio/accel/kionix-kx022a-i2c.c | 2
drivers/iio/accel/kionix-kx022a-spi.c | 2
drivers/iio/accel/kionix-kx022a.c | 8 -
drivers/iio/accel/kxsd9-i2c.c | 2
drivers/iio/accel/kxsd9-spi.c | 2
drivers/iio/accel/kxsd9.c | 4
drivers/iio/accel/mma7455_core.c | 6
drivers/iio/accel/mma7455_i2c.c | 2
drivers/iio/accel/mma7455_spi.c | 2
drivers/iio/accel/mma9551.c | 2
drivers/iio/accel/mma9551_core.c | 36 ++--
drivers/iio/accel/mma9553.c | 2
drivers/iio/accel/ssp_accel_sensor.c | 2
drivers/iio/accel/st_accel_core.c | 6
drivers/iio/accel/st_accel_i2c.c | 2
drivers/iio/accel/st_accel_spi.c | 2
drivers/iio/adc/ad7091r-base.c | 8 -
drivers/iio/adc/ad7091r5.c | 2
drivers/iio/adc/ad7091r8.c | 2
drivers/iio/adc/ad7124.c | 2
drivers/iio/adc/ad7173.c | 2
drivers/iio/adc/ad7192.c | 2
drivers/iio/adc/ad7606.c | 28 +--
drivers/iio/adc/ad7606_par.c | 4
drivers/iio/adc/ad7606_spi.c | 2
drivers/iio/adc/ad7625.c | 2
drivers/iio/adc/ad7780.c | 2
drivers/iio/adc/ad7791.c | 2
drivers/iio/adc/ad7793.c | 2
drivers/iio/adc/ad9467.c | 2
drivers/iio/adc/ad_sigma_delta.c | 20 +-
drivers/iio/adc/adi-axi-adc.c | 4
drivers/iio/adc/ltc2497-core.c | 4
drivers/iio/adc/ltc2497.h | 2
drivers/iio/adc/max11205.c | 2
drivers/iio/adc/men_z188_adc.c | 2
drivers/iio/adc/sd_adc_modulator.c | 2
drivers/iio/adc/stm32-dfsdm-adc.c | 2
drivers/iio/addac/stx104.c | 2
drivers/iio/afe/iio-rescale.c | 4
drivers/iio/buffer/industrialio-buffer-dma.c | 36 ++--
drivers/iio/buffer/industrialio-buffer-dmaengine.c | 8 -
drivers/iio/chemical/bme680_core.c | 4
drivers/iio/chemical/bme680_i2c.c | 2
drivers/iio/chemical/bme680_spi.c | 2
drivers/iio/chemical/ens160_core.c | 2
drivers/iio/chemical/ens160_i2c.c | 2
drivers/iio/chemical/ens160_spi.c | 2
drivers/iio/chemical/scd30_core.c | 2
drivers/iio/chemical/scd30_i2c.c | 2
drivers/iio/chemical/scd30_serial.c | 2
drivers/iio/chemical/sps30.c | 2
drivers/iio/chemical/sps30_i2c.c | 2
drivers/iio/chemical/sps30_serial.c | 2
drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 26 +--
drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 10 -
drivers/iio/common/inv_sensors/inv_sensors_timestamp.c | 8 -
drivers/iio/common/ms_sensors/ms_sensors_i2c.c | 24 +--
drivers/iio/common/ssp_sensors/ssp_dev.c | 10 -
drivers/iio/common/ssp_sensors/ssp_iio.c | 8 -
drivers/iio/common/st_sensors/st_sensors_buffer.c | 2
drivers/iio/common/st_sensors/st_sensors_core.c | 28 +--
drivers/iio/common/st_sensors/st_sensors_i2c.c | 2
drivers/iio/common/st_sensors/st_sensors_spi.c | 2
drivers/iio/common/st_sensors/st_sensors_trigger.c | 4
drivers/iio/dac/ad3552r-common.c | 16 +-
drivers/iio/dac/ad3552r-hs.c | 4
drivers/iio/dac/ad3552r.c | 2
drivers/iio/dac/ad5592r-base.c | 4
drivers/iio/dac/ad5592r.c | 2
drivers/iio/dac/ad5593r.c | 2
drivers/iio/dac/ad5686-spi.c | 2
drivers/iio/dac/ad5686.c | 4
drivers/iio/dac/ad5696-i2c.c | 2
drivers/iio/dac/ad8460.c | 2
drivers/iio/dac/ad9739a.c | 2
drivers/iio/dac/adi-axi-dac.c | 4
drivers/iio/gyro/adis16136.c | 2
drivers/iio/gyro/adis16260.c | 2
drivers/iio/gyro/fxas21002c_core.c | 4
drivers/iio/gyro/fxas21002c_i2c.c | 2
drivers/iio/gyro/fxas21002c_spi.c | 2
drivers/iio/gyro/hid-sensor-gyro-3d.c | 2
drivers/iio/gyro/ssp_gyro_sensor.c | 2
drivers/iio/gyro/st_gyro_core.c | 6
drivers/iio/gyro/st_gyro_i2c.c | 2
drivers/iio/gyro/st_gyro_spi.c | 2
drivers/iio/humidity/hid-sensor-humidity.c | 2
drivers/iio/humidity/hts221_core.c | 2
drivers/iio/humidity/hts221_i2c.c | 2
drivers/iio/humidity/hts221_spi.c | 2
drivers/iio/humidity/htu21.c | 2
drivers/iio/imu/adis.c | 20 +-
drivers/iio/imu/adis16400.c | 2
drivers/iio/imu/adis16460.c | 2
drivers/iio/imu/adis16475.c | 2
drivers/iio/imu/adis16480.c | 2
drivers/iio/imu/adis_buffer.c | 4
drivers/iio/imu/adis_trigger.c | 2
drivers/iio/imu/bmi160/bmi160_core.c | 6
drivers/iio/imu/bmi160/bmi160_i2c.c | 2
drivers/iio/imu/bmi160/bmi160_spi.c | 2
drivers/iio/imu/bmi270/bmi270_core.c | 6
drivers/iio/imu/bmi270/bmi270_i2c.c | 2
drivers/iio/imu/bmi270/bmi270_spi.c | 2
drivers/iio/imu/bmi323/bmi323_core.c | 4
drivers/iio/imu/bmi323/bmi323_i2c.c | 2
drivers/iio/imu/bmi323/bmi323_spi.c | 2
drivers/iio/imu/bno055/bno055.c | 4
drivers/iio/imu/bno055/bno055_i2c.c | 2
drivers/iio/imu/bno055/bno055_ser_core.c | 2
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 6
drivers/iio/imu/inv_icm42600/inv_icm42600_i2c.c | 2
drivers/iio/imu/inv_icm42600/inv_icm42600_spi.c | 2
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 4
drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c | 2
drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c | 2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 2
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 4
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 2
drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 2
drivers/iio/industrialio-backend.c | 58 +++----
drivers/iio/industrialio-buffer.c | 2
drivers/iio/industrialio-gts-helper.c | 26 +--
drivers/iio/light/apds9306.c | 2
drivers/iio/light/bh1745.c | 2
drivers/iio/light/hid-sensor-als.c | 2
drivers/iio/light/hid-sensor-prox.c | 2
drivers/iio/light/rohm-bu27008.c | 2
drivers/iio/light/rohm-bu27034.c | 2
drivers/iio/light/st_uvis25_core.c | 2
drivers/iio/light/st_uvis25_i2c.c | 2
drivers/iio/light/st_uvis25_spi.c | 2
drivers/iio/magnetometer/bmc150_magn.c | 8 -
drivers/iio/magnetometer/bmc150_magn_i2c.c | 2
drivers/iio/magnetometer/bmc150_magn_spi.c | 2
drivers/iio/magnetometer/hid-sensor-magn-3d.c | 2
drivers/iio/magnetometer/hmc5843_core.c | 4
drivers/iio/magnetometer/hmc5843_i2c.c | 2
drivers/iio/magnetometer/hmc5843_spi.c | 2
drivers/iio/magnetometer/rm3100-core.c | 8 -
drivers/iio/magnetometer/rm3100-i2c.c | 2
drivers/iio/magnetometer/rm3100-spi.c | 2
drivers/iio/magnetometer/st_magn_core.c | 6
drivers/iio/magnetometer/st_magn_i2c.c | 2
drivers/iio/magnetometer/st_magn_spi.c | 2
drivers/iio/orientation/hid-sensor-incl-3d.c | 2
drivers/iio/orientation/hid-sensor-rotation.c | 2
drivers/iio/position/hid-sensor-custom-intel-hinge.c | 2
drivers/iio/pressure/bmp280-core.c | 14 -
drivers/iio/pressure/bmp280-i2c.c | 2
drivers/iio/pressure/bmp280-regmap.c | 10 -
drivers/iio/pressure/bmp280-spi.c | 2
drivers/iio/pressure/hid-sensor-press.c | 2
drivers/iio/pressure/hsc030pa.c | 2
drivers/iio/pressure/hsc030pa_i2c.c | 2
drivers/iio/pressure/hsc030pa_spi.c | 2
drivers/iio/pressure/mpl115.c | 2
drivers/iio/pressure/mpl115_i2c.c | 2
drivers/iio/pressure/mpl115_spi.c | 2
drivers/iio/pressure/mprls0025pa.c | 2
drivers/iio/pressure/mprls0025pa_i2c.c | 2
drivers/iio/pressure/mprls0025pa_spi.c | 2
drivers/iio/pressure/ms5611_core.c | 2
drivers/iio/pressure/ms5611_i2c.c | 2
drivers/iio/pressure/ms5611_spi.c | 2
drivers/iio/pressure/ms5637.c | 2
drivers/iio/pressure/st_pressure_core.c | 6
drivers/iio/pressure/st_pressure_i2c.c | 2
drivers/iio/pressure/st_pressure_spi.c | 2
drivers/iio/pressure/zpa2326.c | 12 -
drivers/iio/pressure/zpa2326_i2c.c | 2
drivers/iio/pressure/zpa2326_spi.c | 2
drivers/iio/proximity/sx9310.c | 2
drivers/iio/proximity/sx9324.c | 2
drivers/iio/proximity/sx9360.c | 2
drivers/iio/proximity/sx_common.c | 10 -
drivers/iio/temperature/hid-sensor-temperature.c | 2
drivers/iio/temperature/tsys01.c | 2
drivers/iio/temperature/tsys02d.c | 2
drivers/iio/test/iio-test-gts.c | 2
drivers/iio/test/iio-test-rescale.c | 2
drivers/infiniband/core/umem_dmabuf.c | 2
drivers/infiniband/hw/mana/device.c | 2
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 2
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c | 2
drivers/iommu/iommu.c | 10 -
drivers/iommu/iommufd/device.c | 32 ++--
drivers/iommu/iommufd/driver.c | 4
drivers/iommu/iommufd/iova_bitmap.c | 8 -
drivers/iommu/iommufd/main.c | 12 -
drivers/iommu/iommufd/vfio_compat.c | 6
drivers/leds/flash/leds-ktd2692.c | 2
drivers/leds/leds-expresswire.c | 12 -
drivers/mcb/mcb-core.c | 28 +--
drivers/mcb/mcb-lpc.c | 2
drivers/mcb/mcb-parse.c | 2
drivers/mcb/mcb-pci.c | 2
drivers/media/common/videobuf2/videobuf2-core.c | 2
drivers/media/common/videobuf2/videobuf2-dma-contig.c | 2
drivers/media/common/videobuf2/videobuf2-dma-sg.c | 2
drivers/media/common/videobuf2/videobuf2-vmalloc.c | 2
drivers/media/i2c/ds90ub913.c | 2
drivers/media/i2c/ds90ub953.c | 2
drivers/media/i2c/ds90ub960.c | 2
drivers/media/pci/intel/ipu-bridge.c | 6
drivers/media/pci/intel/ipu3/ipu3-cio2.c | 2
drivers/media/pci/intel/ipu6/ipu6-buttress.c | 12 -
drivers/media/pci/intel/ipu6/ipu6-cpd.c | 4
drivers/media/pci/intel/ipu6/ipu6-dma.c | 18 +-
drivers/media/pci/intel/ipu6/ipu6-fw-com.c | 18 +-
drivers/media/pci/intel/ipu6/ipu6-isys.c | 4
drivers/media/pci/intel/ipu6/ipu6-mmu.c | 4
drivers/media/pci/intel/ipu6/ipu6.c | 4
drivers/media/pci/intel/ivsc/mei_csi.c | 2
drivers/media/platform/nvidia/tegra-vde/dmabuf-cache.c | 2
drivers/mfd/cs40l50-core.c | 2
drivers/mfd/cs42l43-i2c.c | 2
drivers/mfd/cs42l43-sdw.c | 2
drivers/mfd/cs42l43.c | 12 -
drivers/mfd/intel-lpss-acpi.c | 2
drivers/mfd/intel-lpss-pci.c | 2
drivers/mfd/intel-lpss.c | 4
drivers/mfd/intel-m10-bmc-core.c | 10 -
drivers/mfd/intel-m10-bmc-pmci.c | 2
drivers/mfd/intel-m10-bmc-spi.c | 2
drivers/mfd/ocelot-core.c | 6
drivers/mfd/ocelot-spi.c | 4
drivers/misc/fastrpc.c | 2
drivers/misc/mei/platform-vsc.c | 2
drivers/misc/mei/vsc-fw-loader.c | 2
drivers/misc/mei/vsc-tp.c | 18 +-
drivers/net/dsa/ocelot/ocelot_ext.c | 2
drivers/net/dsa/realtek/realtek-mdio.c | 6
drivers/net/dsa/realtek/realtek-smi.c | 6
drivers/net/dsa/realtek/rtl8365mb.c | 2
drivers/net/dsa/realtek/rtl8366-core.c | 22 +-
drivers/net/dsa/realtek/rtl8366rb.c | 2
drivers/net/dsa/realtek/rtl83xx.c | 16 +-
drivers/net/ethernet/intel/i40e/i40e_main.c | 2
drivers/net/ethernet/intel/iavf/iavf_main.c | 4
drivers/net/ethernet/intel/ice/ice_main.c | 2
drivers/net/ethernet/intel/idpf/idpf_main.c | 2
drivers/net/ethernet/intel/libeth/rx.c | 8 -
drivers/net/ethernet/intel/libie/rx.c | 4
drivers/net/ethernet/microsoft/mana/gdma_main.c | 12 -
drivers/net/ethernet/microsoft/mana/mana_en.c | 10 -
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/module.c | 2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h | 2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/module.c | 2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/module.c | 2
drivers/net/wireless/intel/iwlwifi/dvm/main.c | 2
drivers/net/wireless/intel/iwlwifi/iwl-drv.h | 2
drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 2
drivers/net/wireless/intel/iwlwifi/mvm/tests/links.c | 2
drivers/net/wireless/intel/iwlwifi/mvm/tests/scan.c | 2
drivers/net/wireless/intel/iwlwifi/tests/devinfo.c | 2
drivers/nvdimm/region_devs.c | 2
drivers/nvme/host/core.c | 14 -
drivers/nvme/target/passthru.c | 2
drivers/pci/pcie/aer.c | 4
drivers/peci/controller/peci-aspeed.c | 2
drivers/peci/controller/peci-npcm.c | 2
drivers/peci/core.c | 2
drivers/peci/cpu.c | 12 -
drivers/peci/device.c | 4
drivers/peci/request.c | 30 ++--
drivers/perf/cxl_pmu.c | 2
drivers/pinctrl/intel/pinctrl-alderlake.c | 2
drivers/pinctrl/intel/pinctrl-baytrail.c | 2
drivers/pinctrl/intel/pinctrl-broxton.c | 2
drivers/pinctrl/intel/pinctrl-cannonlake.c | 2
drivers/pinctrl/intel/pinctrl-cedarfork.c | 2
drivers/pinctrl/intel/pinctrl-cherryview.c | 2
drivers/pinctrl/intel/pinctrl-denverton.c | 2
drivers/pinctrl/intel/pinctrl-elkhartlake.c | 2
drivers/pinctrl/intel/pinctrl-emmitsburg.c | 2
drivers/pinctrl/intel/pinctrl-geminilake.c | 2
drivers/pinctrl/intel/pinctrl-icelake.c | 2
drivers/pinctrl/intel/pinctrl-intel-platform.c | 2
drivers/pinctrl/intel/pinctrl-intel.c | 22 +-
drivers/pinctrl/intel/pinctrl-jasperlake.c | 2
drivers/pinctrl/intel/pinctrl-lakefield.c | 2
drivers/pinctrl/intel/pinctrl-lewisburg.c | 2
drivers/pinctrl/intel/pinctrl-lynxpoint.c | 2
drivers/pinctrl/intel/pinctrl-merrifield.c | 2
drivers/pinctrl/intel/pinctrl-meteorlake.c | 2
drivers/pinctrl/intel/pinctrl-meteorpoint.c | 2
drivers/pinctrl/intel/pinctrl-moorefield.c | 2
drivers/pinctrl/intel/pinctrl-sunrisepoint.c | 2
drivers/pinctrl/intel/pinctrl-tangier.c | 2
drivers/pinctrl/intel/pinctrl-tigerlake.c | 2
drivers/platform/chrome/chromeos_of_hw_prober.c | 2
drivers/platform/x86/amd/hsmp/acpi.c | 2
drivers/platform/x86/amd/hsmp/hsmp.c | 16 +-
drivers/platform/x86/amd/hsmp/plat.c | 2
drivers/platform/x86/ideapad-laptop.c | 6
drivers/platform/x86/intel/plr_tpmi.c | 4
drivers/platform/x86/intel/pmc/core_ssram.c | 4
drivers/platform/x86/intel/pmt/class.c | 8 -
drivers/platform/x86/intel/pmt/crashlog.c | 2
drivers/platform/x86/intel/pmt/telemetry.c | 16 +-
drivers/platform/x86/intel/speed_select_if/isst_tpmi.c | 2
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 16 +-
drivers/platform/x86/intel/tpmi_power_domains.c | 8 -
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c | 8 -
drivers/platform/x86/intel/uncore-frequency/uncore-frequency-tpmi.c | 4
drivers/platform/x86/intel/uncore-frequency/uncore-frequency.c | 2
drivers/platform/x86/intel/vsec.c | 4
drivers/platform/x86/intel/vsec_tpmi.c | 12 -
drivers/platform/x86/lenovo-ymc.c | 2
drivers/powercap/idle_inject.c | 16 +-
drivers/powercap/intel_rapl_tpmi.c | 2
drivers/pwm/pwm-dwc.h | 2
drivers/pwm/pwm-lpss-pci.c | 2
drivers/pwm/pwm-lpss-platform.c | 2
drivers/reset/amlogic/reset-meson-aux.c | 2
drivers/reset/amlogic/reset-meson-common.c | 8 -
drivers/reset/amlogic/reset-meson.c | 2
drivers/reset/reset-mpfs.c | 4
drivers/rtc/rtc-hid-sensor-time.c | 2
drivers/soundwire/amd_init.c | 6
drivers/soundwire/intel.c | 2
drivers/soundwire/intel_ace2x.c | 4
drivers/soundwire/intel_init.c | 10 -
drivers/soundwire/slave.c | 2
drivers/spi/spi-cs42l43.c | 2
drivers/spi/spi-dw-bt1.c | 2
drivers/spi/spi-dw-core.c | 14 -
drivers/spi/spi-dw-dma.c | 4
drivers/spi/spi-dw-mmio.c | 2
drivers/spi/spi-dw-pci.c | 2
drivers/spi/spi-ljca.c | 2
drivers/spi/spi-loongson-core.c | 4
drivers/spi/spi-loongson-pci.c | 2
drivers/spi/spi-loongson-plat.c | 2
drivers/spi/spi-pxa2xx-pci.c | 2
drivers/spi/spi-pxa2xx-platform.c | 2
drivers/spi/spi-pxa2xx.c | 4
drivers/staging/iio/accel/adis16203.c | 2
drivers/staging/iio/accel/adis16240.c | 2
drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2
drivers/thermal/intel/int340x_thermal/processor_thermal_device.c | 4
drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c | 2
drivers/thermal/intel/int340x_thermal/processor_thermal_mbox.c | 6
drivers/thermal/intel/int340x_thermal/processor_thermal_power_floor.c | 12 -
drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c | 2
drivers/thermal/intel/int340x_thermal/processor_thermal_wt_hint.c | 10 -
drivers/thermal/intel/int340x_thermal/processor_thermal_wt_req.c | 2
drivers/thermal/intel/intel_powerclamp.c | 2
drivers/thermal/intel/intel_soc_dts_iosf.c | 2
drivers/thermal/intel/intel_tcc.c | 10 -
drivers/thermal/intel/intel_tcc_cooling.c | 2
drivers/thermal/intel/x86_pkg_temp_thermal.c | 2
drivers/thermal/thermal_hwmon.c | 2
drivers/tty/serial/8250/8250_exar.c | 2
drivers/tty/serial/8250/8250_men_mcb.c | 2
drivers/tty/serial/8250/8250_pci.c | 2
drivers/tty/serial/8250/8250_pci1xxxx.c | 2
drivers/tty/serial/8250/8250_pcilib.c | 4
drivers/tty/serial/men_z135_uart.c | 2
drivers/tty/serial/sc16is7xx_i2c.c | 2
drivers/tty/serial/sc16is7xx_spi.c | 2
drivers/usb/gadget/function/f_fs.c | 2
drivers/usb/host/xhci-pci-renesas.c | 2
drivers/usb/host/xhci-pci.c | 4
drivers/usb/misc/usb-ljca.c | 8 -
drivers/usb/storage/alauda.c | 2
drivers/usb/storage/cypress_atacb.c | 2
drivers/usb/storage/datafab.c | 2
drivers/usb/storage/ene_ub6250.c | 2
drivers/usb/storage/freecom.c | 2
drivers/usb/storage/isd200.c | 2
drivers/usb/storage/jumpshot.c | 2
drivers/usb/storage/karma.c | 2
drivers/usb/storage/onetouch.c | 2
drivers/usb/storage/realtek_cr.c | 2
drivers/usb/storage/sddr09.c | 2
drivers/usb/storage/sddr55.c | 2
drivers/usb/storage/shuttle_usbat.c | 2
drivers/usb/storage/uas.c | 2
drivers/vfio/cdx/main.c | 2
drivers/vfio/iommufd.c | 4
drivers/vfio/pci/mlx5/main.c | 2
drivers/vfio/pci/pds/pci_drv.c | 2
drivers/vfio/pci/qat/main.c | 2
drivers/vfio/vfio_main.c | 2
drivers/video/backlight/ktd2801-backlight.c | 2
drivers/virtio/virtio_dma_buf.c | 2
drivers/watchdog/menz69_wdt.c | 2
drivers/xen/gntdev-dmabuf.c | 2
fs/efivarfs/vars.c | 2
include/kunit/visibility.h | 5
include/linux/acpi.h | 2
include/linux/export.h | 4
include/linux/fw_table.h | 2
include/linux/module.h | 2
include/linux/pm.h | 2
include/linux/pwm.h | 2
kernel/module/Kconfig | 2
kernel/resource.c | 2
lib/kunit/user_alloc.c | 2
lib/test_firmware.c | 2
mm/kasan/kasan_test_c.c | 2
net/handshake/handshake-test.c | 2
net/mac80211/tests/elems.c | 2
net/mac80211/tests/mfp.c | 2
net/mac80211/tests/tpe.c | 2
net/sunrpc/auth_gss/gss_krb5_test.c | 2
net/wireless/tests/chan.c | 2
net/wireless/tests/scan.c | 2
samples/vfio-mdev/mbochs.c | 2
scripts/coccinelle/misc/add_namespace.cocci | 4
security/apparmor/policy_unpack_test.c | 2
sound/hda/intel-dsp-config.c | 2
sound/hda/intel-sdw-acpi.c | 2
sound/pci/hda/cirrus_scodec.c | 2
sound/pci/hda/cirrus_scodec_test.c | 2
sound/pci/hda/cs35l41_hda.c | 12 -
sound/pci/hda/cs35l41_hda_i2c.c | 2
sound/pci/hda/cs35l41_hda_spi.c | 2
sound/pci/hda/cs35l56_hda.c | 16 +-
sound/pci/hda/cs35l56_hda_i2c.c | 4
sound/pci/hda/cs35l56_hda_spi.c | 4
sound/pci/hda/hda_component.c | 14 -
sound/pci/hda/hda_cs_dsp_ctl.c | 12 -
sound/pci/hda/patch_realtek.c | 2
sound/pci/hda/tas2781_hda_i2c.c | 2
sound/soc/amd/acp/acp-i2s.c | 2
sound/soc/amd/acp/acp-legacy-common.c | 18 +-
sound/soc/amd/acp/acp-legacy-mach.c | 2
sound/soc/amd/acp/acp-mach-common.c | 4
sound/soc/amd/acp/acp-pci.c | 2
sound/soc/amd/acp/acp-pdm.c | 2
sound/soc/amd/acp/acp-platform.c | 10 -
sound/soc/amd/acp/acp-rembrandt.c | 2
sound/soc/amd/acp/acp-renoir.c | 2
sound/soc/amd/acp/acp-sdw-legacy-mach.c | 4
sound/soc/amd/acp/acp-sdw-mach-common.c | 2
sound/soc/amd/acp/acp-sdw-sof-mach.c | 4
sound/soc/amd/acp/acp-sof-mach.c | 2
sound/soc/amd/acp/acp63.c | 2
sound/soc/amd/acp/acp70.c | 2
sound/soc/amd/acp/amd-sdw-acpi.c | 2
sound/soc/amd/ps/pci-ps.c | 4
sound/soc/codecs/cs-amp-lib-test.c | 2
sound/soc/codecs/cs-amp-lib.c | 8 -
sound/soc/codecs/cs35l45-i2c.c | 2
sound/soc/codecs/cs35l45-spi.c | 2
sound/soc/codecs/cs35l45-tables.c | 8 -
sound/soc/codecs/cs35l45.c | 4
sound/soc/codecs/cs35l56-i2c.c | 4
sound/soc/codecs/cs35l56-sdw.c | 4
sound/soc/codecs/cs35l56-shared.c | 52 +++----
sound/soc/codecs/cs35l56-spi.c | 4
sound/soc/codecs/cs35l56.c | 10 -
sound/soc/codecs/cs42l42-i2c.c | 2
sound/soc/codecs/cs42l42-sdw.c | 2
sound/soc/codecs/cs42l42.c | 32 ++--
sound/soc/codecs/cs42l43-sdw.c | 6
sound/soc/codecs/cs42l43.c | 2
sound/soc/codecs/cs42l83-i2c.c | 2
sound/soc/codecs/cs530x-i2c.c | 2
sound/soc/codecs/cs530x.c | 4
sound/soc/codecs/rt712-sdca-sdw.c | 2
sound/soc/codecs/tas2781-fmwlib.c | 20 +-
sound/soc/codecs/tas2781-i2c.c | 2
sound/soc/codecs/wm_adsp.c | 2
sound/soc/intel/boards/ehl_rt5660.c | 2
sound/soc/intel/boards/hda_dsp_common.c | 2
sound/soc/intel/boards/skl_hda_dsp_generic.c | 2
sound/soc/intel/boards/sof_board_helpers.c | 10 -
sound/soc/intel/boards/sof_cirrus_common.c | 4
sound/soc/intel/boards/sof_cs42l42.c | 4
sound/soc/intel/boards/sof_da7219.c | 4
sound/soc/intel/boards/sof_es8336.c | 2
sound/soc/intel/boards/sof_maxim_common.c | 12 -
sound/soc/intel/boards/sof_nau8825.c | 8 -
sound/soc/intel/boards/sof_nuvoton_common.c | 2
sound/soc/intel/boards/sof_pcm512x.c | 2
sound/soc/intel/boards/sof_realtek_common.c | 16 +-
sound/soc/intel/boards/sof_rt5682.c | 6
sound/soc/intel/boards/sof_sdw.c | 4
sound/soc/intel/boards/sof_ssp_amp.c | 6
sound/soc/intel/common/soc-acpi-intel-mtl-match.c | 2
sound/soc/intel/common/soc-acpi-intel-sdca-quirks.c | 4
sound/soc/intel/common/soc-acpi-intel-ssp-common.c | 10 -
sound/soc/sdca/sdca_device.c | 4
sound/soc/sdca/sdca_functions.c | 2
sound/soc/sdw_utils/soc_sdw_bridge_cs35l56.c | 6
sound/soc/sdw_utils/soc_sdw_cs42l42.c | 2
sound/soc/sdw_utils/soc_sdw_cs42l43.c | 8 -
sound/soc/sdw_utils/soc_sdw_cs_amp.c | 4
sound/soc/sdw_utils/soc_sdw_dmic.c | 2
sound/soc/sdw_utils/soc_sdw_maxim.c | 4
sound/soc/sdw_utils/soc_sdw_rt5682.c | 2
sound/soc/sdw_utils/soc_sdw_rt700.c | 2
sound/soc/sdw_utils/soc_sdw_rt711.c | 6
sound/soc/sdw_utils/soc_sdw_rt_amp.c | 8 -
sound/soc/sdw_utils/soc_sdw_rt_dmic.c | 2
sound/soc/sdw_utils/soc_sdw_rt_mf_sdca.c | 2
sound/soc/sdw_utils/soc_sdw_rt_sdca_jack_common.c | 6
sound/soc/sdw_utils/soc_sdw_utils.c | 42 ++---
sound/soc/sof/amd/acp-common.c | 8 -
sound/soc/sof/amd/acp-ipc.c | 16 +-
sound/soc/sof/amd/acp-loader.c | 12 -
sound/soc/sof/amd/acp-pcm.c | 8 -
sound/soc/sof/amd/acp-probes.c | 6
sound/soc/sof/amd/acp-stream.c | 6
sound/soc/sof/amd/acp-trace.c | 4
sound/soc/sof/amd/acp.c | 12 -
sound/soc/sof/amd/acp63.c | 2
sound/soc/sof/amd/acp70.c | 2
sound/soc/sof/amd/pci-acp63.c | 4
sound/soc/sof/amd/pci-acp70.c | 4
sound/soc/sof/amd/pci-rmb.c | 4
sound/soc/sof/amd/pci-rn.c | 4
sound/soc/sof/amd/pci-vangogh.c | 4
sound/soc/sof/amd/rembrandt.c | 2
sound/soc/sof/amd/renoir.c | 2
sound/soc/sof/amd/vangogh.c | 2
sound/soc/sof/core.c | 2
sound/soc/sof/imx/imx8.c | 2
sound/soc/sof/imx/imx8m.c | 2
sound/soc/sof/imx/imx8ulp.c | 2
sound/soc/sof/intel/atom.c | 22 +-
sound/soc/sof/intel/bdw.c | 6
sound/soc/sof/intel/byt.c | 8 -
sound/soc/sof/intel/cnl.c | 18 +-
sound/soc/sof/intel/hda-bus.c | 4
sound/soc/sof/intel/hda-codec.c | 32 ++--
sound/soc/sof/intel/hda-common-ops.c | 2
sound/soc/sof/intel/hda-ctrl.c | 16 +-
sound/soc/sof/intel/hda-dai.c | 14 -
sound/soc/sof/intel/hda-dsp.c | 62 ++++----
sound/soc/sof/intel/hda-ipc.c | 34 ++--
sound/soc/sof/intel/hda-loader.c | 16 +-
sound/soc/sof/intel/hda-mlink.c | 68 ++++-----
sound/soc/sof/intel/hda-pcm.c | 12 -
sound/soc/sof/intel/hda-probes.c | 6
sound/soc/sof/intel/hda-stream.c | 18 +-
sound/soc/sof/intel/hda-trace.c | 6
sound/soc/sof/intel/hda.c | 40 ++---
sound/soc/sof/intel/lnl.c | 6
sound/soc/sof/intel/mtl.c | 30 ++--
sound/soc/sof/intel/pci-apl.c | 6
sound/soc/sof/intel/pci-cnl.c | 6
sound/soc/sof/intel/pci-icl.c | 8 -
sound/soc/sof/intel/pci-lnl.c | 10 -
sound/soc/sof/intel/pci-mtl.c | 6
sound/soc/sof/intel/pci-ptl.c | 12 -
sound/soc/sof/intel/pci-skl.c | 6
sound/soc/sof/intel/pci-tgl.c | 8 -
sound/soc/sof/intel/pci-tng.c | 8 -
sound/soc/sof/intel/skl.c | 6
sound/soc/sof/intel/telemetry.c | 2
sound/soc/sof/mediatek/mt8186/mt8186.c | 4
sound/soc/sof/mediatek/mt8195/mt8195.c | 4
sound/soc/sof/sof-acpi-dev.c | 6
sound/soc/sof/sof-client-ipc-flood-test.c | 2
sound/soc/sof/sof-client-ipc-kernel-injector.c | 2
sound/soc/sof/sof-client-ipc-msg-injector.c | 2
sound/soc/sof/sof-client-probes.c | 2
sound/soc/sof/sof-client.c | 40 ++---
sound/soc/sof/sof-pci-dev.c | 8 -
sound/soc/sof/xtensa/core.c | 2
tools/testing/cxl/cxl_core_exports.c | 2
tools/testing/cxl/test/cxl.c | 4
tools/testing/cxl/test/mem.c | 2
tools/testing/cxl/test/mock.c | 28 +--
876 files changed, 2189 insertions(+), 2196 deletions(-)
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 2/7] module/modpost: Use for() loop
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 1/7] module: Convert symbol namespace to string literal Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2025-02-07 8:50 ` Masahiro Yamada
2025-02-07 16:38 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 3/7] module/modpost: Add basename helper Peter Zijlstra
` (7 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
scripts/mod/modpost.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1586,12 +1586,9 @@ static void read_symbols(const char *mod
license = get_next_modinfo(&info, "license", license);
}
- namespace = get_modinfo(&info, "import_ns");
- while (namespace) {
+ for (namespace = get_modinfo(&info, "import_ns"); namespace;
+ namespace = get_next_modinfo(&info, "import_ns", namespace))
add_namespace(&mod->imported_namespaces, namespace);
- namespace = get_next_modinfo(&info, "import_ns",
- namespace);
- }
if (extra_warn && !get_modinfo(&info, "description"))
warn("missing MODULE_DESCRIPTION() in %s\n", modname);
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 3/7] module/modpost: Add basename helper
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 1/7] module: Convert symbol namespace to string literal Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 2/7] module/modpost: Use for() loop Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2025-02-07 17:56 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 4/7] module: Add module specific symbol namespace support Peter Zijlstra
` (6 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
scripts/mod/modpost.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1553,6 +1553,16 @@ static void mod_set_crcs(struct module *
free(buf);
}
+static const char *mod_basename(const char *modname)
+{
+ const char *basename = strrchr(modname, '/');
+ if (basename)
+ basename++;
+ else
+ basename = modname;
+ return basename;
+}
+
static void read_symbols(const char *modname)
{
const char *symname;
@@ -1697,11 +1707,7 @@ static void check_exports(struct module
s->crc_valid = exp->crc_valid;
s->crc = exp->crc;
- basename = strrchr(mod->name, '/');
- if (basename)
- basename++;
- else
- basename = mod->name;
+ basename = mod_basename(mod->name);
if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
modpost_log(!allow_missing_ns_imports,
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 4/7] module: Add module specific symbol namespace support
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (2 preceding siblings ...)
2024-12-02 14:59 ` [PATCH -v2 3/7] module/modpost: Add basename helper Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2025-02-07 16:22 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing Peter Zijlstra
` (5 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Designate the "MODULE_${modname}" symbol namespace to mean: 'only
export to the named module'.
Notably, explicit imports of anything in the "MODULE_" space is
forbidden. Modules implicitly get the "MODULE_${modname}" namespace
added.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/module/main.c | 28 ++++++++++++++++++++++++++--
scripts/mod/modpost.c | 5 +++++
2 files changed, 31 insertions(+), 2 deletions(-)
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1070,6 +1070,13 @@ static int verify_namespace_is_imported(
namespace = kernel_symbol_namespace(sym);
if (namespace && namespace[0]) {
+ /*
+ * Implicitly import MODULE_${mod->name} namespace.
+ */
+ if (strncmp(namespace, "MODULE_", 7) == 0 &&
+ strcmp(namespace+7, mod->name) == 0)
+ return 0;
+
for_each_modinfo_entry(imported_namespace, info, "import_ns") {
if (strcmp(namespace, imported_namespace) == 0)
return 0;
@@ -1613,15 +1620,30 @@ static void module_license_taint_check(s
}
}
-static void setup_modinfo(struct module *mod, struct load_info *info)
+static int setup_modinfo(struct module *mod, struct load_info *info)
{
struct module_attribute *attr;
+ char *imported_namespace;
int i;
for (i = 0; (attr = modinfo_attrs[i]); i++) {
if (attr->setup)
attr->setup(mod, get_modinfo(info, attr->attr.name));
}
+
+ for_each_modinfo_entry(imported_namespace, info, "import_ns") {
+ /*
+ * 'MODULE_' prefixed namespaces are implicit, disallow
+ * explicit imports.
+ */
+ if (strstarts(imported_namespace, "MODULE_")) {
+ pr_err("%s: module tries to import module namespace: %s\n",
+ mod->name, imported_namespace);
+ return -EPERM;
+ }
+ }
+
+ return 0;
}
static void free_modinfo(struct module *mod)
@@ -2935,7 +2957,9 @@ static int load_module(struct load_info
goto free_unload;
/* Set up MODINFO_ATTR fields */
- setup_modinfo(mod, info);
+ err = setup_modinfo(mod, info);
+ if (err)
+ goto free_modinfo;
/* Fix up syms, so that st_value is a pointer to location. */
err = simplify_symbols(mod, info);
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1565,6 +1565,7 @@ static const char *mod_basename(const ch
static void read_symbols(const char *modname)
{
+ char module_namespace[MODULE_NAME_LEN + 8];
const char *symname;
char *version;
char *license;
@@ -1600,6 +1601,10 @@ static void read_symbols(const char *mod
namespace = get_next_modinfo(&info, "import_ns", namespace))
add_namespace(&mod->imported_namespaces, namespace);
+ snprintf(module_namespace, sizeof(module_namespace), "MODULE_%s",
+ mod_basename(mod->name));
+ add_namespace(&mod->imported_namespaces, module_namespace);
+
if (extra_warn && !get_modinfo(&info, "description"))
warn("missing MODULE_DESCRIPTION() in %s\n", modname);
}
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (3 preceding siblings ...)
2024-12-02 14:59 ` [PATCH -v2 4/7] module: Add module specific symbol namespace support Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2025-02-07 8:41 ` Masahiro Yamada
2025-02-07 15:45 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 6/7] module: Account for the build time module name mangling Peter Zijlstra
` (4 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Instead of only accepting "MODULE_${name}", extend it with a comma
separated list of module names and add tail glob support.
That is, something like: "MODULE_foo-*,bar" is now possible.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/module/main.c | 39 ++++++++++++++++++++++++++++++++++-----
scripts/mod/modpost.c | 40 ++++++++++++++++++++++++++++++++++------
2 files changed, 68 insertions(+), 11 deletions(-)
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1061,6 +1061,38 @@ static char *get_modinfo(const struct lo
return get_next_modinfo(info, tag, NULL);
}
+/*
+ * @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
+ */
+static bool verify_module_namespace(const char *namespace, const char *modname)
+{
+ size_t len, modlen = strlen(modname);
+ const char *sep;
+ bool glob;
+
+ if (strncmp(namespace, "MODULE_", 7) != 0)
+ return false;
+
+ for (namespace += 7; *namespace; namespace = sep) {
+ sep = strchrnul(namespace, ',');
+ len = sep - namespace;
+
+ glob = false;
+ if (sep[-1] == '*') {
+ len--;
+ glob = true;
+ }
+
+ if (*sep)
+ sep++;
+
+ if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
+ return true;
+ }
+
+ return false;
+}
+
static int verify_namespace_is_imported(const struct load_info *info,
const struct kernel_symbol *sym,
struct module *mod)
@@ -1070,11 +1102,8 @@ static int verify_namespace_is_imported(
namespace = kernel_symbol_namespace(sym);
if (namespace && namespace[0]) {
- /*
- * Implicitly import MODULE_${mod->name} namespace.
- */
- if (strncmp(namespace, "MODULE_", 7) == 0 &&
- strcmp(namespace+7, mod->name) == 0)
+
+ if (verify_module_namespace(namespace, mod->name))
return 0;
for_each_modinfo_entry(imported_namespace, info, "import_ns") {
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1565,7 +1565,6 @@ static const char *mod_basename(const ch
static void read_symbols(const char *modname)
{
- char module_namespace[MODULE_NAME_LEN + 8];
const char *symname;
char *version;
char *license;
@@ -1601,10 +1600,6 @@ static void read_symbols(const char *mod
namespace = get_next_modinfo(&info, "import_ns", namespace))
add_namespace(&mod->imported_namespaces, namespace);
- snprintf(module_namespace, sizeof(module_namespace), "MODULE_%s",
- mod_basename(mod->name));
- add_namespace(&mod->imported_namespaces, module_namespace);
-
if (extra_warn && !get_modinfo(&info, "description"))
warn("missing MODULE_DESCRIPTION() in %s\n", modname);
}
@@ -1687,6 +1682,38 @@ void buf_write(struct buffer *buf, const
buf->pos += len;
}
+/*
+ * @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
+ */
+static bool module_namespace(const char *namespace, const char *modname)
+{
+ size_t len, modlen = strlen(modname);
+ const char *sep;
+ bool glob;
+
+ if (strncmp(namespace, "MODULE_", 7) != 0)
+ return false;
+
+ for (namespace += 7; *namespace; namespace = sep) {
+ sep = strchrnul(namespace, ',');
+ len = sep - namespace;
+
+ glob = false;
+ if (sep[-1] == '*') {
+ len--;
+ glob = true;
+ }
+
+ if (*sep)
+ sep++;
+
+ if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
+ return true;
+ }
+
+ return false;
+}
+
static void check_exports(struct module *mod)
{
struct symbol *s, *exp;
@@ -1714,7 +1741,8 @@ static void check_exports(struct module
basename = mod_basename(mod->name);
- if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
+ if (!module_namespace(exp->namespace, basename) &&
+ !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
modpost_log(!allow_missing_ns_imports,
"module %s uses symbol %s from namespace %s, but does not import it.\n",
basename, exp->name, exp->namespace);
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 6/7] module: Account for the build time module name mangling
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (4 preceding siblings ...)
2024-12-02 14:59 ` [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2024-12-06 18:35 ` Sean Christopherson
2025-05-02 13:15 ` Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper Peter Zijlstra
` (3 subsequent siblings)
9 siblings, 2 replies; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Sean Christopherson, Peter Zijlstra (Intel)
Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle
the module name with s/-/_/g.
Since this happens late in the build, only the kernel needs to bother
with this, the modpost tool still sees the original name.
Reported-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
kernel/module/main.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -1062,6 +1062,30 @@ static char *get_modinfo(const struct lo
}
/*
+ * Like strncmp(), except s/-/_/g as per scripts/Makefile.lib:name-fix-token rule.
+ */
+static int mod_strncmp(const char *str_a, const char *str_b, size_t n)
+{
+ for (int i = 0; i < n; i++) {
+ char a = str_a[i];
+ char b = str_b[i];
+ int d;
+
+ if (a == '-') a = '_';
+ if (b == '-') b = '_';
+
+ d = a - b;
+ if (d)
+ return d;
+
+ if (!a)
+ break;
+ }
+
+ return 0;
+}
+
+/*
* @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
*/
static bool verify_module_namespace(const char *namespace, const char *modname)
@@ -1086,7 +1110,7 @@ static bool verify_module_namespace(cons
if (*sep)
sep++;
- if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
+ if (mod_strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
return true;
}
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (5 preceding siblings ...)
2024-12-02 14:59 ` [PATCH -v2 6/7] module: Account for the build time module name mangling Peter Zijlstra
@ 2024-12-02 14:59 ` Peter Zijlstra
2025-02-07 8:09 ` Masahiro Yamada
2024-12-02 17:36 ` [PATCH -v2 0/7] module: Strict per-modname namespaces Andi Kleen
` (2 subsequent siblings)
9 siblings, 1 reply; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 14:59 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Peter Zijlstra (Intel)
Requested-by: Masahiro Yamada <masahiroy@kernel.org>
Requested-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/export.h | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,11 +24,23 @@
.long sym
#endif
-#define ___EXPORT_SYMBOL(sym, license, ns) \
+/*
+ * LLVM intregrated assembler refuses to merge adjacent string literals (like
+ * C and GNU-as) and chokes on:
+ *
+ * .asciz "MODULE_" "kvm" ;
+ *
+ * As would be generated when using EXPORT_SYMBOL_GPL_FOR(foo, "kvm"), use
+ * varargs to assemble it like so:
+ *
+ * .ascii "MODULE_", "kvm", "\0" ;
+ *
+ */
+#define ___EXPORT_SYMBOL(sym, license, ns...) \
.section ".export_symbol","a" ASM_NL \
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
- .asciz ns ASM_NL \
+ .ascii ns, "\0" ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous
@@ -39,20 +51,20 @@
* be reused in other execution contexts such as the UEFI stub or the
* decompressor.
*/
-#define __EXPORT_SYMBOL(sym, license, ns)
+#define __EXPORT_SYMBOL(sym, license, ns...)
#elif defined(__GENKSYMS__)
-#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
+#define __EXPORT_SYMBOL(sym, license, ns...) __GENKSYMS_EXPORT_SYMBOL(sym)
#elif defined(__ASSEMBLY__)
-#define __EXPORT_SYMBOL(sym, license, ns) \
+#define __EXPORT_SYMBOL(sym, license, ns...) \
___EXPORT_SYMBOL(sym, license, ns)
#else
-#define __EXPORT_SYMBOL(sym, license, ns) \
+#define __EXPORT_SYMBOL(sym, license, ns...) \
extern typeof(sym) sym; \
__ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
@@ -70,4 +82,6 @@
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)
+#define EXPORT_SYMBOL_GPL_FOR(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "MODULE_", mods)
+
#endif /* _LINUX_EXPORT_H */
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-02 14:59 ` [PATCH -v2 1/7] module: Convert symbol namespace to string literal Peter Zijlstra
@ 2024-12-02 15:15 ` Peter Zijlstra
2024-12-02 15:22 ` Greg KH
2024-12-02 19:33 ` Linus Torvalds
0 siblings, 2 replies; 31+ messages in thread
From: Peter Zijlstra @ 2024-12-02 15:15 UTC (permalink / raw)
To: mcgrof, Linus Torvalds
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Mon, Dec 02, 2024 at 03:59:47PM +0100, Peter Zijlstra wrote:
> Clean up the existing export namespace code along the same lines of
> 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to
> __section("foo")") and for the same reason, it is not desired for the
> namespace argument to be a macro expansion itself.
>
> git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
> do
> awk -i inplace '
> /^#define EXPORT_SYMBOL_NS/ {
> gsub(/__stringify\(ns\)/, "ns");
> print;
> next;
> }
> /^#define MODULE_IMPORT_NS/ {
> gsub(/__stringify\(ns\)/, "ns");
> print;
> next;
> }
> /MODULE_IMPORT_NS/ {
> $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
> }
> /EXPORT_SYMBOL_NS/ {
> if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
> if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
> $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
> $0 !~ /^my/) {
> getline line;
> gsub(/[[:space:]]*\\$/, "");
> gsub(/[[:space:]]/, "", line);
> $0 = $0 " " line;
> }
>
> $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
> "\\1(\\2, \"\\3\")", "g");
> }
> }
> { print }' $file;
> done
Perhaps we can ask Linus to run this now, before -next fills up again ?
> Requested-by: Masahiro Yamada <masahiroy@kernel.org>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-02 15:15 ` Peter Zijlstra
@ 2024-12-02 15:22 ` Greg KH
2024-12-02 19:33 ` Linus Torvalds
1 sibling, 0 replies; 31+ messages in thread
From: Greg KH @ 2024-12-02 15:22 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, Linus Torvalds, x86, hpa, petr.pavlu, samitolvanen,
da.gomez, masahiroy, nathan, nicolas, linux-kernel, linux-modules,
linux-kbuild, hch
On Mon, Dec 02, 2024 at 04:15:33PM +0100, Peter Zijlstra wrote:
> On Mon, Dec 02, 2024 at 03:59:47PM +0100, Peter Zijlstra wrote:
> > Clean up the existing export namespace code along the same lines of
> > 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to
> > __section("foo")") and for the same reason, it is not desired for the
> > namespace argument to be a macro expansion itself.
> >
> > git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file;
> > do
> > awk -i inplace '
> > /^#define EXPORT_SYMBOL_NS/ {
> > gsub(/__stringify\(ns\)/, "ns");
> > print;
> > next;
> > }
> > /^#define MODULE_IMPORT_NS/ {
> > gsub(/__stringify\(ns\)/, "ns");
> > print;
> > next;
> > }
> > /MODULE_IMPORT_NS/ {
> > $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g");
> > }
> > /EXPORT_SYMBOL_NS/ {
> > if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) {
> > if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ &&
> > $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ &&
> > $0 !~ /^my/) {
> > getline line;
> > gsub(/[[:space:]]*\\$/, "");
> > gsub(/[[:space:]]/, "", line);
> > $0 = $0 " " line;
> > }
> >
> > $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/,
> > "\\1(\\2, \"\\3\")", "g");
> > }
> > }
> > { print }' $file;
> > done
>
> Perhaps we can ask Linus to run this now, before -next fills up again ?
Yes please!
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 0/7] module: Strict per-modname namespaces
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (6 preceding siblings ...)
2024-12-02 14:59 ` [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper Peter Zijlstra
@ 2024-12-02 17:36 ` Andi Kleen
2024-12-16 16:43 ` Petr Pavlu
2025-05-02 11:55 ` Roy, Patrick
9 siblings, 0 replies; 31+ messages in thread
From: Andi Kleen @ 2024-12-02 17:36 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy,
nathan, nicolas, linux-kernel, linux-modules, linux-kbuild, hch,
gregkh
Peter Zijlstra <peterz@infradead.org> writes:
> Hi!
>
> Implement a means for exports to be available only to an explicit list of named
> modules. By explicitly limiting the usage of certain exports, the abuse
> potential/risk is greatly reduced.
Blast from the past: https://lists.linuxcoding.com/kernel/2007-q4/msg19926.html
Yes it makes sense.
-Andi
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-02 15:15 ` Peter Zijlstra
2024-12-02 15:22 ` Greg KH
@ 2024-12-02 19:33 ` Linus Torvalds
2024-12-03 19:19 ` Mark Brown
1 sibling, 1 reply; 31+ messages in thread
From: Linus Torvalds @ 2024-12-02 19:33 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy,
nathan, nicolas, linux-kernel, linux-modules, linux-kbuild, hch,
gregkh
On Mon, 2 Dec 2024 at 07:15, Peter Zijlstra <peterz@infradead.org> wrote:
>
> Perhaps we can ask Linus to run this now, before -next fills up again ?
Sure. I did an unasked-for scripted 'remove_new' removal right after
rc1 for the same reason.
If we have these kinds of big scripted things, right after the merge
window tends to be the best time to do them. The conflict potential of
leaving it hanging in linux-next can be somewhat annoying. They may be
fairly unlikely, and easy to resolve individually, but it's one of
those "one is trivial to deal with, but even just a handful is
annoying".
So I'll run your script and take your commit message, and we'll have
this part over and done with.
Thanks,
Linus
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-02 19:33 ` Linus Torvalds
@ 2024-12-03 19:19 ` Mark Brown
2024-12-03 22:06 ` Mark Brown
0 siblings, 1 reply; 31+ messages in thread
From: Mark Brown @ 2024-12-03 19:19 UTC (permalink / raw)
To: Linus Torvalds
Cc: Peter Zijlstra, mcgrof, x86, hpa, petr.pavlu, samitolvanen,
da.gomez, masahiroy, nathan, nicolas, linux-kernel, linux-modules,
linux-kbuild, hch, gregkh, linux-next
[-- Attachment #1: Type: text/plain, Size: 1329 bytes --]
On Mon, Dec 02, 2024 at 11:33:58AM -0800, Linus Torvalds wrote:
> On Mon, 2 Dec 2024 at 07:15, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > Perhaps we can ask Linus to run this now, before -next fills up again ?
>
> Sure. I did an unasked-for scripted 'remove_new' removal right after
> rc1 for the same reason.
>
> If we have these kinds of big scripted things, right after the merge
> window tends to be the best time to do them. The conflict potential of
> leaving it hanging in linux-next can be somewhat annoying. They may be
> fairly unlikely, and easy to resolve individually, but it's one of
> those "one is trivial to deal with, but even just a handful is
> annoying".
>
> So I'll run your script and take your commit message, and we'll have
> this part over and done with.
I *think* this is interacting in a fun way with at least the IIO
subsystem in -next (Linus' tree is fine, I didn't do too much
investigation as I'd quite like the -next build to finish some time
today):
/tmp/next/tmp/ccjk7YJR.s: Assembler messages:
/tmp/next/tmp/ccjk7YJR.s:5: Error: junk at end of line, first unrecognized character is `I'
make[7]: *** [/tmp/next/build/scripts/Makefile.build:194: drivers/iio/imu/inv_icm42600/inv_icm42600_core.o] Error 1
I've dropped the IIO trees from -next for now.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-03 19:19 ` Mark Brown
@ 2024-12-03 22:06 ` Mark Brown
2024-12-04 1:11 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Mark Brown @ 2024-12-03 22:06 UTC (permalink / raw)
To: Linus Torvalds
Cc: Peter Zijlstra, mcgrof, x86, hpa, petr.pavlu, samitolvanen,
da.gomez, masahiroy, nathan, nicolas, linux-kernel, linux-modules,
linux-kbuild, hch, gregkh, linux-next
[-- Attachment #1: Type: text/plain, Size: 983 bytes --]
On Tue, Dec 03, 2024 at 07:20:05PM +0000, Mark Brown wrote:
> On Mon, Dec 02, 2024 at 11:33:58AM -0800, Linus Torvalds wrote:
> > If we have these kinds of big scripted things, right after the merge
> > window tends to be the best time to do them. The conflict potential of
> > leaving it hanging in linux-next can be somewhat annoying. They may be
> > fairly unlikely, and easy to resolve individually, but it's one of
> > those "one is trivial to deal with, but even just a handful is
> > annoying".
> > So I'll run your script and take your commit message, and we'll have
> > this part over and done with.
> I *think* this is interacting in a fun way with at least the IIO
> subsystem in -next (Linus' tree is fine, I didn't do too much
> investigation as I'd quite like the -next build to finish some time
> today):
Yes, this is breaking ASoC and possibly other things as well. I guess
any tree adding a new use of these macros needs to merge mainline to
avoid a mess here.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 1/7] module: Convert symbol namespace to string literal
2024-12-03 22:06 ` Mark Brown
@ 2024-12-04 1:11 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2024-12-04 1:11 UTC (permalink / raw)
To: Mark Brown
Cc: Linus Torvalds, Peter Zijlstra, mcgrof, x86, hpa, petr.pavlu,
samitolvanen, da.gomez, nathan, nicolas, linux-kernel,
linux-modules, linux-kbuild, hch, gregkh, linux-next
On Wed, Dec 4, 2024 at 7:06 AM Mark Brown <broonie@kernel.org> wrote:
>
> On Tue, Dec 03, 2024 at 07:20:05PM +0000, Mark Brown wrote:
> > On Mon, Dec 02, 2024 at 11:33:58AM -0800, Linus Torvalds wrote:
>
> > > If we have these kinds of big scripted things, right after the merge
> > > window tends to be the best time to do them. The conflict potential of
> > > leaving it hanging in linux-next can be somewhat annoying. They may be
> > > fairly unlikely, and easy to resolve individually, but it's one of
> > > those "one is trivial to deal with, but even just a handful is
> > > annoying".
>
> > > So I'll run your script and take your commit message, and we'll have
> > > this part over and done with.
>
> > I *think* this is interacting in a fun way with at least the IIO
> > subsystem in -next (Linus' tree is fine, I didn't do too much
> > investigation as I'd quite like the -next build to finish some time
> > today):
>
> Yes, this is breaking ASoC and possibly other things as well. I guess
> any tree adding a new use of these macros needs to merge mainline to
> avoid a mess here.
In this development cycle, I think subsystems should queue up patches
on top of -rc2 instead of -rc1.
Meanwhile, linux-next needs to carry the following fixup.
diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
index 550cc53e7559..f415f300afb6 100644
--- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
+++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
@@ -908,4 +908,4 @@ EXPORT_NS_GPL_DEV_PM_OPS(inv_icm42600_pm_ops,
IIO_ICM42600) = {
MODULE_AUTHOR("InvenSense, Inc.");
MODULE_DESCRIPTION("InvenSense ICM-426xx device driver");
MODULE_LICENSE("GPL");
-MODULE_IMPORT_NS(IIO_INV_SENSORS_TIMESTAMP);
+MODULE_IMPORT_NS("IIO_INV_SENSORS_TIMESTAMP");
--
Best Regards
Masahiro Yamada
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 6/7] module: Account for the build time module name mangling
2024-12-02 14:59 ` [PATCH -v2 6/7] module: Account for the build time module name mangling Peter Zijlstra
@ 2024-12-06 18:35 ` Sean Christopherson
2025-05-02 13:15 ` Peter Zijlstra
1 sibling, 0 replies; 31+ messages in thread
From: Sean Christopherson @ 2024-12-06 18:35 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy,
nathan, nicolas, linux-kernel, linux-modules, linux-kbuild, hch,
gregkh
On Mon, Dec 02, 2024, Peter Zijlstra wrote:
> Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle
> the module name with s/-/_/g.
>
> Since this happens late in the build, only the kernel needs to bother
> with this, the modpost tool still sees the original name.
>
> Reported-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
Tested-by: Sean Christopherson <seanjc@google.com>
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 0/7] module: Strict per-modname namespaces
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (7 preceding siblings ...)
2024-12-02 17:36 ` [PATCH -v2 0/7] module: Strict per-modname namespaces Andi Kleen
@ 2024-12-16 16:43 ` Petr Pavlu
2025-02-05 10:14 ` Petr Pavlu
2025-05-02 11:55 ` Roy, Patrick
9 siblings, 1 reply; 31+ messages in thread
From: Petr Pavlu @ 2024-12-16 16:43 UTC (permalink / raw)
To: masahiroy
Cc: Peter Zijlstra, mcgrof, x86, hpa, petr.pavlu, samitolvanen,
da.gomez, nathan, nicolas, linux-kernel, linux-modules,
linux-kbuild, hch, gregkh
On 12/2/24 15:59, Peter Zijlstra wrote:
> Hi!
>
> Implement a means for exports to be available only to an explicit list of named
> modules. By explicitly limiting the usage of certain exports, the abuse
> potential/risk is greatly reduced.
>
> The first 'patch' is an awk scripts that cleans up the existing module
> namespace code along the same lines of commit 33def8498fdd ("treewide: Convert
> macro and uses of __section(foo) to __section("foo")") and for the same reason,
> it is not desired for the namespace argument to be a macro expansion itself.
>
> The remainder of the patches introduce the special "MODULE_<modname-list>"
> namespace, which shall be forbidden from being explicitly imported. A module
> that matches the simple modname-list will get an implicit import.
@Masahiro, I'd like to take this on the modules tree for 6.14. Can I get
an Acked-by you for the changes?
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 0/7] module: Strict per-modname namespaces
2024-12-16 16:43 ` Petr Pavlu
@ 2025-02-05 10:14 ` Petr Pavlu
2025-02-07 18:04 ` Masahiro Yamada
0 siblings, 1 reply; 31+ messages in thread
From: Petr Pavlu @ 2025-02-05 10:14 UTC (permalink / raw)
To: masahiroy
Cc: Peter Zijlstra, mcgrof, x86, hpa, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On 12/16/24 17:43, Petr Pavlu wrote:
> On 12/2/24 15:59, Peter Zijlstra wrote:
>> Hi!
>>
>> Implement a means for exports to be available only to an explicit list of named
>> modules. By explicitly limiting the usage of certain exports, the abuse
>> potential/risk is greatly reduced.
>>
>> The first 'patch' is an awk scripts that cleans up the existing module
>> namespace code along the same lines of commit 33def8498fdd ("treewide: Convert
>> macro and uses of __section(foo) to __section("foo")") and for the same reason,
>> it is not desired for the namespace argument to be a macro expansion itself.
>>
>> The remainder of the patches introduce the special "MODULE_<modname-list>"
>> namespace, which shall be forbidden from being explicitly imported. A module
>> that matches the simple modname-list will get an implicit import.
>
> @Masahiro, I'd like to take this on the modules tree for 6.14. Can I get
> an Acked-by you for the changes?
Ping, this still applies mostly cleanly. I plan to take the series on
modules-next, or let me know if you prefer for this to go through the
kbuild tree.
--
Thanks,
Petr
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper
2024-12-02 14:59 ` [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper Peter Zijlstra
@ 2025-02-07 8:09 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 8:09 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
Commit description is needed.
[bikeshed]
Perhaps, I slightly prefer EXPORT_SYMBOL_GPL_FOR_MODULES().
>
> -#define ___EXPORT_SYMBOL(sym, license, ns) \
> +/*
> + * LLVM intregrated assembler refuses to merge adjacent string literals (like
"intregrated" is a typo.
> + * C and GNU-as) and chokes on:
> + *
> + * .asciz "MODULE_" "kvm" ;
> + *
> + * As would be generated when using EXPORT_SYMBOL_GPL_FOR(foo, "kvm"), use
> + * varargs to assemble it like so:
> + *
> + * .ascii "MODULE_", "kvm", "\0" ;
But, you do not need comma separators, right?
The following less-invasive diff worked for me with LLVM=1.
diff --git a/include/linux/export.h b/include/linux/export.h
index a8c23d945634..546279f4d0c2 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -24,11 +24,17 @@
.long sym
#endif
+/*
+ * LLVM integrated assembler can merge adjacent string literals (like
+ * C and GNU-as) passed to '.ascii', but not to '.asciz' and chokes on:
+ *
+ * .asciz "MODULE_" "kvm" ;
+ */
#define ___EXPORT_SYMBOL(sym, license, ns) \
.section ".export_symbol","a" ASM_NL \
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
- .asciz ns ASM_NL \
+ .ascii ns "\0" ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous
@@ -85,4 +91,6 @@
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)
+#define EXPORT_SYMBOL_GPL_FOR(sym, mods) __EXPORT_SYMBOL(sym, "GPL",
"MODULE_" mods)
+
--
Best Regards
Masahiro Yamada
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing
2024-12-02 14:59 ` [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing Peter Zijlstra
@ 2025-02-07 8:41 ` Masahiro Yamada
2025-05-02 13:10 ` Peter Zijlstra
2025-02-07 15:45 ` Masahiro Yamada
1 sibling, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 8:41 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Instead of only accepting "MODULE_${name}", extend it with a comma
> separated list of module names and add tail glob support.
>
> That is, something like: "MODULE_foo-*,bar" is now possible.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/module/main.c | 39 ++++++++++++++++++++++++++++++++++-----
> scripts/mod/modpost.c | 40 ++++++++++++++++++++++++++++++++++------
> 2 files changed, 68 insertions(+), 11 deletions(-)
>
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -1061,6 +1061,38 @@ static char *get_modinfo(const struct lo
> return get_next_modinfo(info, tag, NULL);
> }
>
> +/*
> + * @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
Please add a proper kdoc style comment block.
Rather than an underscore, I prefer a colon, which rarely appears in file names.
How about "module:foo-*,bar" instead of "MODULE_foo-*,bar" ?
> + */
> +static bool verify_module_namespace(const char *namespace, const char *modname)
> +{
> + size_t len, modlen = strlen(modname);
> + const char *sep;
> + bool glob;
> +
> + if (strncmp(namespace, "MODULE_", 7) != 0)
> + return false;
> +
> + for (namespace += 7; *namespace; namespace = sep) {
> + sep = strchrnul(namespace, ',');
> + len = sep - namespace;
> +
> + glob = false;
> + if (sep[-1] == '*') {
> + len--;
> + glob = true;
> + }
Why only limited to the trailing wildcard?
Did you consider using glob_match()?
> +
> + if (*sep)
> + sep++;
> +
> + if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
> + return true;
> + }
> +
> + return false;
> +}
> +
> static int verify_namespace_is_imported(const struct load_info *info,
> const struct kernel_symbol *sym,
> struct module *mod)
> @@ -1070,11 +1102,8 @@ static int verify_namespace_is_imported(
>
> namespace = kernel_symbol_namespace(sym);
> if (namespace && namespace[0]) {
> - /*
> - * Implicitly import MODULE_${mod->name} namespace.
> - */
> - if (strncmp(namespace, "MODULE_", 7) == 0 &&
> - strcmp(namespace+7, mod->name) == 0)
> +
> + if (verify_module_namespace(namespace, mod->name))
> return 0;
>
> for_each_modinfo_entry(imported_namespace, info, "import_ns") {
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1565,7 +1565,6 @@ static const char *mod_basename(const ch
>
> static void read_symbols(const char *modname)
> {
> - char module_namespace[MODULE_NAME_LEN + 8];
> const char *symname;
> char *version;
> char *license;
> @@ -1601,10 +1600,6 @@ static void read_symbols(const char *mod
> namespace = get_next_modinfo(&info, "import_ns", namespace))
> add_namespace(&mod->imported_namespaces, namespace);
>
> - snprintf(module_namespace, sizeof(module_namespace), "MODULE_%s",
> - mod_basename(mod->name));
> - add_namespace(&mod->imported_namespaces, module_namespace);
> -
> if (extra_warn && !get_modinfo(&info, "description"))
> warn("missing MODULE_DESCRIPTION() in %s\n", modname);
> }
> @@ -1687,6 +1682,38 @@ void buf_write(struct buffer *buf, const
> buf->pos += len;
> }
>
> +/*
> + * @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
Same comment as in kernel/module/main.c
> + */
> +static bool module_namespace(const char *namespace, const char *modname)
> +{
> + size_t len, modlen = strlen(modname);
> + const char *sep;
> + bool glob;
> +
> + if (strncmp(namespace, "MODULE_", 7) != 0)
> + return false;
If you see the existing code closely, strstarts() helper is used everywhere.
I would write like this:
static const char *prefix = "module:";
if (!strstarts(namespace, prefix))
return false;
> +
> + for (namespace += 7; *namespace; namespace = sep) {
I tend to avoid the magic number, 7.
Just like this:
https://github.com/torvalds/linux/blob/v6.14-rc1/scripts/mod/file2alias.c#L1494
> + sep = strchrnul(namespace, ',');
> + len = sep - namespace;
> +
> + glob = false;
> + if (sep[-1] == '*') {
> + len--;
> + glob = true;
> + }
> +
> + if (*sep)
> + sep++;
> +
> + if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
> + return true;
> + }
Same as kernel/module/main.c.
If you see around line 700 in this file,
you will find fnmatch() is already used for glob matching.
> +
> + return false;
> +}
> +
> static void check_exports(struct module *mod)
> {
> struct symbol *s, *exp;
> @@ -1714,7 +1741,8 @@ static void check_exports(struct module
>
> basename = mod_basename(mod->name);
>
> - if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> + if (!module_namespace(exp->namespace, basename) &&
> + !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> modpost_log(!allow_missing_ns_imports,
> "module %s uses symbol %s from namespace %s, but does not import it.\n",
> basename, exp->name, exp->namespace);
>
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 2/7] module/modpost: Use for() loop
2024-12-02 14:59 ` [PATCH -v2 2/7] module/modpost: Use for() loop Peter Zijlstra
@ 2025-02-07 8:50 ` Masahiro Yamada
2025-02-07 16:38 ` Masahiro Yamada
1 sibling, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 8:50 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
Please add a commit description.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> scripts/mod/modpost.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1586,12 +1586,9 @@ static void read_symbols(const char *mod
> license = get_next_modinfo(&info, "license", license);
> }
>
> - namespace = get_modinfo(&info, "import_ns");
> - while (namespace) {
> + for (namespace = get_modinfo(&info, "import_ns"); namespace;
> + namespace = get_next_modinfo(&info, "import_ns", namespace))
[Bikeshed]
Personally, I tend to indent a long for() as follows:
for (namespace = get_modinfo(&info, "import_ns");
namespace;
namespace = get_next_modinfo(&info, "import_ns", namespace))
> add_namespace(&mod->imported_namespaces, namespace);
> - namespace = get_next_modinfo(&info, "import_ns",
> - namespace);
> - }
>
> if (extra_warn && !get_modinfo(&info, "description"))
> warn("missing MODULE_DESCRIPTION() in %s\n", modname);
>
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing
2024-12-02 14:59 ` [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing Peter Zijlstra
2025-02-07 8:41 ` Masahiro Yamada
@ 2025-02-07 15:45 ` Masahiro Yamada
2025-05-02 13:11 ` Peter Zijlstra
1 sibling, 1 reply; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 15:45 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Instead of only accepting "MODULE_${name}", extend it with a comma
> separated list of module names and add tail glob support.
>
> That is, something like: "MODULE_foo-*,bar" is now possible.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/module/main.c | 39 ++++++++++++++++++++++++++++++++++-----
> scripts/mod/modpost.c | 40 ++++++++++++++++++++++++++++++++++------
> 2 files changed, 68 insertions(+), 11 deletions(-)
>
> static void check_exports(struct module *mod)
> {
> struct symbol *s, *exp;
> @@ -1714,7 +1741,8 @@ static void check_exports(struct module
>
> basename = mod_basename(mod->name);
>
> - if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> + if (!module_namespace(exp->namespace, basename) &&
> + !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> modpost_log(!allow_missing_ns_imports,
> "module %s uses symbol %s from namespace %s, but does not import it.\n",
> basename, exp->name, exp->namespace);
>
When module_namespace() fails, the following error message is shown:
ERROR: modpost: module bar uses symbol foo from namespace
MODULE_kvm, but does not import it.
We get a hint from this error message, but the solution
is not MODULE_IMPORT_NS();
'make nsdeps' will try to solve this by adding
MODULE_IMPORT_NS("MODULE_kvm");
Apparently, this does not work.
Not sure if you want to solve the issue.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 4/7] module: Add module specific symbol namespace support
2024-12-02 14:59 ` [PATCH -v2 4/7] module: Add module specific symbol namespace support Peter Zijlstra
@ 2025-02-07 16:22 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 16:22 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Designate the "MODULE_${modname}" symbol namespace to mean: 'only
> export to the named module'.
>
> Notably, explicit imports of anything in the "MODULE_" space is
> forbidden. Modules implicitly get the "MODULE_${modname}" namespace
> added.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/module/main.c | 28 ++++++++++++++++++++++++++--
> scripts/mod/modpost.c | 5 +++++
> 2 files changed, 31 insertions(+), 2 deletions(-)
>
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -1070,6 +1070,13 @@ static int verify_namespace_is_imported(
>
> namespace = kernel_symbol_namespace(sym);
> if (namespace && namespace[0]) {
> + /*
> + * Implicitly import MODULE_${mod->name} namespace.
> + */
> + if (strncmp(namespace, "MODULE_", 7) == 0 &&
strncmp() -> strstarts()
> + strcmp(namespace+7, mod->name) == 0)
> + return 0;
> +
You can add verify_module_namespace() in this commit
with a simple implementation.
static bool verify_module_namespace(const char *namespace, const char *modname)
{
const char *prefix = "module:";
return strstarts(namespace, prefix) &&
!strcmp(namespace + strlen(prefix), modname);
}
Then, you can extend it in the next commit,
to support the glob pattern in verify_module_namespace()
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1565,6 +1565,7 @@ static const char *mod_basename(const ch
>
> static void read_symbols(const char *modname)
> {
> + char module_namespace[MODULE_NAME_LEN + 8];
> const char *symname;
> char *version;
> char *license;
> @@ -1600,6 +1601,10 @@ static void read_symbols(const char *mod
> namespace = get_next_modinfo(&info, "import_ns", namespace))
> add_namespace(&mod->imported_namespaces, namespace);
>
> + snprintf(module_namespace, sizeof(module_namespace), "MODULE_%s",
> + mod_basename(mod->name));
> + add_namespace(&mod->imported_namespaces, module_namespace);
> +
> if (extra_warn && !get_modinfo(&info, "description"))
> warn("missing MODULE_DESCRIPTION() in %s\n", modname);
> }
This is a noise change, as you immediately remove this code in the next commit.
So, I recommend adding verify_module_namespace() in this commit.
Then, you can extend it in the next commit for glob pattern support.
index d4abcd8ee2ed..58fbcb6bb718 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1674,6 +1674,14 @@ void buf_write(struct buffer *buf, const char
*s, int len)
buf->pos += len;
}
+static bool verify_module_namespace(const char *namespace, const char *modname)
+{
+ const char *prefix = "module:";
+
+ return strstarts(namespace, prefix) &&
+ !strcmp(namespace + strlen(prefix), modname);
+}
+
static void check_exports(struct module *mod)
{
struct symbol *s, *exp;
@@ -1701,7 +1709,8 @@ static void check_exports(struct module *mod)
basename = mod_basename(mod->name);
- if (!contains_namespace(&mod->imported_namespaces,
exp->namespace)) {
+ if (!verify_module_namespace(exp->namespace, mod->name) &&
+ !contains_namespace(&mod->imported_namespaces,
exp->namespace)) {
modpost_log(!allow_missing_ns_imports,
"module %s uses symbol %s from
namespace %s, but does not import it.\n",
basename, exp->name, exp->namespace);
--
Best Regards
Masahiro Yamada
^ permalink raw reply related [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 2/7] module/modpost: Use for() loop
2024-12-02 14:59 ` [PATCH -v2 2/7] module/modpost: Use for() loop Peter Zijlstra
2025-02-07 8:50 ` Masahiro Yamada
@ 2025-02-07 16:38 ` Masahiro Yamada
1 sibling, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 16:38 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
The commit subject prefix should be "modpost: "
instead of "module/modpost: "
You are touching only modpost in this patch.
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> scripts/mod/modpost.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 3/7] module/modpost: Add basename helper
2024-12-02 14:59 ` [PATCH -v2 3/7] module/modpost: Add basename helper Peter Zijlstra
@ 2025-02-07 17:56 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 17:56 UTC (permalink / raw)
To: Peter Zijlstra
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
I do not think you need this helper (at least in your purpose).
You will use this helper in the 4/7 patch.
Then, you will immediately revert it in the 5/7 patch.
If you look at the final result, you did not need to add
mod_basename() in the first place.
(There is just one call site, which does not save any
duplicated code).
I suggest adding verify_module_namespace() in the 4/7 patch
instead of using the helper.
BTW, I think this helper is useful for cleaning up the current code,
but you are not even aware that this common pattern appears multiple times.
https://lore.kernel.org/all/20250207175024.412054-1-masahiroy@kernel.org/T/#u
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> scripts/mod/modpost.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1553,6 +1553,16 @@ static void mod_set_crcs(struct module *
> free(buf);
> }
>
> +static const char *mod_basename(const char *modname)
> +{
> + const char *basename = strrchr(modname, '/');
> + if (basename)
> + basename++;
> + else
> + basename = modname;
> + return basename;
> +}
> +
> static void read_symbols(const char *modname)
> {
> const char *symname;
> @@ -1697,11 +1707,7 @@ static void check_exports(struct module
> s->crc_valid = exp->crc_valid;
> s->crc = exp->crc;
>
> - basename = strrchr(mod->name, '/');
> - if (basename)
> - basename++;
> - else
> - basename = mod->name;
> + basename = mod_basename(mod->name);
>
> if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> modpost_log(!allow_missing_ns_imports,
>
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 0/7] module: Strict per-modname namespaces
2025-02-05 10:14 ` Petr Pavlu
@ 2025-02-07 18:04 ` Masahiro Yamada
0 siblings, 0 replies; 31+ messages in thread
From: Masahiro Yamada @ 2025-02-07 18:04 UTC (permalink / raw)
To: Petr Pavlu
Cc: Peter Zijlstra, mcgrof, x86, hpa, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Wed, Feb 5, 2025 at 7:14 PM Petr Pavlu <petr.pavlu@suse.com> wrote:
>
> On 12/16/24 17:43, Petr Pavlu wrote:
> > On 12/2/24 15:59, Peter Zijlstra wrote:
> >> Hi!
> >>
> >> Implement a means for exports to be available only to an explicit list of named
> >> modules. By explicitly limiting the usage of certain exports, the abuse
> >> potential/risk is greatly reduced.
> >>
> >> The first 'patch' is an awk scripts that cleans up the existing module
> >> namespace code along the same lines of commit 33def8498fdd ("treewide: Convert
> >> macro and uses of __section(foo) to __section("foo")") and for the same reason,
> >> it is not desired for the namespace argument to be a macro expansion itself.
> >>
> >> The remainder of the patches introduce the special "MODULE_<modname-list>"
> >> namespace, which shall be forbidden from being explicitly imported. A module
> >> that matches the simple modname-list will get an implicit import.
> >
> > @Masahiro, I'd like to take this on the modules tree for 6.14. Can I get
> > an Acked-by you for the changes?
>
> Ping, this still applies mostly cleanly. I plan to take the series on
> modules-next, or let me know if you prefer for this to go through the
> kbuild tree.
I do not think this patch set is in a mature state yet.
He did not provide proper documentation or commit description.
It would be nice if he takes some time to add documentation to
Documentation/core-api/symbol-namespaces.rst
since this is a new feature of the module namespace.
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 31+ messages in thread
* RE: [PATCH -v2 0/7] module: Strict per-modname namespaces
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
` (8 preceding siblings ...)
2024-12-16 16:43 ` Petr Pavlu
@ 2025-05-02 11:55 ` Roy, Patrick
2025-05-02 12:55 ` Peter Zijlstra
9 siblings, 1 reply; 31+ messages in thread
From: Roy, Patrick @ 2025-05-02 11:55 UTC (permalink / raw)
To: peterz@infradead.org
Cc: da.gomez@samsung.com, gregkh@linuxfoundation.org,
hch@infradead.org, hpa@zytor.com, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
masahiroy@kernel.org, mcgrof@kernel.org, nathan@kernel.org,
nicolas@fjasle.eu, petr.pavlu@suse.com, samitolvanen@google.com,
x86@kernel.org
Hi Peter,
Are you still working on this patch series? I'm working on having KVM remove
virtual machine memory from the kernel's direct map, to harden again
speculative execution attacks [1]. At David H.'s LSF/MM/BPF task on
guest_memfd, it was suggested to use per-modname namespaces to export
set_direct_map_valid() specifically for use in KVM to achieve this.
Is there anything I can do to help get this across the finish line
(testing/etc.)?
Best,
Patrick
[1]: https://lore.kernel.org/kvm/20250221160728.1584559-1-roypat@amazon.co.uk/
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 0/7] module: Strict per-modname namespaces
2025-05-02 11:55 ` Roy, Patrick
@ 2025-05-02 12:55 ` Peter Zijlstra
0 siblings, 0 replies; 31+ messages in thread
From: Peter Zijlstra @ 2025-05-02 12:55 UTC (permalink / raw)
To: Roy, Patrick
Cc: da.gomez@samsung.com, gregkh@linuxfoundation.org,
hch@infradead.org, hpa@zytor.com, linux-kbuild@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
masahiroy@kernel.org, mcgrof@kernel.org, nathan@kernel.org,
nicolas@fjasle.eu, petr.pavlu@suse.com, samitolvanen@google.com,
x86@kernel.org
On Fri, May 02, 2025 at 11:55:54AM +0000, Roy, Patrick wrote:
> Hi Peter,
>
> Are you still working on this patch series? I'm working on having KVM remove
> virtual machine memory from the kernel's direct map, to harden again
> speculative execution attacks [1]. At David H.'s LSF/MM/BPF task on
> guest_memfd, it was suggested to use per-modname namespaces to export
> set_direct_map_valid() specifically for use in KVM to achieve this.
>
> Is there anything I can do to help get this across the finish line
> (testing/etc.)?
Hmm, I had more or less forgotten about this.
Let me rebase and address the comments.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing
2025-02-07 8:41 ` Masahiro Yamada
@ 2025-05-02 13:10 ` Peter Zijlstra
0 siblings, 0 replies; 31+ messages in thread
From: Peter Zijlstra @ 2025-05-02 13:10 UTC (permalink / raw)
To: Masahiro Yamada
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Fri, Feb 07, 2025 at 05:41:54PM +0900, Masahiro Yamada wrote:
> > +static bool verify_module_namespace(const char *namespace, const char *modname)
> > +{
> > + size_t len, modlen = strlen(modname);
> > + const char *sep;
> > + bool glob;
> > +
> > + if (strncmp(namespace, "MODULE_", 7) != 0)
> > + return false;
> > +
> > + for (namespace += 7; *namespace; namespace = sep) {
> > + sep = strchrnul(namespace, ',');
> > + len = sep - namespace;
> > +
> > + glob = false;
> > + if (sep[-1] == '*') {
> > + len--;
> > + glob = true;
> > + }
>
>
> Why only limited to the trailing wildcard?
Because its simple and easy.
> Did you consider using glob_match()?
I had not, because I didn't know we had that in-kernel. Looking at that,
using it is a bit of a pain, since it needs the pattern as a C string,
which means I need to strdup() the thing because I can't modify the
original.
That in turn means we need to deal with malloc failure.
Is that all worth it?
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing
2025-02-07 15:45 ` Masahiro Yamada
@ 2025-05-02 13:11 ` Peter Zijlstra
0 siblings, 0 replies; 31+ messages in thread
From: Peter Zijlstra @ 2025-05-02 13:11 UTC (permalink / raw)
To: Masahiro Yamada
Cc: mcgrof, x86, hpa, petr.pavlu, samitolvanen, da.gomez, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh
On Sat, Feb 08, 2025 at 12:45:21AM +0900, Masahiro Yamada wrote:
> On Tue, Dec 3, 2024 at 12:11 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > Instead of only accepting "MODULE_${name}", extend it with a comma
> > separated list of module names and add tail glob support.
> >
> > That is, something like: "MODULE_foo-*,bar" is now possible.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > ---
> > kernel/module/main.c | 39 ++++++++++++++++++++++++++++++++++-----
> > scripts/mod/modpost.c | 40 ++++++++++++++++++++++++++++++++++------
> > 2 files changed, 68 insertions(+), 11 deletions(-)
> >
>
> > static void check_exports(struct module *mod)
> > {
> > struct symbol *s, *exp;
> > @@ -1714,7 +1741,8 @@ static void check_exports(struct module
> >
> > basename = mod_basename(mod->name);
> >
> > - if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> > + if (!module_namespace(exp->namespace, basename) &&
> > + !contains_namespace(&mod->imported_namespaces, exp->namespace)) {
> > modpost_log(!allow_missing_ns_imports,
> > "module %s uses symbol %s from namespace %s, but does not import it.\n",
> > basename, exp->name, exp->namespace);
> >
>
> When module_namespace() fails, the following error message is shown:
>
> ERROR: modpost: module bar uses symbol foo from namespace
> MODULE_kvm, but does not import it.
>
>
> We get a hint from this error message, but the solution
> is not MODULE_IMPORT_NS();
>
> 'make nsdeps' will try to solve this by adding
>
> MODULE_IMPORT_NS("MODULE_kvm");
>
> Apparently, this does not work.
>
> Not sure if you want to solve the issue.
Seems unsolvable by construction; so no.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH -v2 6/7] module: Account for the build time module name mangling
2024-12-02 14:59 ` [PATCH -v2 6/7] module: Account for the build time module name mangling Peter Zijlstra
2024-12-06 18:35 ` Sean Christopherson
@ 2025-05-02 13:15 ` Peter Zijlstra
1 sibling, 0 replies; 31+ messages in thread
From: Peter Zijlstra @ 2025-05-02 13:15 UTC (permalink / raw)
To: mcgrof
Cc: x86, hpa, petr.pavlu, samitolvanen, da.gomez, masahiroy, nathan,
nicolas, linux-kernel, linux-modules, linux-kbuild, hch, gregkh,
Sean Christopherson
On Mon, Dec 02, 2024 at 03:59:52PM +0100, Peter Zijlstra wrote:
> Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle
> the module name with s/-/_/g.
>
> Since this happens late in the build, only the kernel needs to bother
> with this, the modpost tool still sees the original name.
>
> Reported-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
> kernel/module/main.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -1062,6 +1062,30 @@ static char *get_modinfo(const struct lo
> }
>
> /*
> + * Like strncmp(), except s/-/_/g as per scripts/Makefile.lib:name-fix-token rule.
> + */
> +static int mod_strncmp(const char *str_a, const char *str_b, size_t n)
> +{
> + for (int i = 0; i < n; i++) {
> + char a = str_a[i];
> + char b = str_b[i];
> + int d;
> +
> + if (a == '-') a = '_';
> + if (b == '-') b = '_';
> +
> + d = a - b;
> + if (d)
> + return d;
> +
> + if (!a)
> + break;
> + }
> +
> + return 0;
> +}
> +
> +/*
> * @namespace ~= "MODULE_foo-*,bar", match @modname to 'foo-*' or 'bar'
> */
> static bool verify_module_namespace(const char *namespace, const char *modname)
> @@ -1086,7 +1110,7 @@ static bool verify_module_namespace(cons
> if (*sep)
> sep++;
>
> - if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
> + if (mod_strncmp(namespace, modname, len) == 0 && (glob || len == modlen))
> return true;
Note that this is going to be a pain if we use glob_match(), because
then either all the patterns must already use '[-_]', or we need to
dynamically rewrite the glob.
Neither really appeals to me much.
Best to keep it simple.
^ permalink raw reply [flat|nested] 31+ messages in thread
end of thread, other threads:[~2025-05-02 13:16 UTC | newest]
Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-02 14:59 [PATCH -v2 0/7] module: Strict per-modname namespaces Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 1/7] module: Convert symbol namespace to string literal Peter Zijlstra
2024-12-02 15:15 ` Peter Zijlstra
2024-12-02 15:22 ` Greg KH
2024-12-02 19:33 ` Linus Torvalds
2024-12-03 19:19 ` Mark Brown
2024-12-03 22:06 ` Mark Brown
2024-12-04 1:11 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 2/7] module/modpost: Use for() loop Peter Zijlstra
2025-02-07 8:50 ` Masahiro Yamada
2025-02-07 16:38 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 3/7] module/modpost: Add basename helper Peter Zijlstra
2025-02-07 17:56 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 4/7] module: Add module specific symbol namespace support Peter Zijlstra
2025-02-07 16:22 ` Masahiro Yamada
2024-12-02 14:59 ` [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing Peter Zijlstra
2025-02-07 8:41 ` Masahiro Yamada
2025-05-02 13:10 ` Peter Zijlstra
2025-02-07 15:45 ` Masahiro Yamada
2025-05-02 13:11 ` Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 6/7] module: Account for the build time module name mangling Peter Zijlstra
2024-12-06 18:35 ` Sean Christopherson
2025-05-02 13:15 ` Peter Zijlstra
2024-12-02 14:59 ` [PATCH -v2 7/7] module: Provide EXPORT_SYMBOL_GPL_FOR() helper Peter Zijlstra
2025-02-07 8:09 ` Masahiro Yamada
2024-12-02 17:36 ` [PATCH -v2 0/7] module: Strict per-modname namespaces Andi Kleen
2024-12-16 16:43 ` Petr Pavlu
2025-02-05 10:14 ` Petr Pavlu
2025-02-07 18:04 ` Masahiro Yamada
2025-05-02 11:55 ` Roy, Patrick
2025-05-02 12:55 ` 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).