version magic '6.1.24+ SMP mod_unload riscv' should be '6.1.24-gf4f652de5a3f
SYSCALL_DEFINE3(init_module, void __user *, umod,
unsigned long, len, const char __user *, uargs)
{
int err;
struct load_info info = { };
err = may_init_module();
if (err)
return err;
pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
umod, len, uargs);
err = copy_module_from_user(umod, len, &info);
if (err)
return err;
return load_module(&info, uargs, 0);
}
SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
{
struct load_info info = { };
void *buf = NULL;
int len;
int err;
err = may_init_module();
if (err)
return err;
pr_debug("finit_module: fd=%d, uargs=%p, flags=%i\n", fd, uargs, flags);
if (flags & ~(MODULE_INIT_IGNORE_MODVERSIONS
|MODULE_INIT_IGNORE_VERMAGIC
|MODULE_INIT_COMPRESSED_FILE))
return -EINVAL;
len = kernel_read_file_from_fd(fd, 0, &buf, INT_MAX, NULL,
READING_MODULE);
if (len < 0)
return len;
if (flags & MODULE_INIT_COMPRESSED_FILE) {
err = module_decompress(&info, buf, len);
vfree(buf); /* compressed data is no longer needed */
if (err)
return err;
} else {
info.hdr = buf;
info.len = len;
}
return load_module(&info, uargs, flags);
}
finit_module flags会带IGNORE
busybox 1.36仍然没有支持 IGNORE只能关闭
# CONFIG_LOCALVERSION_AUTO is not set
static int load_module(const char *fname, const char *options)
{
#if 1
int r;
size_t len = MAXINT(ssize_t);
char *module_image;
if (!options)
options = "";
dbg1_error_msg("load_module('%s','%s')", fname, options);
/*
* First we try finit_module if available. Some kernels are configured
* to only allow loading of modules off of secure storage (like a read-
* only rootfs) which needs the finit_module call. If it fails, we fall
* back to normal module loading to support compressed modules.
*/
r = 1;
# ifdef __NR_finit_module
{
int fd = open(fname, O_RDONLY | O_CLOEXEC);
if (fd >= 0) {
r = finit_module(fd, options, 0) != 0;
close(fd);
}
}
# endif