[PATCH v2 0/2] Do extra ELF header check before calling finit_module()

Qu Wenruo wqu at suse.com
Sun Jan 3 04:10:40 UTC 2021


System calls finit_module() and init_module() have very clear
specification to only accept valid ELF image.

And upstream kernel commit 14721add58ef ("module: Add more error message
for failed kernel module loading") even adds error messages to show the
reason why some kernel modules failed to load.

This means, we should no longer call finit_module() no-brain, and at
least follow kmod to do some basic ELF header checks before calling
finit_module().

Although we can still call finit_module() without brain and normal users
won't even notice a thing, treating the kernel better is never a bad
thing.

Changelog:
v2:
- Fix the unreleased fd in the modutils.c
- Add extra #ifdef to avoid compiling the check if finit_module() is no
  avaiable
- Add the 2nd patch to handle modprobe-small 

Qu Wenruo (2):
  modutils: check ELF header before calling finit_module()
  modprobe-small: check ELF header before calling finit_module()

 modutils/modprobe-small.c | 33 ++++++++++++++++++++++++++++++++-
 modutils/modutils.c       | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 2 deletions(-)

-- 
2.29.2



More information about the busybox mailing list