]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod/libkmod-signature: rework struct kmod_signature_info
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)
committerLucas De Marchi <demarchi@kernel.org>
Wed, 22 Apr 2026 13:58:19 +0000 (08:58 -0500)
commit2ef7ade1d11d1203dc0f8767f2cdc578c39ed759
tree66e760d67c8b43678a1fa0c2b349918ef1d7058c
parent9585b87f9975d15bef4433619ae7dc9c95392957
libkmod/libkmod-signature: rework struct kmod_signature_info

Currently, we use a stack allocated instance which bolts of misc private
data via a void *, while also having an optional free callback.

In kmod we opt to pre-calculate the total size, do a one-off allocation,
copy the data as needed, adjusting the pointers.

Doing the same here, gives us a mixed bag of benefits:
 - shorter and simpler code
 - smaller binary - ~100 bytes off
 - fewer instructions - ~40 per module
 - few allocations - ~2 per module
 - extra bytes are allocated - ~180 per module

The updated code seems far more natural and consistent with the
code-base. Although, if we really want to squeeze more cycles we could
use a reasonably large stack buffer and fallback to heap.

v2:
 - don't leak on d2i_PKCS7_bio failure
 - use +1 (instead of sizeof('\0')) for the null terminator

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
libkmod/libkmod-internal.h
libkmod/libkmod-module.c
libkmod/libkmod-signature.c