summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* modprobe: rmmod_do_module: Free kmod list of holdersHEADmasterNicolas Schier2023-04-181-0/+1
| | | | | | | | Add a missing kmod_module_unref_list() to fix a memory leak. Fixes: 42b32d30c38e ("modprobe: Fix holders removal") Signed-off-by: Nicolas Schier <n.schier@avm.de> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* configure.ac: fix link with -llzmaFabrice Fontaine2023-03-061-4/+4
| | | | | | | | | | | | | | | | Add liblzma_LIBS to LIBS to avoid the following build failure when building with a static-only liblzma.a: /home/autobuild/autobuild/instance-5/output-1/host/lib/gcc/xtensa-buildroot-linux-uclibc/11.3.0/../../../../xtensa-buildroot-linux-uclibc/bin/ld: libkmod/.libs/libkmod-internal.a(libkmod-file.o):(.text.xz_uncompress+0x10): undefined reference to `lzma_code' For consistency, also update libzstd, zlib and libcrypto Fixes: - http://autobuild.buildroot.org/results/83a4a7ecc77f39639d3e5bc8554bd01a62a3ede0 References: https://github.com/kmod-project/kmod/pull/25 Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* configure: manage libkmod.pc.in and version.py.in via AC_CONFIG_FILESEmil Velikov2023-02-212-25/+2
| | | | | | | | | | | | | Replace the manual sed command, build rules and dist/clean for using AC_CONFIG_FILES. It does the exact same thing, with an added bonus... Currently we're missing version.py.in in the EXTRA_DIST. Thus a simple "touch Makefile" should retrigger the regeneration of version.py. Which would presumably fail, since the input file isn't in the distribution tarball. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* shared: annotate local API as staticEmil Velikov2023-02-212-6/+3
| | | | | | | None of the API is used outside of the compilation unit. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* libkmod: annotate kmod_builtin_iter API as staticEmil Velikov2023-02-212-9/+4
| | | | | | | It's no longer used outside the compilation unit, as of last commit. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* libkmod: remove unused kmod_module_get_builtinEmil Velikov2023-02-212-44/+0
| | | | | | | | The last and only user was removed with commit 0246e06 ("depmod: Stop opening modules.modinfo once per module") Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* testsuite: Handle different sysconfdirLucas De Marchi2023-02-106-32/+9
| | | | | | | | Instead of skipping tests if sysconfdir isn't /etc, just handle it during the rootfs setup logic. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* testsuite: Move setup-rootfs logic from Makefile to scriptLucas De Marchi2023-02-102-10/+19
| | | | | | | | | It's easier to implement the logic outside of the Makefile, so rename the populate-modules.sh script to setup-rootfs.sh and move the additional logic from the makefile to the script. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
* libkmod: error out on unknown hash algorithmEmil Velikov2023-02-091-1/+5
| | | | | | | | | | | Currently if we see unknown algorithm, we'll do an OOB read in pkey_hash_algo. This can happen for example if OPENSSL_NO_SM3 is set and the kernel module uses a SM3 hash. Cc: Mikhail Novosyolov <m.novosyolov@rosalinux.ru> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* testsuite/depmod: use defines for the rootfs/lib_modulesEmil Velikov2023-02-091-23/+27
| | | | | | | | | The uname used across the tests is same, so drop "_ORDER" from the macro name and use it throughout. Similarly - add respective LIB_MODULES defines and use them in the tests. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* testsuite: add function declarations for __xstat familyEmil Velikov2023-02-091-1/+8
| | | | | | | | | | | As the inline comment says - the declarations have been dropped with glibc 2.32.9000, as a result the build throws a set of lovely warnings. Inspired by umockdev, which bears the same license as this project. https://github.com/martinpitt/umockdev/commit/f1b416400479d861deffb4c5a40422dcdf190e85 Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* treewide: add some static const notationsEmil Velikov2023-02-096-12/+12
| | | | | Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* depmod: Introduce outdir optionEmil Velikov2023-02-098-3/+128
| | | | | | | | | | | | This option is equivalent to basedir, with the small difference being that's where the meta-data files are generated. In other words, this allows us to have read-only input modules and modules.dep, while still being able to generate the meta-data files. Signed-off-by: Emil Velikov <emil.velikov@collabora.com> [ Move files to a different dir so input files (produced by kernel build system is separate from the files generated by depmod (output) ] Signed-off-by: Lucas De Marchi <lucas.demarchi@gmail.com>
* man/rmmod: explain why modprobe -r is more usefulYauheni Kaliuta2023-02-081-1/+2
| | | | | | | | | Improve user experience by explaining the option so the user may not search explanations in other manpages (modprobe). Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: Allow passing path to moduleGustavo Sousa2023-01-1324-10/+91
| | | | | | | | | | | | | | | | This is useful to kernel module developers for testing a just compiled module: instead of using insmod, they can load the module from the path while getting all the benefits of modprobe (e.g. module dependency resolution). v2: - Add test for relative path as well. (Lucas) - Add note warning about modules with dependencies not matching the installed depmod database. (Lucas) Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: Move insertion block into separate functionGustavo Sousa2023-01-131-35/+42
| | | | | | | | | That same logic will be used for enabling modprobe for paths in the next patch. As such, prepare for that by extracting that block into its own function. Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* testsuite: Wrap chdir()Gustavo Sousa2023-01-131-0/+1
| | | | | | | | One of the tests in an upcoming patch will need to change into a specific directory to test loading a module from a relative path. Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* kmod: configure.ac: In _Noreturn check, include <stdlib.h> for exitFlorian Weimer2022-12-261-1/+2
| | | | | | | | Otherwise, an implicit functiona declaration is used, causing a C99 compatibility issue. Signed-off-by: Florian Weimer <fweimer@redhat.com> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* autogen.sh: remove --with-rootprefix, it is gone since kmod-11Adam Gołębiowski2022-11-301-1/+0
| | | | Signed-off-by: Adam Gołębiowski <adamg@pld-linux.org>
* libkmod: do not crash on unknown signature algorithmMikhail Novosyolov2022-10-031-0/+3
| | | | | | | | | | | | | | | Example kernel module: https://file-store.rosalinux.ru/download/7281f97e0c04c0f818ad3f936706f4a407e8dc7e (/lib/modules/5.15.67-generic-1rosa2021.1-x86_64/kernel/drivers/usb/host/xhci-pci.ko.zst) It is signed with Streebog 512. libkmod v30 crashed in libkmod-module.c:2413 in this code: n = kmod_module_info_append(list, "sig_hashalgo", strlen("sig_hashalgo"), sig_info.hash_algo, strlen(sig_info.hash_algo)); because strlen() got null.
* testsuite: fix override of `stat` on 32-bit architecturesJulien Cristau2022-09-051-4/+5
| | | | | | | | | | | | | | | | | When _FILE_OFFSET_BITS is 64, glibc headers turn `stat` calls into `stat64`, and our `stat` override into a `stat64` function. However, because we use dlsym to get the address of libc's `stat`, we end up calling into the "real" `stat` function, which deals with 32-bit off_t, and we treat its result as if it were returned from stat64. On most architectures this seems to have been harmless, but on 32-bit mips, st_mode's offset in struct stat and struct stat64 are different, so we read garbage. To fix this, explicitly unset _FILE_OFFSET_BITS in path.c, to turn off the redirect magic in glibc headers, and override both the 32-bit and 64-bit functions so each call ends up wrapping the right libc function. Fixes #16 (https://github.com/kmod-project/kmod/issues/16)
* modprobe: Write error messages to syslog if stderr is unavailableQuentin Armitage2022-06-301-0/+7
| | | | | | | | The man page modprobe(8) states for the --syslog option: "This is also automatically enabled when stderr is unavailable." but it wasn't happening. This commit now makes modprobe write to syslog if stderr is closed.
* build: enable building & running tests from a subdirDimitri John Ledkov2022-06-301-0/+1
| | | | | | | | | During dpkg build, in a subdir, it is currently not possible to run tests. Building testsuite/modules due to non-existance of the testsuite directory under the build dir. Thus create it, when it is not there. Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
* testsuite: repair read of uninitialized memoryJan Engelhardt2022-06-301-1/+1
| | | | | | | | | Function ``test_backoff_time`` does not initialize ``delta``, and ``get_backoff_delta_msec`` then performs a read from uninitialized memory with the ``!*delta`` expression. Signed-off-by: Jan Engelhardt <jengelh@inai.de> Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* kmod 30v30Lucas De Marchi2022-06-303-5/+85
|
* libkmod: Support SM3 hash algorithmHuaxinLu2022-06-301-0/+6
| | | | | | | SM3 has been supported in kernel and cryptographic libraries like openssl. This patch adds support for the SM3 algorithm of kmod. Signed-off-by: HuaxinLu <luhuaxin1@huawei.com>
* README: Update optional dependenciesLucas De Marchi2022-06-291-0/+2
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* Keep only one readmeLucas De Marchi2022-06-281-126/+0
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: Add --waitLucas De Marchi2022-06-262-9/+78
| | | | | | | | Retry module removal if it fails due to EAGAIN. This allows user to pass --wait <timeout>, during which `modprobe -r` will keep trying to remove the module. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* testsuite: Add tests for sleep calculationLucas De Marchi2022-06-261-0/+41
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* util: Add exponential backoff sleepLucas De Marchi2022-06-262-0/+51
| | | | | | | Add simple functions to put the current thread to sleep using exponential backoff to split the interval in smaller pieces. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* util: Add msec variants for time-related functionsLucas De Marchi2022-06-262-0/+20
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* util: Add time-related functions from testsuiteLucas De Marchi2022-06-263-13/+19
| | | | | | | This will be useful in future not only to testsuite, but also to tools and library. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* module-playground: Add debugfs entry in mod-simpleLucas De Marchi2022-06-261-1/+17
| | | | | | | Add a debugfs file in mod-simple for manual tests: insert the module and open the file to have its refcount increased. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* libkmod: Allow to ignore log message on module removalLucas De Marchi2022-06-262-4/+11
| | | | | | | Caller may want to handle retries, in which case the log message is not appropriate. Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: Move -R to "Query options"Lucas De Marchi2022-06-261-4/+4
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: re-use modname variableLucas De Marchi2022-06-261-1/+1
| | | | Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* depmod: Fix writing over array lengthLucas De Marchi2022-06-261-0/+1
| | | | | | | | | | | | | | | | | | | | | Make sure return value in flush_stream_to() is the length written if the value didn't the size. Fix warning on gcc 12.1: tools/depmod.c: In function ‘output_builtin_alias_bin’: tools/depmod.c:2465:24: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds] 2465 | modname[len] = '\0'; | ~~~~~~~^~~~~ tools/depmod.c:2460:22: note: while referencing ‘modname’ 2460 | char modname[PATH_MAX]; | ^~~~~~~ tools/depmod.c:2477:22: warning: array subscript 4096 is above array bounds of ‘char[4096]’ [-Warray-bounds] 2477 | value[len] = '\0'; | ~~~~~^~~~~ tools/depmod.c:2461:22: note: while referencing ‘value’ 2461 | char value[PATH_MAX]; | ^~~~~ Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
* modprobe: Make rmmod_do_module() contain all the removal sequenceLucas De Marchi2022-04-061-15/+22
| | | | | | | | | | | | Move the remaining part of the removal sequence dangling in rmmod_do_remove_module() to rmmod_do_module() so we can consider this function is the one controlling all the module removals. While at it, add some comments about the removal order and normalize coding style in this function. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* modprobe: move check for remove_holders to callerLucas De Marchi2022-04-061-2/+4
| | | | | | | Do not mix the flags with and additional boolean from arguments. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* modprobe: Fix holders removalLucas De Marchi2022-04-061-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | The idea behind --remove-dependencies was to remove other modules that depend on the current module being removed. It's the reverse dependency list, not the dependency list of the current module: that never works since the current module would still hold a ref on it. Fix it by replacing the call to kmod_module_get_dependencies() with kmod_module_get_holders() when using that option. Also try to cleanup the confusion by renaming the option to --remove-holders: "holder" is the name used in sysfs and by libkmod to refer to a "live" reverse dependency like what we are interested in. Before: ./tools/modprobe -D -r --remove-dependencies video rmmod video After: ./tools/modprobe -D -r --remove-holders video rmmod i915 rmmod thinkpad_acpi rmmod video Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* modprobe: remove unneeded variable str_startMasahiro Yamada2022-04-041-3/+3
| | | | | | | | | The variable 'str_start' is not useful here. Replace it with 'str'. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
* modprobe: fix the NULL-termination of new_argvMasahiro Yamada2022-04-041-1/+1
| | | | | | | | | | The number of new arguments is (i + argc - 1) as it is set to *p_argc one line below. The correct location of NULL termination is new_argv[i + argc - 1]. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
* depmod: Add support for excluding a directorySaul Wold2022-04-012-4/+76
| | | | | | | | | | | | | | | This adds support to depmod to enable a new exclude directive in the depmod.d/*.conf configuration file. Currently depmod already excludes directories named source or build. This change will allow additional directories like .debug to be excluded also via a new exclude directive. depmod.d/exclude.conf example: exclude .debug Signed-off-by: Saul Wold <saul.wold@windriver.com> [ Fix warnings and make should_exclude_dir() return bool ] Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
* modprobe: Rename rmmod_do_deps_listLucas De Marchi2022-04-011-4/+5
| | | | | | | It's used not only for dependencies, but also for pre and post softdep. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* docs: Add missing functions to documentationLucas De Marchi2022-03-031-0/+2
| | | | Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
* libkmod: Fix use of sizeof instead of ARRAY_SIZELucas De Marchi2022-02-231-2/+2
| | | | | Link: https://github.com/kmod-project/kmod/issues/12 Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
* modinfo: Allow to force arg as module nameLucas De Marchi2022-02-201-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the Linux kernel or userspace sets an alias with the same name as a module, they force the tools to use that. However in some situations it may be desired to query the module itself. Getting the module information through modinfo is one such situation. So, add a option to modinfo to explicitly instruct it to handle the argument as a module name. Example, when trying to output information about the crc32 module that is builtin: $ modinfo crc32 filename: /lib/modules/5.15.19-1-MANJARO/kernel/arch/x86/crypto/crc32-pclmul.ko.zst alias: crypto-crc32-pclmul alias: crc32-pclmul alias: crypto-crc32 alias: crc32 license: GPL author: Alexander Boyko <alexander_boyko@xyratex.com> srcversion: B6B2FF9236731E69418A2E5 alias: cpu:type:x86,ven*fam*mod*:feature:*0081* depends: retpoline: Y intree: Y name: crc32_pclmul vermagic: 5.15.19-1-MANJARO SMP preempt mod_unload sig_id: PKCS#7 signer: Build time autogenerated kernel key sig_key: 77:FB:AA:BD:48:78:A4:C6:56:18:9A:7E:A6:F3:29:3E:C5:6B:E9:37 sig_hashalgo: sha512 signature: 30:65:02:31:00:B0:D4:49:9D:1D:F1:71:4C:3C:BB:70:B2:3E:46:5D: 38:5A:F1:00:95:FD:7A:96:C4:2C:24:35:A2:1B:0B:A8:1C:29:6F:02: 7A:68:EE:BA:A4:1C:01:4B:86:39:15:3E:66:02:30:7F:7A:66:5E:F2: 2F:98:73:3D:AD:96:66:81:8B:94:6E:F3:3F:44:0F:85:E1:73:3A:9E: F9:C4:BE:9B:88:02:BD:83:04:B9:2E:72:0B:93:BC:82:B6:A1:1B:6A: C2:ED:8C filename: /lib/modules/5.15.19-1-MANJARO/kernel/crypto/crc32_generic.ko.zst alias: crypto-crc32-generic alias: crc32-generic alias: crypto-crc32 alias: crc32 license: GPL description: CRC32 calculations wrapper for lib/crc32 author: Alexander Boyko <alexander_boyko@xyratex.com> srcversion: F08036C38DDB06BCD1E6091 depends: retpoline: Y intree: Y name: crc32_generic vermagic: 5.15.19-1-MANJARO SMP preempt mod_unload sig_id: PKCS#7 signer: Build time autogenerated kernel key sig_key: 77:FB:AA:BD:48:78:A4:C6:56:18:9A:7E:A6:F3:29:3E:C5:6B:E9:37 sig_hashalgo: sha512 signature: 30:65:02:31:00:E3:9E:C8:80:15:0E:D7:74:96:B5:25:EA:32:F7:DF: E9:FC:3C:82:D9:B9:B9:37:C5:20:8D:06:31:02:62:B3:54:E8:DF:F2: 7E:E2:7C:A4:CF:49:17:CB:75:DF:2C:7A:2F:02:30:25:DE:7C:2A:2C: 97:3F:65:16:76:B3:71:FB:62:DB:8F:F3:33:65:77:98:F3:57:ED:D7: 87:78:FF:C2:04:55:70:00:10:63:1E:B2:FE:22:D8:E5:6D:5F:95:4E: 7D:2C:6B That is because the Linux kernel exports "crc32" as an alias to those modules, besides being a module itself: $ grep crc32 /lib/modules/$(uname -r)/modules.builtin kernel/lib/crc32.ko $ $ grep "alias crc32 " /lib/modules/$(uname -r)/modules.alias alias crc32 crc32_pclmul alias crc32 crc32_generic With the new -m|--modname option it's possible to query the information about this (builtin) module explicitly: $ modinfo --modname crc32 name: crc32 filename: (builtin) license: GPL file: lib/crc32 description: Various CRC32 calculations author: Matt Domsch <Matt_Domsch@dell.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* modinfo: Update help message with "modulename"Lucas De Marchi2022-02-201-1/+1
| | | | | | | | | | | man page correctly states the a module name can be used in place of a file name: modinfo [-0] [-F field] [-k kernel] [modulename|filename...] Update the help message accordingly. Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
* libkmod: Add lookup from module nameLucas De Marchi2022-02-203-0/+61
| | | | | | | | | Slightly different than kmod_module_new_from_lookup(): it doesn't consider aliases, only module names. This is useful for cases we want to force a tool to handle something as the module name, without trying to interpret it as an alias. Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>