init_module(2) System Calls Manual init_module(2) init_module, finit_module - C (libc, -lc) #include /* MODULE_* */ #include /* SYS_* */ #include int syscall(SYS_init_module, void module_image[.len], unsigned long len, const char *param_values); int syscall(SYS_finit_module, int fd, const char *param_values, int flags); : glibc , syscall(2). init_module() ELF , , , init. . module_image , ; len . ELF, . param_values , ( ), module_param() module_param_array(). . : name[ =value [,value...]] -- module_param() ( Linux include/linux/moduleparam.h). bool invbool. . finit_module() finit_module() init_module(), fd. , ; . param_values init_module(). flags finit_module(). , : MODULE_INIT_IGNORE_MODVERSIONS . MODULE_INIT_IGNORE_VERMAGIC . MODULE_INIT_COMPRESSED_FILE (since Linux 5.17) Use in-kernel module decompression. , , , . . -, <>, ( ). -, CONFIG_MODVERSIONS, . . <> , , . MODULE_INIT_IGNORE_VERMAGIC <>, MODULE_INIT_IGNORE_MODVERSIONS . ( CONFIG_MODULE_FORCE_LOAD), , ENOEXEC, . If the kernel was build with CONFIG_MODULE_DECOMPRESS, the in-kernel decompression feature can be used. User-space code can check if the kernel supports decompression by reading the /sys/module/compression attribute. If the kernel supports decompression, the compressed file can directly be passed to finit_module() using the MODULE_INIT_COMPRESSED_FILE flag. The in-kernel module decompressor supports the following compression algorithms: o gzip (since Linux 5.17) o xz (since Linux 5.17) o zstd (since Linux 6.2) The kernel only implements a single decompression method. This is selected during module generation accordingly to the compression method chosen in the kernel configuration. On success, these system calls return 0. On error, -1 is returned and errno is set to indicate the error. EBADMSG ( Linux 3.7) . EBUSY . EFAULT . ENOKEY ( Linux 3.7) . , CONFIG_MODULE_SIG_FORCE; , (taints) . ENOMEM . EPERM ( CAP_SYS_MODULE), ( /proc/sys/kernel/modules_disabled proc(5)). init_module() : EEXIST . EINVAL param_values, - ELF module_image . ENOEXEC , module_image, ELF, ELF . finit_module() : EBADF , fd, . EFBIG , fd, . EINVAL flags . EINVAL The decompressor sanity checks failed, while loading a compressed module with flag MODULE_INIT_COMPRESSED_FILE set. ENOEXEC fd . EOPNOTSUPP (since Linux 5.17) The flag MODULE_INIT_COMPRESSED_FILE is set to load a compressed module, and the kernel was built without CONFIG_MODULE_DECOMPRESS. ETXTBSY ( Linux 4.7) The file referred to by fd is opened for read-write. , init , init_module() finit_module() errno , init. Linux. finit_module() Linux 3.8. The init_module() system call is not supported by glibc. No declaration is provided in glibc headers, but, through a quirk of history, glibc versions before glibc 2.23 did export an ABI for this system call. Therefore, in order to employ this system call, it is (before glibc 2.23) sufficient to manually declare the interface in your code; alternatively, you can invoke the system call using syscall(2). Linux 2.4 Linux 2.4 init_module() : #include int init_module(const char *name, struct module *image); ( init_module() , query_module(); ENOSYS Linux 2.6 .) image, init. ( Linux 2.6, init_module() ). , . Linux 2.2 : struct module { unsigned long size_of_struct; struct module *next; const char *name; unsigned long size; long usecount; unsigned long flags; unsigned int nsyms; unsigned int ndeps; struct module_symbol *syms; struct module_ref *deps; struct module_ref *refs; int (*init)(void); void (*cleanup)(void); const struct exception_table_entry *ex_table_start; const struct exception_table_entry *ex_table_end; #ifdef __alpha__ unsigned long gp; #endif }; , next refs, , . /proc/modules /sys/module. include/linux/module.h Linux. create_module(2), delete_module(2), query_module(2), lsmod(8), modprobe(8) () Azamat Hackimov , Dmitriy S. Seregin , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 2 2024 . init_module(2)