Changes in 5.10.240
cifs: Fix cifs_query_path_info() for Windows NT servers
NFSv4.2: fix listxattr to return selinux security label
mailbox: Not protect module_put with spin_lock_irqsave
mfd: max14577: Fix wakeup source leaks on device unbind
leds: multicolor: Fix intensity setting while SW blinking
hwmon: (pmbus/max34440) Fix support for max34451
dmaengine: xilinx_dma: Set dma_device directions
md/md-bitmap: fix dm-raid max_write_behind setting
bcache: fix NULL pointer in cache_set_flush()
iio: pressure: zpa2326: Use aligned_s64 for the timestamp
um: Add cmpxchg8b_emu and checksum functions to asm-prototypes.h
usb: potential integer overflow in usbg_make_tpg()
usb: common: usb-conn-gpio: use a unique name for usb connector device
usb: Add checks for snprintf() calls in usb_alloc_dev()
usb: cdc-wdm: avoid setting WDM_READ for ZLP-s
usb: typec: displayport: Receive DP Status Update NAK request exit dp altmode
ALSA: hda: Ignore unsol events for cards being shut down
ALSA: hda: Add new pci id for AMD GPU display HD audio controller
ceph: fix possible integer overflow in ceph_zero_objects()
ovl: Check for NULL d_inode() in ovl_dentry_upper()
VMCI: check context->notify_page after call to get_user_pages_fast() to avoid GPF
VMCI: fix race between vmci_host_setup_notify and vmci_ctx_unset_notify
usb: typec: tcpci_maxim: Fix uninitialized return variable
usb: typec: tcpci_maxim: remove redundant assignment
usb: typec: tcpci_maxim: add terminating newlines to logging
usb: typec: tcpm/tcpci_maxim: Fix bounds check in process_rx()
fs/jfs: consolidate sanity checking in dbMount
jfs: validate AG parameters in dbMount() to prevent crashes
media: omap3isp: use sgtable-based scatterlist wrappers
can: tcan4x5x: fix power regulator retrieval during probe
f2fs: don't over-report free space or inodes in statvfs
RDMA/core: Use refcount_t instead of atomic_t on refcount of iwcm_id_private
RDMA/iwcm: Fix use-after-free of work objects after cm_id destruction
uio: uio_hv_generic: use devm_kzalloc() for private data alloc
Drivers: hv: vmbus: Fix duplicate CPU assignments within a device
Drivers: hv: Rename 'alloced' to 'allocated'
Drivers: hv: vmbus: Add utility function for querying ring size
uio_hv_generic: Query the ringbuffer size for device
uio_hv_generic: Align ring size to system page
PCI: cadence-ep: Correct PBA offset in .set_msix() callback
net_sched: sch_sfq: reject invalid perturb period
i2c: tiny-usb: disable zero-length read messages
i2c: robotfuzz-osif: disable zero-length read messages
atm: clip: prevent NULL deref in clip_push()
ALSA: usb-audio: Fix out-of-bounds read in snd_usb_get_audioformat_uac3()
attach_recursive_mnt(): do not lock the covering tree when sliding something under it
libbpf: Fix null pointer dereference in btf_dump__free on allocation failure
wifi: mac80211: fix beacon interval calculation overflow
vsock/uapi: fix linux/vm_sockets.h userspace compilation errors
um: ubd: Add missing error check in start_io_thread()
net: enetc: Correct endianness handling in _enetc_rd_reg64
atm: Release atm_dev_mutex after removing procfs in atm_dev_deregister().
dt-bindings: serial: 8250: Make clocks and clock-frequency exclusive
Bluetooth: L2CAP: Fix L2CAP MTU negotiation
dm-raid: fix variable in journal device check
btrfs: update superblock's device bytes_used when dropping chunk
HID: wacom: fix memory leak on kobject creation failure
HID: wacom: fix memory leak on sysfs attribute creation failure
HID: wacom: fix kobject reference count leak
drm/tegra: Assign plane type before registration
drm/tegra: Fix a possible null pointer dereference
drm/udl: Unregister device before cleaning up on disconnect
drm/amdkfd: Fix race in GWS queue scheduling
drm/bridge: cdns-dsi: Fix the clock variable for mode_valid()
drm/bridge: cdns-dsi: Fix connecting to next bridge
drm/bridge: cdns-dsi: Check return value when getting default PHY config
drm/bridge: cdns-dsi: Wait for Clk and Data Lanes to be ready
PCI: hv: Do not set PCI_COMMAND_MEMORY to reduce VM boot time
s390: Add '-std=gnu11' to decompressor and purgatory CFLAGS
Revert "ipv6: save dontfrag in cork"
arm64: Restrict pagetable teardown to avoid false warning
rtc: cmos: use spin_lock_irqsave in cmos_interrupt
vsock/vmci: Clear the vmci transport packet properly when initializing it
mmc: sdhci: Add a helper function for dump register in dynamic debug mode
Revert "mmc: sdhci: Disable SD card clock before changing parameters"
usb: typec: altmodes/displayport: do not index invalid pin_assignments
mtk-sd: Fix a pagefault in dma_unmap_sg() for not prepared data
platform/mellanox: mlxbf-tmfifo: fix vring_desc.len assignment
RDMA/mlx5: Initialize obj_event->obj_sub_list before xa_insert
nfs: Clean up /proc/net/rpc/nfs when nfs_fs_proc_net_init() fails.
NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
scsi: qla2xxx: Fix DMA mapping test in qla24xx_get_port_database()
scsi: qla4xxx: Fix missing DMA mapping error in qla4xxx_alloc_pdu()
scsi: ufs: core: Fix spelling of a sysfs attribute name
RDMA/mlx5: Fix CC counters query for MPV
btrfs: fix missing error handling when searching for inode refs during log replay
drm/exynos: fimd: Guard display clock control with runtime PM calls
spi: spi-fsl-dspi: Clear completion counter before initiating transfer
drm/i915/selftests: Change mock_request() to return error pointers
drm/i915/gt: Fix timeline left held on VMA alloc error
lib: test_objagg: Set error message in check_expect_hints_stats()
amd-xgbe: align CL37 AN sequence as per databook
enic: fix incorrect MTU comparison in enic_change_mtu()
net: rose: Fix fall-through warnings for Clang
rose: fix dangling neighbour pointers in rose_rt_device_down()
nui: Fix dma_mapping_error() check
net/sched: Always pass notifications when child class becomes empty
ALSA: sb: Force to disable DMAs once when DMA mode is changed
ata: pata_cs5536: fix build on 32-bit UML
powerpc: Fix struct termio related ioctl macros
scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port()
wifi: mac80211: drop invalid source address OCB frames
wifi: ath6kl: remove WARN on bad firmware input
ACPICA: Refuse to evaluate a method if arguments are missing
rcu: Return early if callback is not specified
regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods
mmc: mediatek: use data instead of mrq parameter from msdc_{un}prepare_data()
mtk-sd: Prevent memory corruption from DMA map failure
mtk-sd: reset host->mrq on prepare_data() error
drm/v3d: Disable interrupts before resetting the GPU
RDMA/mlx5: Fix vport loopback for MPV device
flexfiles/pNFS: update stats on NFS4ERR_DELAY for v4.1 DSes
NFSv4/flexfiles: Fix handling of NFS level errors in I/O
btrfs: propagate last_unlink_trans earlier when doing a rmdir
btrfs: use btrfs_record_snapshot_destroy() during rmdir
dpaa2-eth: rename dpaa2_eth_xdp_release_buf into dpaa2_eth_recycle_buf
dpaa2-eth: Update dpni_get_single_step_cfg command
dpaa2-eth: Update SINGLE_STEP register access
net: dpaa2-eth: rearrange variable in dpaa2_eth_get_ethtool_stats
dpaa2-eth: fix xdp_rxq_info leak
xhci: dbctty: disable ECHO flag by default
xhci: dbc: Flush queued requests before stopping dbc
Logitech C-270 even more broken
usb: typec: displayport: Fix potential deadlock
ACPI: PAD: fix crash in exit_round_robin()
media: uvcvideo: Return the number of processed controls
media: uvcvideo: Send control events for partial succeeds
media: uvcvideo: Rollback non processed entities on error
staging: rtl8723bs: Avoid memset() in aes_cipher() and aes_decipher()
drm/exynos: exynos7_drm_decon: add vblank check in IRQ handling
ASoC: fsl_asrc: use internal measured ratio for non-ideal ratio mode
perf: Revert to requiring CAP_SYS_ADMIN for uprobes
fix proc_sys_compare() handling of in-lookup dentries
netlink: Fix wraparounds of sk->sk_rmem_alloc.
tipc: Fix use-after-free in tipc_conn_close().
vsock: Fix transport_{g2h,h2g} TOCTOU
vm_sockets: Add flags field in the vsock address data structure
vm_sockets: Add VMADDR_FLAG_TO_HOST vsock flag
af_vsock: Set VMADDR_FLAG_TO_HOST flag on the receive path
af_vsock: Assign the vsock transport considering the vsock address flags
vsock: Fix transport_* TOCTOU
vsock: Fix IOCTL_VM_SOCKETS_GET_LOCAL_CID to check also `transport_local`
net: phy: smsc: Fix Auto-MDIX configuration when disabled by strap
net: phy: smsc: Fix link failure in forced mode with Auto-MDIX
atm: clip: Fix potential null-ptr-deref in to_atmarpd().
atm: clip: Fix memory leak of struct clip_vcc.
atm: clip: Fix infinite recursive call of clip_push().
atm: clip: Fix NULL pointer dereference in vcc_sendmsg()
net/sched: Abort __tc_modify_qdisc if parent class does not exist
fs/proc: do_task_stat: use __for_each_thread()
rxrpc: Fix oops due to non-existence of prealloc backlog struct
Documentation: x86/bugs/its: Add ITS documentation
x86/bhi: Define SPEC_CTRL_BHI_DIS_S
x86/its: Enumerate Indirect Target Selection (ITS) bug
x86/alternatives: Introduce int3_emulate_jcc()
x86/alternatives: Teach text_poke_bp() to patch Jcc.d32 instructions
x86/its: Add support for ITS-safe indirect thunk
x86/alternative: Optimize returns patching
x86/alternatives: Remove faulty optimization
x86/its: Add support for ITS-safe return thunk
x86/its: Fix undefined reference to cpu_wants_rethunk_at()
x86/its: Enable Indirect Target Selection mitigation
x86/its: Add "vmexit" option to skip mitigation on some CPUs
x86/modules: Set VM_FLUSH_RESET_PERMS in module_alloc()
x86/its: Use dynamic thunks for indirect branches
x86/its: Fix build errors when CONFIG_MODULES=n
x86/its: FineIBT-paranoid vs ITS
x86/mce/amd: Fix threshold limit reset
x86/mce: Don't remove sysfs if thresholding sysfs init fails
x86/mce: Make sure CMCI banks are cleared during shutdown on Intel
pinctrl: qcom: msm: mark certain pins as invalid for interrupts
drm/sched: Increment job count before swapping tail spsc queue
usb: gadget: u_serial: Fix race condition in TTY wakeup
Revert "ACPI: battery: negate current when discharging"
ethernet: atl1: Add missing DMA mapping error checks and count errors
rtc: lib_test: add MODULE_LICENSE
pwm: mediatek: Ensure to disable clocks in error path
netlink: Fix rmem check in netlink_broadcast_deliver().
netlink: make sure we allow at least one dump skb
Input: xpad - add support for Amazon Game Controller
Input: xpad - add VID for Turtle Beach controllers
Input: xpad - support Acer NGR 200 Controller
dma-buf: fix timeout handling in dma_resv_wait_timeout v2
wifi: zd1211rw: Fix potential NULL pointer dereference in zd_mac_tx_to_dev()
md/raid1: Fix stack memory use after return in raid1_reshape
net: appletalk: Fix device refcount leak in atrtr_create()
net: phy: microchip: limit 100M workaround to link-down events on LAN88xx
can: m_can: m_can_handle_lost_msg(): downgrade msg lost in rx message to debug level
net: ll_temac: Fix missing tx_pending check in ethtools_set_ringparam()
bnxt_en: Fix DCB ETS validation
bnxt_en: Set DMA unmap len correctly for XDP_REDIRECT
atm: idt77252: Add missing `dma_map_error()`
um: vector: Reduce stack usage in vector_eth_configure()
net: usb: qmi_wwan: add SIMCom 8230C composition
vt: add missing notification when switching back to text mode
HID: Add IGNORE quirk for SMARTLINKTECHNOLOGY
HID: quirks: Add quirk for 2 Chicony Electronics HP 5MP Cameras
Input: atkbd - do not skip atkbd_deactivate() when skipping ATKBD_CMD_GETID
vhost-scsi: protect vq->log_used with vq->mutex
x86/mm: Disable hugetlb page table sharing on 32-bit
x86/bugs: Rename MDS machinery to something more generic
x86/bugs: Add a Transient Scheduler Attacks mitigation
KVM: x86: add support for CPUID leaf 0x80000021
KVM: SVM: Advertise TSA CPUID bits to guests
x86/process: Move the buffer clearing before MONITOR
rseq: Fix segfault on registration when rseq_cs is non-zero
Linux 5.10.240
Change-Id: I75c56007632194306321eca64ab10f3d2531da3d
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
913 lines
24 KiB
C
913 lines
24 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Dynamic loading of modules into the kernel.
|
|
*
|
|
* Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
|
|
* Rewritten again by Rusty Russell, 2002
|
|
*/
|
|
|
|
#ifndef _LINUX_MODULE_H
|
|
#define _LINUX_MODULE_H
|
|
|
|
#include <linux/list.h>
|
|
#include <linux/stat.h>
|
|
#include <linux/compiler.h>
|
|
#include <linux/cache.h>
|
|
#include <linux/kmod.h>
|
|
#include <linux/init.h>
|
|
#include <linux/elf.h>
|
|
#include <linux/stringify.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/jump_label.h>
|
|
#include <linux/export.h>
|
|
#include <linux/rbtree_latch.h>
|
|
#include <linux/error-injection.h>
|
|
#include <linux/tracepoint-defs.h>
|
|
#include <linux/srcu.h>
|
|
#include <linux/static_call_types.h>
|
|
#include <linux/cfi.h>
|
|
#include <linux/android_kabi.h>
|
|
|
|
#include <linux/percpu.h>
|
|
#include <asm/module.h>
|
|
|
|
/* Not Yet Implemented */
|
|
#define MODULE_SUPPORTED_DEVICE(name)
|
|
|
|
#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
|
|
|
|
struct modversion_info {
|
|
unsigned long crc;
|
|
char name[MODULE_NAME_LEN];
|
|
};
|
|
|
|
struct module;
|
|
struct exception_table_entry;
|
|
|
|
struct module_kobject {
|
|
struct kobject kobj;
|
|
struct module *mod;
|
|
struct kobject *drivers_dir;
|
|
struct module_param_attrs *mp;
|
|
struct completion *kobj_completion;
|
|
} __randomize_layout;
|
|
|
|
struct module_attribute {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct module_attribute *, struct module_kobject *,
|
|
char *);
|
|
ssize_t (*store)(struct module_attribute *, struct module_kobject *,
|
|
const char *, size_t count);
|
|
void (*setup)(struct module *, const char *);
|
|
int (*test)(struct module *);
|
|
void (*free)(struct module *);
|
|
};
|
|
|
|
struct module_version_attribute {
|
|
struct module_attribute mattr;
|
|
const char *module_name;
|
|
const char *version;
|
|
} __attribute__ ((__aligned__(sizeof(void *))));
|
|
|
|
extern ssize_t __modver_version_show(struct module_attribute *,
|
|
struct module_kobject *, char *);
|
|
|
|
extern struct module_attribute module_uevent;
|
|
|
|
/* These are either module local, or the kernel's dummy ones. */
|
|
extern int init_module(void);
|
|
extern void cleanup_module(void);
|
|
|
|
#ifndef MODULE
|
|
/**
|
|
* module_init() - driver initialization entry point
|
|
* @x: function to be run at kernel boot time or module insertion
|
|
*
|
|
* module_init() will either be called during do_initcalls() (if
|
|
* builtin) or at module insertion time (if a module). There can only
|
|
* be one per module.
|
|
*/
|
|
#define module_init(x) __initcall(x);
|
|
|
|
/**
|
|
* module_exit() - driver exit entry point
|
|
* @x: function to be run when driver is removed
|
|
*
|
|
* module_exit() will wrap the driver clean-up code
|
|
* with cleanup_module() when used with rmmod when
|
|
* the driver is a module. If the driver is statically
|
|
* compiled into the kernel, module_exit() has no effect.
|
|
* There can only be one per module.
|
|
*/
|
|
#define module_exit(x) __exitcall(x);
|
|
|
|
#else /* MODULE */
|
|
|
|
/*
|
|
* In most cases loadable modules do not need custom
|
|
* initcall levels. There are still some valid cases where
|
|
* a driver may be needed early if built in, and does not
|
|
* matter when built as a loadable module. Like bus
|
|
* snooping debug drivers.
|
|
*/
|
|
#define early_initcall(fn) module_init(fn)
|
|
#define core_initcall(fn) module_init(fn)
|
|
#define core_initcall_sync(fn) module_init(fn)
|
|
#define postcore_initcall(fn) module_init(fn)
|
|
#define postcore_initcall_sync(fn) module_init(fn)
|
|
#define arch_initcall(fn) module_init(fn)
|
|
#define subsys_initcall(fn) module_init(fn)
|
|
#define subsys_initcall_sync(fn) module_init(fn)
|
|
#define fs_initcall(fn) module_init(fn)
|
|
#define fs_initcall_sync(fn) module_init(fn)
|
|
#define rootfs_initcall(fn) module_init(fn)
|
|
#define device_initcall(fn) module_init(fn)
|
|
#define device_initcall_sync(fn) module_init(fn)
|
|
#define late_initcall(fn) module_init(fn)
|
|
#define late_initcall_sync(fn) module_init(fn)
|
|
|
|
#define console_initcall(fn) module_init(fn)
|
|
|
|
/* Each module must use one module_init(). */
|
|
#define module_init(initfn) \
|
|
static inline initcall_t __maybe_unused __inittest(void) \
|
|
{ return initfn; } \
|
|
int init_module(void) __copy(initfn) \
|
|
__attribute__((alias(#initfn))); \
|
|
__CFI_ADDRESSABLE(init_module)
|
|
|
|
/* This is only required if you want to be unloadable. */
|
|
#define module_exit(exitfn) \
|
|
static inline exitcall_t __maybe_unused __exittest(void) \
|
|
{ return exitfn; } \
|
|
void cleanup_module(void) __copy(exitfn) \
|
|
__attribute__((alias(#exitfn))); \
|
|
__CFI_ADDRESSABLE(cleanup_module)
|
|
|
|
#endif
|
|
|
|
/* This means "can be init if no module support, otherwise module load
|
|
may call it." */
|
|
#ifdef CONFIG_MODULES
|
|
#define __init_or_module
|
|
#define __initdata_or_module
|
|
#define __initconst_or_module
|
|
#define __INIT_OR_MODULE .text
|
|
#define __INITDATA_OR_MODULE .data
|
|
#define __INITRODATA_OR_MODULE .section ".rodata","a",%progbits
|
|
#else
|
|
#define __init_or_module __init
|
|
#define __initdata_or_module __initdata
|
|
#define __initconst_or_module __initconst
|
|
#define __INIT_OR_MODULE __INIT
|
|
#define __INITDATA_OR_MODULE __INITDATA
|
|
#define __INITRODATA_OR_MODULE __INITRODATA
|
|
#endif /*CONFIG_MODULES*/
|
|
|
|
/* Generic info of form tag = "info" */
|
|
#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
|
|
|
|
/* For userspace: you can also call me... */
|
|
#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
|
|
|
|
/* Soft module dependencies. See man modprobe.d for details.
|
|
* Example: MODULE_SOFTDEP("pre: module-foo module-bar post: module-baz")
|
|
*/
|
|
#define MODULE_SOFTDEP(_softdep) MODULE_INFO(softdep, _softdep)
|
|
|
|
/*
|
|
* MODULE_FILE is used for generating modules.builtin
|
|
* So, make it no-op when this is being built as a module
|
|
*/
|
|
#ifdef MODULE
|
|
#define MODULE_FILE
|
|
#else
|
|
#define MODULE_FILE MODULE_INFO(file, KBUILD_MODFILE);
|
|
#endif
|
|
|
|
/*
|
|
* The following license idents are currently accepted as indicating free
|
|
* software modules
|
|
*
|
|
* "GPL" [GNU Public License v2]
|
|
* "GPL v2" [GNU Public License v2]
|
|
* "GPL and additional rights" [GNU Public License v2 rights and more]
|
|
* "Dual BSD/GPL" [GNU Public License v2
|
|
* or BSD license choice]
|
|
* "Dual MIT/GPL" [GNU Public License v2
|
|
* or MIT license choice]
|
|
* "Dual MPL/GPL" [GNU Public License v2
|
|
* or Mozilla license choice]
|
|
*
|
|
* The following other idents are available
|
|
*
|
|
* "Proprietary" [Non free products]
|
|
*
|
|
* Both "GPL v2" and "GPL" (the latter also in dual licensed strings) are
|
|
* merely stating that the module is licensed under the GPL v2, but are not
|
|
* telling whether "GPL v2 only" or "GPL v2 or later". The reason why there
|
|
* are two variants is a historic and failed attempt to convey more
|
|
* information in the MODULE_LICENSE string. For module loading the
|
|
* "only/or later" distinction is completely irrelevant and does neither
|
|
* replace the proper license identifiers in the corresponding source file
|
|
* nor amends them in any way. The sole purpose is to make the
|
|
* 'Proprietary' flagging work and to refuse to bind symbols which are
|
|
* exported with EXPORT_SYMBOL_GPL when a non free module is loaded.
|
|
*
|
|
* In the same way "BSD" is not a clear license information. It merely
|
|
* states, that the module is licensed under one of the compatible BSD
|
|
* license variants. The detailed and correct license information is again
|
|
* to be found in the corresponding source files.
|
|
*
|
|
* There are dual licensed components, but when running with Linux it is the
|
|
* GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
|
|
* is a GPL combined work.
|
|
*
|
|
* This exists for several reasons
|
|
* 1. So modinfo can show license info for users wanting to vet their setup
|
|
* is free
|
|
* 2. So the community can ignore bug reports including proprietary modules
|
|
* 3. So vendors can do likewise based on their own policies
|
|
*/
|
|
#define MODULE_LICENSE(_license) MODULE_FILE MODULE_INFO(license, _license)
|
|
|
|
/*
|
|
* Author(s), use "Name <email>" or just "Name", for multiple
|
|
* authors use multiple MODULE_AUTHOR() statements/lines.
|
|
*/
|
|
#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
|
|
|
|
/* What your module does. */
|
|
#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
|
|
|
|
#ifdef MODULE
|
|
/* Creates an alias so file2alias.c can find device table. */
|
|
#define MODULE_DEVICE_TABLE(type, name) \
|
|
extern typeof(name) __mod_##type##__##name##_device_table \
|
|
__attribute__ ((unused, alias(__stringify(name))))
|
|
#else /* !MODULE */
|
|
#define MODULE_DEVICE_TABLE(type, name)
|
|
#endif
|
|
|
|
/* Version of form [<epoch>:]<version>[-<extra-version>].
|
|
* Or for CVS/RCS ID version, everything but the number is stripped.
|
|
* <epoch>: A (small) unsigned integer which allows you to start versions
|
|
* anew. If not mentioned, it's zero. eg. "2:1.0" is after
|
|
* "1:2.0".
|
|
|
|
* <version>: The <version> may contain only alphanumerics and the
|
|
* character `.'. Ordered by numeric sort for numeric parts,
|
|
* ascii sort for ascii parts (as per RPM or DEB algorithm).
|
|
|
|
* <extraversion>: Like <version>, but inserted for local
|
|
* customizations, eg "rh3" or "rusty1".
|
|
|
|
* Using this automatically adds a checksum of the .c files and the
|
|
* local headers in "srcversion".
|
|
*/
|
|
|
|
#if defined(MODULE) || !defined(CONFIG_SYSFS)
|
|
#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
|
|
#else
|
|
#define MODULE_VERSION(_version) \
|
|
MODULE_INFO(version, _version); \
|
|
static struct module_version_attribute ___modver_attr = { \
|
|
.mattr = { \
|
|
.attr = { \
|
|
.name = "version", \
|
|
.mode = S_IRUGO, \
|
|
}, \
|
|
.show = __modver_version_show, \
|
|
}, \
|
|
.module_name = KBUILD_MODNAME, \
|
|
.version = _version, \
|
|
}; \
|
|
static const struct module_version_attribute \
|
|
__used __section("__modver") \
|
|
* __moduleparam_const __modver_attr = &___modver_attr
|
|
#endif
|
|
|
|
/* Optional firmware file (or files) needed by the module
|
|
* format is simply firmware file name. Multiple firmware
|
|
* files require multiple MODULE_FIRMWARE() specifiers */
|
|
#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
|
|
|
|
#define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, __stringify(ns))
|
|
|
|
struct notifier_block;
|
|
|
|
#ifdef CONFIG_MODULES
|
|
|
|
extern int modules_disabled; /* for sysctl */
|
|
/* Get/put a kernel symbol (calls must be symmetric) */
|
|
void *__symbol_get(const char *symbol);
|
|
void *__symbol_get_gpl(const char *symbol);
|
|
#define symbol_get(x) ((typeof(&x))(__symbol_get(__stringify(x))))
|
|
|
|
/* modules using other modules: kdb wants to see this. */
|
|
struct module_use {
|
|
struct list_head source_list;
|
|
struct list_head target_list;
|
|
struct module *source, *target;
|
|
};
|
|
|
|
enum module_state {
|
|
MODULE_STATE_LIVE, /* Normal state. */
|
|
MODULE_STATE_COMING, /* Full formed, running module_init. */
|
|
MODULE_STATE_GOING, /* Going away. */
|
|
MODULE_STATE_UNFORMED, /* Still setting it up. */
|
|
};
|
|
|
|
struct mod_tree_node {
|
|
struct module *mod;
|
|
struct latch_tree_node node;
|
|
};
|
|
|
|
struct module_layout {
|
|
/* The actual code + data. */
|
|
void *base;
|
|
/* Total size. */
|
|
unsigned int size;
|
|
/* The size of the executable code. */
|
|
unsigned int text_size;
|
|
/* Size of RO section of the module (text+rodata) */
|
|
unsigned int ro_size;
|
|
/* Size of RO after init section */
|
|
unsigned int ro_after_init_size;
|
|
|
|
#ifdef CONFIG_MODULES_TREE_LOOKUP
|
|
struct mod_tree_node mtn;
|
|
#endif
|
|
};
|
|
|
|
#ifdef CONFIG_MODULES_TREE_LOOKUP
|
|
/* Only touch one cacheline for common rbtree-for-core-layout case. */
|
|
#define __module_layout_align ____cacheline_aligned
|
|
#else
|
|
#define __module_layout_align
|
|
#endif
|
|
|
|
struct mod_kallsyms {
|
|
Elf_Sym *symtab;
|
|
unsigned int num_symtab;
|
|
char *strtab;
|
|
char *typetab;
|
|
};
|
|
|
|
#ifdef CONFIG_LIVEPATCH
|
|
struct klp_modinfo {
|
|
Elf_Ehdr hdr;
|
|
Elf_Shdr *sechdrs;
|
|
char *secstrings;
|
|
unsigned int symndx;
|
|
};
|
|
#endif
|
|
|
|
struct module {
|
|
enum module_state state;
|
|
|
|
/* Member of list of modules */
|
|
struct list_head list;
|
|
|
|
/* Unique handle for this module */
|
|
char name[MODULE_NAME_LEN];
|
|
|
|
/* Sysfs stuff. */
|
|
struct module_kobject mkobj;
|
|
struct module_attribute *modinfo_attrs;
|
|
const char *version;
|
|
const char *srcversion;
|
|
const char *scmversion;
|
|
struct kobject *holders_dir;
|
|
|
|
/* Exported symbols */
|
|
const struct kernel_symbol *syms;
|
|
const s32 *crcs;
|
|
unsigned int num_syms;
|
|
|
|
#ifdef CONFIG_CFI_CLANG
|
|
cfi_check_fn cfi_check;
|
|
#endif
|
|
|
|
/* Kernel parameters. */
|
|
#ifdef CONFIG_SYSFS
|
|
struct mutex param_lock;
|
|
#endif
|
|
struct kernel_param *kp;
|
|
unsigned int num_kp;
|
|
|
|
/* GPL-only exported symbols. */
|
|
unsigned int num_gpl_syms;
|
|
const struct kernel_symbol *gpl_syms;
|
|
const s32 *gpl_crcs;
|
|
bool using_gplonly_symbols;
|
|
|
|
#ifdef CONFIG_UNUSED_SYMBOLS
|
|
/* unused exported symbols. */
|
|
const struct kernel_symbol *unused_syms;
|
|
const s32 *unused_crcs;
|
|
unsigned int num_unused_syms;
|
|
|
|
/* GPL-only, unused exported symbols. */
|
|
unsigned int num_unused_gpl_syms;
|
|
const struct kernel_symbol *unused_gpl_syms;
|
|
const s32 *unused_gpl_crcs;
|
|
#endif
|
|
|
|
/*
|
|
* Signature was verified. Unconditionally compiled in Android to
|
|
* preserve ABI compatibility between kernels without module
|
|
* signing enabled and signed modules.
|
|
*/
|
|
bool sig_ok;
|
|
|
|
bool async_probe_requested;
|
|
|
|
/* symbols that will be GPL-only in the near future. */
|
|
const struct kernel_symbol *gpl_future_syms;
|
|
const s32 *gpl_future_crcs;
|
|
unsigned int num_gpl_future_syms;
|
|
|
|
/* Exception table */
|
|
unsigned int num_exentries;
|
|
struct exception_table_entry *extable;
|
|
|
|
/* Startup function. */
|
|
int (*init)(void);
|
|
|
|
/* Core layout: rbtree is accessed frequently, so keep together. */
|
|
struct module_layout core_layout __module_layout_align;
|
|
struct module_layout init_layout;
|
|
|
|
/* Arch-specific module values */
|
|
struct mod_arch_specific arch;
|
|
|
|
unsigned long taints; /* same bits as kernel:taint_flags */
|
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
/* Support for BUG */
|
|
unsigned num_bugs;
|
|
struct list_head bug_list;
|
|
struct bug_entry *bug_table;
|
|
#endif
|
|
|
|
#ifdef CONFIG_KALLSYMS
|
|
/* Protected by RCU and/or module_mutex: use rcu_dereference() */
|
|
struct mod_kallsyms __rcu *kallsyms;
|
|
struct mod_kallsyms core_kallsyms;
|
|
|
|
/* Section attributes */
|
|
struct module_sect_attrs *sect_attrs;
|
|
|
|
/* Notes attributes */
|
|
struct module_notes_attrs *notes_attrs;
|
|
#endif
|
|
|
|
/* The command line arguments (may be mangled). People like
|
|
keeping pointers to this stuff */
|
|
char *args;
|
|
|
|
#ifdef CONFIG_SMP
|
|
/* Per-cpu data. */
|
|
void __percpu *percpu;
|
|
unsigned int percpu_size;
|
|
#endif
|
|
void *noinstr_text_start;
|
|
unsigned int noinstr_text_size;
|
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
unsigned int num_tracepoints;
|
|
tracepoint_ptr_t *tracepoints_ptrs;
|
|
#endif
|
|
#ifdef CONFIG_TREE_SRCU
|
|
unsigned int num_srcu_structs;
|
|
struct srcu_struct **srcu_struct_ptrs;
|
|
#endif
|
|
#ifdef CONFIG_BPF_EVENTS
|
|
unsigned int num_bpf_raw_events;
|
|
struct bpf_raw_event_map *bpf_raw_events;
|
|
#endif
|
|
#ifdef CONFIG_JUMP_LABEL
|
|
struct jump_entry *jump_entries;
|
|
unsigned int num_jump_entries;
|
|
#endif
|
|
#ifdef CONFIG_TRACING
|
|
unsigned int num_trace_bprintk_fmt;
|
|
const char **trace_bprintk_fmt_start;
|
|
#endif
|
|
#ifdef CONFIG_EVENT_TRACING
|
|
struct trace_event_call **trace_events;
|
|
unsigned int num_trace_events;
|
|
struct trace_eval_map **trace_evals;
|
|
unsigned int num_trace_evals;
|
|
#endif
|
|
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
|
unsigned int num_ftrace_callsites;
|
|
unsigned long *ftrace_callsites;
|
|
#endif
|
|
#ifdef CONFIG_KPROBES
|
|
void *kprobes_text_start;
|
|
unsigned int kprobes_text_size;
|
|
unsigned long *kprobe_blacklist;
|
|
unsigned int num_kprobe_blacklist;
|
|
#endif
|
|
#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
|
|
int num_static_call_sites;
|
|
struct static_call_site *static_call_sites;
|
|
#endif
|
|
|
|
#ifdef CONFIG_LIVEPATCH
|
|
bool klp; /* Is this a livepatch module? */
|
|
bool klp_alive;
|
|
|
|
/* Elf information */
|
|
struct klp_modinfo *klp_info;
|
|
#endif
|
|
|
|
#ifdef CONFIG_MODULE_UNLOAD
|
|
/* What modules depend on me? */
|
|
struct list_head source_list;
|
|
/* What modules do I depend on? */
|
|
struct list_head target_list;
|
|
|
|
/* Destruction function. */
|
|
void (*exit)(void);
|
|
|
|
atomic_t refcnt;
|
|
#endif
|
|
|
|
#ifdef CONFIG_MITIGATION_ITS
|
|
int its_num_pages;
|
|
void **its_page_array;
|
|
#endif
|
|
|
|
#ifdef CONFIG_CONSTRUCTORS
|
|
/* Constructor functions. */
|
|
ctor_fn_t *ctors;
|
|
unsigned int num_ctors;
|
|
#endif
|
|
|
|
#ifdef CONFIG_FUNCTION_ERROR_INJECTION
|
|
struct error_injection_entry *ei_funcs;
|
|
unsigned int num_ei_funcs;
|
|
#endif
|
|
ANDROID_KABI_RESERVE(1);
|
|
ANDROID_KABI_RESERVE(2);
|
|
ANDROID_KABI_RESERVE(3);
|
|
ANDROID_KABI_RESERVE(4);
|
|
} ____cacheline_aligned __randomize_layout;
|
|
#ifndef MODULE_ARCH_INIT
|
|
#define MODULE_ARCH_INIT {}
|
|
#endif
|
|
|
|
#ifndef HAVE_ARCH_KALLSYMS_SYMBOL_VALUE
|
|
static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)
|
|
{
|
|
return sym->st_value;
|
|
}
|
|
#endif
|
|
|
|
extern struct mutex module_mutex;
|
|
|
|
/* FIXME: It'd be nice to isolate modules during init, too, so they
|
|
aren't used before they (may) fail. But presently too much code
|
|
(IDE & SCSI) require entry into the module during init.*/
|
|
static inline bool module_is_live(struct module *mod)
|
|
{
|
|
return mod->state != MODULE_STATE_GOING;
|
|
}
|
|
|
|
struct module *__module_text_address(unsigned long addr);
|
|
struct module *__module_address(unsigned long addr);
|
|
bool is_module_address(unsigned long addr);
|
|
bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr);
|
|
bool is_module_percpu_address(unsigned long addr);
|
|
bool is_module_text_address(unsigned long addr);
|
|
|
|
static inline bool within_module_core(unsigned long addr,
|
|
const struct module *mod)
|
|
{
|
|
return (unsigned long)mod->core_layout.base <= addr &&
|
|
addr < (unsigned long)mod->core_layout.base + mod->core_layout.size;
|
|
}
|
|
|
|
static inline bool within_module_init(unsigned long addr,
|
|
const struct module *mod)
|
|
{
|
|
return (unsigned long)mod->init_layout.base <= addr &&
|
|
addr < (unsigned long)mod->init_layout.base + mod->init_layout.size;
|
|
}
|
|
|
|
static inline bool within_module(unsigned long addr, const struct module *mod)
|
|
{
|
|
return within_module_init(addr, mod) || within_module_core(addr, mod);
|
|
}
|
|
|
|
/* Search for module by name: must hold module_mutex. */
|
|
struct module *find_module(const char *name);
|
|
|
|
struct symsearch {
|
|
const struct kernel_symbol *start, *stop;
|
|
const s32 *crcs;
|
|
enum mod_license {
|
|
NOT_GPL_ONLY,
|
|
GPL_ONLY,
|
|
WILL_BE_GPL_ONLY,
|
|
} license;
|
|
bool unused;
|
|
};
|
|
|
|
/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
|
|
symnum out of range. */
|
|
int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
|
|
char *name, char *module_name, int *exported);
|
|
|
|
/* Look for this name: can be of form module:name. */
|
|
unsigned long module_kallsyms_lookup_name(const char *name);
|
|
|
|
int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
|
|
struct module *, unsigned long),
|
|
void *data);
|
|
|
|
extern void __noreturn __module_put_and_exit(struct module *mod,
|
|
long code);
|
|
#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code)
|
|
|
|
#ifdef CONFIG_MODULE_UNLOAD
|
|
int module_refcount(struct module *mod);
|
|
void __symbol_put(const char *symbol);
|
|
#define symbol_put(x) __symbol_put(__stringify(x))
|
|
void symbol_put_addr(void *addr);
|
|
|
|
/* Sometimes we know we already have a refcount, and it's easier not
|
|
to handle the error case (which only happens with rmmod --wait). */
|
|
extern void __module_get(struct module *module);
|
|
|
|
/* This is the Right Way to get a module: if it fails, it's being removed,
|
|
* so pretend it's not there. */
|
|
extern bool try_module_get(struct module *module);
|
|
|
|
extern void module_put(struct module *module);
|
|
|
|
#else /*!CONFIG_MODULE_UNLOAD*/
|
|
static inline bool try_module_get(struct module *module)
|
|
{
|
|
return !module || module_is_live(module);
|
|
}
|
|
static inline void module_put(struct module *module)
|
|
{
|
|
}
|
|
static inline void __module_get(struct module *module)
|
|
{
|
|
}
|
|
#define symbol_put(x) do { } while (0)
|
|
#define symbol_put_addr(p) do { } while (0)
|
|
|
|
#endif /* CONFIG_MODULE_UNLOAD */
|
|
|
|
/* This is a #define so the string doesn't get put in every .o file */
|
|
#define module_name(mod) \
|
|
({ \
|
|
struct module *__mod = (mod); \
|
|
__mod ? __mod->name : "kernel"; \
|
|
})
|
|
|
|
/* Dereference module function descriptor */
|
|
void *dereference_module_function_descriptor(struct module *mod, void *ptr);
|
|
|
|
/* For kallsyms to ask for address resolution. namebuf should be at
|
|
* least KSYM_NAME_LEN long: a pointer to namebuf is returned if
|
|
* found, otherwise NULL. */
|
|
const char *module_address_lookup(unsigned long addr,
|
|
unsigned long *symbolsize,
|
|
unsigned long *offset,
|
|
char **modname,
|
|
char *namebuf);
|
|
int lookup_module_symbol_name(unsigned long addr, char *symname);
|
|
int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
|
|
|
|
int register_module_notifier(struct notifier_block *nb);
|
|
int unregister_module_notifier(struct notifier_block *nb);
|
|
|
|
extern void print_modules(void);
|
|
|
|
static inline bool module_requested_async_probing(struct module *module)
|
|
{
|
|
return module && module->async_probe_requested;
|
|
}
|
|
|
|
#ifdef CONFIG_LIVEPATCH
|
|
static inline bool is_livepatch_module(struct module *mod)
|
|
{
|
|
return mod->klp;
|
|
}
|
|
#else /* !CONFIG_LIVEPATCH */
|
|
static inline bool is_livepatch_module(struct module *mod)
|
|
{
|
|
return false;
|
|
}
|
|
#endif /* CONFIG_LIVEPATCH */
|
|
|
|
bool is_module_sig_enforced(void);
|
|
void set_module_sig_enforced(void);
|
|
|
|
#else /* !CONFIG_MODULES... */
|
|
|
|
static inline struct module *__module_address(unsigned long addr)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline struct module *__module_text_address(unsigned long addr)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline bool is_module_address(unsigned long addr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool is_module_percpu_address(unsigned long addr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool is_module_text_address(unsigned long addr)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool within_module_core(unsigned long addr,
|
|
const struct module *mod)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool within_module_init(unsigned long addr,
|
|
const struct module *mod)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool within_module(unsigned long addr, const struct module *mod)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/* Get/put a kernel symbol (calls should be symmetric) */
|
|
#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak,visibility("hidden"))); &(x); })
|
|
#define symbol_put(x) do { } while (0)
|
|
#define symbol_put_addr(x) do { } while (0)
|
|
|
|
static inline void __module_get(struct module *module)
|
|
{
|
|
}
|
|
|
|
static inline bool try_module_get(struct module *module)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline void module_put(struct module *module)
|
|
{
|
|
}
|
|
|
|
#define module_name(mod) "kernel"
|
|
|
|
/* For kallsyms to ask for address resolution. NULL means not found. */
|
|
static inline const char *module_address_lookup(unsigned long addr,
|
|
unsigned long *symbolsize,
|
|
unsigned long *offset,
|
|
char **modname,
|
|
char *namebuf)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
|
|
{
|
|
return -ERANGE;
|
|
}
|
|
|
|
static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
|
|
{
|
|
return -ERANGE;
|
|
}
|
|
|
|
static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
|
|
char *type, char *name,
|
|
char *module_name, int *exported)
|
|
{
|
|
return -ERANGE;
|
|
}
|
|
|
|
static inline unsigned long module_kallsyms_lookup_name(const char *name)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
|
|
struct module *,
|
|
unsigned long),
|
|
void *data)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline int register_module_notifier(struct notifier_block *nb)
|
|
{
|
|
/* no events will happen anyway, so this can always succeed */
|
|
return 0;
|
|
}
|
|
|
|
static inline int unregister_module_notifier(struct notifier_block *nb)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#define module_put_and_exit(code) do_exit(code)
|
|
|
|
static inline void print_modules(void)
|
|
{
|
|
}
|
|
|
|
static inline bool module_requested_async_probing(struct module *module)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool is_module_sig_enforced(void)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline void set_module_sig_enforced(void)
|
|
{
|
|
}
|
|
|
|
/* Dereference module function descriptor */
|
|
static inline
|
|
void *dereference_module_function_descriptor(struct module *mod, void *ptr)
|
|
{
|
|
return ptr;
|
|
}
|
|
|
|
#endif /* CONFIG_MODULES */
|
|
|
|
#ifdef CONFIG_SYSFS
|
|
extern struct kset *module_kset;
|
|
extern struct kobj_type module_ktype;
|
|
extern int module_sysfs_initialized;
|
|
#endif /* CONFIG_SYSFS */
|
|
|
|
#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
|
|
|
|
/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
|
|
|
|
#define __MODULE_STRING(x) __stringify(x)
|
|
|
|
#ifdef CONFIG_GENERIC_BUG
|
|
void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
|
|
struct module *);
|
|
void module_bug_cleanup(struct module *);
|
|
|
|
#else /* !CONFIG_GENERIC_BUG */
|
|
|
|
static inline void module_bug_finalize(const Elf_Ehdr *hdr,
|
|
const Elf_Shdr *sechdrs,
|
|
struct module *mod)
|
|
{
|
|
}
|
|
static inline void module_bug_cleanup(struct module *mod) {}
|
|
#endif /* CONFIG_GENERIC_BUG */
|
|
|
|
#ifdef CONFIG_RETPOLINE
|
|
extern bool retpoline_module_ok(bool has_retpoline);
|
|
#else
|
|
static inline bool retpoline_module_ok(bool has_retpoline)
|
|
{
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_MODULE_SIG
|
|
static inline bool module_sig_ok(struct module *module)
|
|
{
|
|
return module->sig_ok;
|
|
}
|
|
#else /* !CONFIG_MODULE_SIG */
|
|
static inline bool module_sig_ok(struct module *module)
|
|
{
|
|
return true;
|
|
}
|
|
#endif /* CONFIG_MODULE_SIG */
|
|
|
|
#endif /* _LINUX_MODULE_H */
|