module: Add more error message for failed kernel module loading
authorQu Wenruo <wqu@suse.com>
Wed, 2 Sep 2020 06:46:19 +0000 (14:46 +0800)
committerJessica Yu <jeyu@kernel.org>
Wed, 2 Sep 2020 09:18:40 +0000 (11:18 +0200)
commit14721add58ef267344bee254bc276c9139b7b665
tree5a2b321561dac98978a4439f0224bb1606f0bb9f
parentf75aef392f869018f78cfedf3c320a6b3fcfda6b
module: Add more error message for failed kernel module loading

When kernel module loading failed, user space only get one of the
following error messages:

- ENOEXEC
  This is the most confusing one. From corrupted ELF header to bad
  WRITE|EXEC flags check introduced by in module_enforce_rwx_sections()
  all returns this error number.

- EPERM
  This is for blacklisted modules. But mod doesn't do extra explain
  on this error either.

- ENOMEM
  The only error which needs no explain.

This means, if a user got "Exec format error" from modprobe, it provides
no meaningful way for the user to debug, and will take extra time
communicating to get extra info.

So this patch will add extra error messages for -ENOEXEC and -EPERM
errors, allowing user to do better debugging and reporting.

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
kernel/module.c