Commits on Jun 9, 2021

  1. libkmod-module: check "new_from_name" return value in get_builtin

    kmod_module_new_from_name() may fail and return error value. It is
    handled properly across the code, but in this particular place the
    check is missing.
    
    Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
    ykaliuta authored and lucasdemarchi committed Jun 9, 2021
    Configuration menu
    Copy the full SHA
    64541d6 View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2021

  1. libkmod: add a library notice log level print

    When you use pass the -v argument to modprobe we bump
    the log level from the default modprobe log level of
    LOG_WARNING (4) to LOG_NOTICE (5), however the library
    only has avaiable to print:
    
     #define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
     #define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
     #define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
    
    LOG_INFO (6) however is too high of a level for it to be
    effective at printing anything when modprobe -v is passed.
    And so the only way in which modprobe -v can trigger the
    library to print a verbose message is to use ERR() but that
    always prints something and we don't want that in some
    situations.
    
    We need to add a new log level macro which uses LOG_NOTICE (5)
    for a "normal but significant condition" which users and developers
    can use to look underneath the hood to confirm if a situation is
    happening.
    
    Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
    Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
    mcgrof authored and lucasdemarchi committed Sep 23, 2021
    Configuration menu
    Copy the full SHA
    43bdf97 View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2022

  1. libkmod: Set builtin to no when module is created from path.

    A recent bug report showed that modinfo doesn't give the signature
    information for certain modules, and it turned out to happen only on
    the modules that are built-in on the running kernel; then modinfo
    skips the signature check, as if the target module file never exists.
    The behavior is, however, inconsistent when modinfo is performed for
    external modules (no matter which kernel version is) and the module
    file path is explicitly given by a command-line argument, which
    guarantees the presence of the module file itself.
    
    Fixes: e7e2cb6 ("modinfo: Show information about built-in modules")
    Link: https://lore.kernel.org/linux-modules/CAKi4VAJVvY3=JdSZm-GD1hJqyCPYaYz-jBJ_REeY5BakVb6_ww@mail.gmail.com/
    BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1189537
    Suggested-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    Signed-off-by: Michal Suchanek <msuchanek@suse.de>
    Reviewed-by: Petr Vorel <pvorel@suse.cz>
    hramrach authored and lucasdemarchi committed Jan 20, 2022
    Configuration menu
    Copy the full SHA
    4e391ac View commit details
    Browse the repository at this point in the history

Commits on Feb 12, 2022

  1. libkmod: Prefer builtin index over builtin.alias

    The modules.builtin.alias.bin is way larger than the
    modules.builtin.bin.  On a normal "distro kernel":
    
    	21k modules.builtin.alias.bin
    	11k modules.builtin.bin
    
    From the kernel we get both modules.builtin and modules.builtin.modinfo.
    depmod generates modules.builtin.bin and modules.builtin.alias.bin
    from them respectively. modules.bultin is not going away: it's not
    deprecated by the new index added. So, let's just stop duplicating the
    information inside modules.builtin.alias.bin and just use the other
    index.
    lucasdemarchi committed Feb 12, 2022
    Configuration menu
    Copy the full SHA
    a965641 View commit details
    Browse the repository at this point in the history
  2. depmod: Do not duplicate builtin index

    Now that libkmod uses modules.builtin.bin again, we don't need to add
    the module names in modules.builtin.alias.bin and just add the aliases.
    
    After this change, here are the new sizes for the indexes:
    
    Before	After	index
    21k	6.4K	modules.builtin.alias.bin
    11k	 11K	modules.builtin.bin
    lucasdemarchi committed Feb 12, 2022
    Configuration menu
    Copy the full SHA
    7a0f593 View commit details
    Browse the repository at this point in the history
  3. depmod: Stop opening modules.modinfo once per module

    Since the addition of modules.aliases.bin, depmod has to open that
    index multiple times and parse it over and over again:
    
    	$ sudo strace -e openat  ./tools/depmod 2>&1 | grep modules.builtin.modinfo  | wc -l
    	299
    	$ time sudo  ./tools/depmod
    	real    0m7.814s
    	user    0m7.571s
    	sys     0m0.237s
    
    Rework the logic in depmod so it does everything: open, read and parse. The
    format is very straightforward and we don't need to keep it in a data structure
    since we only want to add the result to a index. New output:
    
    	$ sudo strace -e openat  ./tools/depmod 2>&1 | grep modules.builtin.modinfo  | wc -l
    	1
    	$ time sudo  ./tools/depmod
    	real    0m7.663s
    	user    0m7.516s
    	sys     0m0.139s
    
    Indexes still match:
    
    	$ cmp /tmp/modules.builtin.alias.bin.new
    	/tmp/modules.builtin.alias.bin.old; echo $?
    	0
    
    Fix: #11
    lucasdemarchi committed Feb 12, 2022
    Configuration menu
    Copy the full SHA
    0246e06 View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2022

  1. test-initstate: Check for negative value on error

    Documentation says kmod_module_new_from_lookup() returns < 0 on error
    and 0 otherwise. There are bugs in libkmod however making it return
    a positive value in some situations, that need to be fixed. However
    it's best to check for the error explicitly like is done in the rest
    of the library to avoid this kind of issues.
    
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    9dc4e5c View commit details
    Browse the repository at this point in the history
  2. libkmod-module: Fix return code for kmod_module_new_from_lookup()

    When kmod_module_new_from_lookup() resolves to an alias, `err` will be
    set to a positive value from the lookup function. Do not return a
    positive value to follow the behavior when it matches a module name
    and the documentation.
    
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    ec8818b View commit details
    Browse the repository at this point in the history
  3. gitignore: ignore gtk-doc.make

    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    61a93a0 View commit details
    Browse the repository at this point in the history
  4. libkmod: Add helper function to iterate lookup options

    The CHECK_ERR_AND_FINISH macro with conditional code flow changes has
    been a source of bugs. Get rid of it replacing with a helper function
    to iterate an array of lookup functions. This helper may also be useful
    in future to create different lookup APIs in libkmod.
    
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    8297271 View commit details
    Browse the repository at this point in the history
  5. libkmod: Update docs about indexes order

    New indexes were created without updating the documentation about the
    order in kmod_module_new_from_lookup(). Add them to the documentation.
    
    Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    a859220 View commit details
    Browse the repository at this point in the history
  6. libkmod: Add lookup from module name

    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>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    9becaae View commit details
    Browse the repository at this point in the history
  7. modinfo: Update help message with "modulename"

    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>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    e343a82 View commit details
    Browse the repository at this point in the history
  8. modinfo: Allow to force arg as module name

    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>
    lucasdemarchi committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    94f7683 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2022

  1. libkmod: Fix use of sizeof instead of ARRAY_SIZE

    Link: #12
    Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
    lucasdemarchi committed Feb 23, 2022
    Configuration menu
    Copy the full SHA
    571a84c View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2022

  1. docs: Add missing functions to documentation

    Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
    lucasdemarchi committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    2058274 View commit details
    Browse the repository at this point in the history

