]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: clear file->memory if map fails
authorEmil Velikov <emil.l.velikov@gmail.com>
Mon, 12 Feb 2024 17:23:05 +0000 (17:23 +0000)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 30 Apr 2024 17:33:52 +0000 (12:33 -0500)
commit90b271fbd2b9708a8fa79b7e98d90c7919e7ed73
tree3e5e244448be171bf33376659aa34a9243b43aef
parent03da2db1358f5ae3b50596f04e5e05bcf7a48fee
libkmod: clear file->memory if map fails

On mmap failure file->memory is set to -1, which we'll happily pass down
to munmap later on.

More importantly, since we do a NULL check in kmod_file_load_contents()
we will exit the function without (re)attempting the load again.

Since we ignore the return code for the load function(s), one can end up
calling kmod_elf_get_memory() and feed that -1 into init_module.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-file.c