From: Lucas De Marchi Date: Wed, 25 Mar 2026 05:28:46 +0000 (-0500) Subject: libkmod: Add build-id item to kmod_module_get_info() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;ds=inline;p=thirdparty%2Fkmod.git libkmod: Add build-id item to kmod_module_get_info() If available, add the build-id to the info list returned by kmod_module_get_info(). This allows us to compare the build-id of a loaded module versus the build-id of the file. It's rather cumbersome command, but it works: $ ./build/modinfo -F build-id hid AE:7A:2E:37:E0:2B:31:D5:72:7C:87:87:15:8C:05:FA:77:7A:4F:57 $ xxd -p -u -s16 /sys/module/hid/notes/.note.gnu.build-id | sed 's/../&:/g;s/:$//' AE:7A:2E:37:E0:2B:31:D5:72:7C:87:87:15:8C:05:FA:77:7A:4F:57 An option to modinfo to really to just dump the raw value can be added in future. Signed-off-by: Lucas De Marchi Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/432 --- diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index e849dd9..29ae608 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -1914,6 +1914,22 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod, goto list_error; } + if (mod->elf) { + const void *build_id; + size_t build_id_len; + + if (kmod_elf_get_build_id(mod->elf, &build_id, &build_id_len) == 0) { + struct kmod_list *n; + + n = kmod_module_info_append_hex(list, "build-id", + strlen("build-id"), build_id, + build_id_len); + if (n == NULL) + goto list_error; + count++; + } + } + if (mod->file && kmod_module_signature_info(mod->file, &sig_info)) { struct kmod_list *n;