Commits on Apr 2, 2022

  1. modprobe: Rename rmmod_do_deps_list

    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>
    lucasdemarchi committed Apr 2, 2022
    Configuration menu
    Copy the full SHA
    7089386 View commit details
    Browse the repository at this point in the history
  2. depmod: Add support for excluding a directory

    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>
    Saul Wold authored and lucasdemarchi committed Apr 2, 2022
    Configuration menu
    Copy the full SHA
    f50e2d6 View commit details
    Browse the repository at this point in the history

Commits on Apr 4, 2022

  1. modprobe: fix the NULL-termination of new_argv

    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>
    masahir0y authored and lucasdemarchi committed Apr 4, 2022
    Configuration menu
    Copy the full SHA
    757b359 View commit details
    Browse the repository at this point in the history
  2. modprobe: remove unneeded variable str_start

    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>
    masahir0y authored and lucasdemarchi committed Apr 4, 2022
    Configuration menu
    Copy the full SHA
    d890179 View commit details
    Browse the repository at this point in the history

Commits on Apr 7, 2022

  1. modprobe: Fix holders removal

    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>
    lucasdemarchi committed Apr 7, 2022
    Configuration menu
    Copy the full SHA
    42b32d3 View commit details
    Browse the repository at this point in the history
  2. modprobe: move check for remove_holders to caller

    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>
    lucasdemarchi committed Apr 7, 2022
    Configuration menu
    Copy the full SHA
    d29ed6e View commit details
    Browse the repository at this point in the history
  3. modprobe: Make rmmod_do_module() contain all the removal sequence

    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>
    lucasdemarchi committed Apr 7, 2022
    Configuration menu
    Copy the full SHA
    ea3c8ad View commit details
    Browse the repository at this point in the history

Commits on Jun 27, 2022

  1. depmod: Fix writing over array length

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    07bf5e1 View commit details
    Browse the repository at this point in the history
  2. modprobe: re-use modname variable

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    6f7ab21 View commit details
    Browse the repository at this point in the history
  3. modprobe: Move -R to "Query options"

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    081fff2 View commit details
    Browse the repository at this point in the history
  4. libkmod: Allow to ignore log message on module removal

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    3a92fc6 View commit details
    Browse the repository at this point in the history
  5. module-playground: Add debugfs entry in mod-simple

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    2ab4fbc View commit details
    Browse the repository at this point in the history
  6. util: Add time-related functions from testsuite

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    5622f1d View commit details
    Browse the repository at this point in the history
  7. util: Add msec variants for time-related functions

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    ba105fa View commit details
    Browse the repository at this point in the history
  8. util: Add exponential backoff sleep

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    8ab15ec View commit details
    Browse the repository at this point in the history
  9. testsuite: Add tests for sleep calculation

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    b253f4c View commit details
    Browse the repository at this point in the history
  10. modprobe: Add --wait

    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>
    lucasdemarchi committed Jun 27, 2022
    Configuration menu
    Copy the full SHA
    2b98ed8 View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2022

  1. Keep only one readme

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    202040c View commit details
    Browse the repository at this point in the history
  2. README: Update optional dependencies

    Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
    lucasdemarchi committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    edc7f3a View commit details
    Browse the repository at this point in the history

Commits on Jun 30, 2022

  1. libkmod: Support SM3 hash algorithm

    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>
    HuaxinLu authored and lucasdemarchi committed Jun 30, 2022
    Configuration menu
    Copy the full SHA
    f609cb5 View commit details
    Browse the repository at this point in the history
  2. kmod 30

    lucasdemarchi committed Jun 30, 2022
    Configuration menu
    Copy the full SHA
    5d46434 View commit details
    Browse the repository at this point in the history