Bug 15727 - insmod return code is broken with MODPROBE_SMALL=y
Summary: insmod return code is broken with MODPROBE_SMALL=y
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-16 16:59 UTC by douglas.raillard
Modified: 2023-08-16 16:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description douglas.raillard 2023-08-16 16:59:09 UTC
insmod (from version 1.31.1 at least to 1.36.1 at least) does not forward the return code of the kernel module init function properly when compiled with MODPROBE_SMALL=y.

This is problematic for callers expecting to distinguish different issues based on that.

The code with MODPROBE_SMALL=y is:

modutils/modprobe-small.c

		if (init_module(map, len,
			(IF_FEATURE_CMDLINE_MODULE_OPTIONS(options ? options : ) "")
			) != 0
		) {
			bb_error_msg_and_die("can't insert '%s': %s",
					*argv, moderror(errno));
		}

So it's quite clear that all non-zero return values for init_module() are treated exactly the same.

In contrast, modutils/insmod.c forwards the return value correctly:

	rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0));
	if (rc)
		bb_error_msg("can't insert '%s': %s", filename, moderror(rc));

	return rc;


To fix that, modprobe-small.c should return "errno" instead of dying with a generic error code.