staticintload_module(struct load_info *info, constchar __user *uargs,
int flags)
{
structmodule *mod;long err;
char *after_dashes;
err = module_sig_check(info, flags);
if (err)
goto free_copy;
err = elf_header_check(info);
if (err)
goto free_copy;
/* Figure out module layout, and allocate all the memory. */
mod = layout_and_allocate(info, flags);
if (IS_ERR(mod)) {
err = PTR_ERR(mod);
goto free_copy;
}
audit_log_kern_module(mod->name);
/* Reserve our place in the list. */
err = add_unformed_module(mod);
if (err)
goto free_module;
#ifdef CONFIG_MODULE_SIG
mod->sig_ok = info->sig_ok;
if (!mod->sig_ok) {
pr_notice_once("%s: module verification failed: signature ""and/or required key missing - tainting ""kernel\n", mod->name);
add_taint_module(mod, TAINT_UNSIGNED_MODULE, LOCKDEP_STILL_OK);
}
#endif
... 以下省略 ...
}
staticintmodule_sig_check(struct load_info *info, int flags)
{
int err = -ENOKEY;
constunsignedlong markerlen = sizeof(MODULE_SIG_STRING) - 1;
constvoid *mod = info->hdr;
/*
* Require flags == 0, as a module with version information
* removed is no longer the module that was signed
*/if (flags == 0 &&
info->len > markerlen &&
memcmp(mod + info->len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {
/* We truncate the module to discard the signature */
info->len -= markerlen;
err = mod_verify_sig(mod, &info->len);
}
if (!err) {
info->sig_ok = true;
return0;
}
#ifdef CONFIG_HUAWEI_PROC_CHECK_ROOT
saudit_log(MOD_SIGN, STP_RISK, 0, "result=%d,", err);
#endif/* Not having a signature is only an error if we're strict. */if (err == -ENOKEY && !sig_enforce)
err = 0;
return err;
}