Skip to content

Commit 4136683

Browse files
committed
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 <demarchi@kernel.org>
1 parent ff46e48 commit 4136683

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

libkmod/libkmod-module.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,7 @@ static struct kmod_list *kmod_module_info_append_hex(struct kmod_list **list,
18531853
KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod,
18541854
struct kmod_list **list)
18551855
{
1856-
struct kmod_elf *elf;
1856+
struct kmod_elf *elf = NULL;
18571857
char **strings;
18581858
int i, count, ret = -ENOMEM;
18591859
struct kmod_signature_info sig_info = {};
@@ -1901,6 +1901,22 @@ KMOD_EXPORT int kmod_module_get_info(const struct kmod_module *mod,
19011901
goto list_error;
19021902
}
19031903

1904+
if (elf != NULL) {
1905+
const void *build_id;
1906+
size_t build_id_len;
1907+
1908+
if (kmod_elf_get_build_id(elf, &build_id, &build_id_len) == 0) {
1909+
struct kmod_list *n;
1910+
1911+
n = kmod_module_info_append_hex(list, "build-id",
1912+
strlen("build-id"), build_id,
1913+
build_id_len);
1914+
if (n == NULL)
1915+
goto list_error;
1916+
count++;
1917+
}
1918+
}
1919+
19041920
if (mod->file && kmod_module_signature_info(mod->file, &sig_info)) {
19051921
struct kmod_list *n;
19061922

0 commit comments

Comments
 (0)