提交 10ccd1ab 编写于 作者: S Sergey Shtylyov 提交者: Jessica Yu

module: avoid *goto*s in module_sig_check()

Let's move the common handling of the non-fatal errors after the *switch*
statement -- this avoids *goto*s inside that *switch*...
Suggested-by: NJoe Perches <joe@perches.com>
Reviewed-by: NMiroslav Benes <mbenes@suse.cz>
Signed-off-by: NSergey Shtylyov <s.shtylyov@omprussia.ru>
Signed-off-by: NJessica Yu <jeyu@kernel.org>
上级 705e9195
...@@ -2908,20 +2908,13 @@ static int module_sig_check(struct load_info *info, int flags) ...@@ -2908,20 +2908,13 @@ static int module_sig_check(struct load_info *info, int flags)
*/ */
case -ENODATA: case -ENODATA:
reason = "unsigned module"; reason = "unsigned module";
goto decide; break;
case -ENOPKG: case -ENOPKG:
reason = "module with unsupported crypto"; reason = "module with unsupported crypto";
goto decide; break;
case -ENOKEY: case -ENOKEY:
reason = "module with unavailable key"; reason = "module with unavailable key";
decide: break;
if (is_module_sig_enforced()) {
pr_notice("%s: loading of %s is rejected\n",
info->name, reason);
return -EKEYREJECTED;
}
return security_locked_down(LOCKDOWN_MODULE_SIGNATURE);
/* All other errors are fatal, including nomem, unparseable /* All other errors are fatal, including nomem, unparseable
* signatures and signature check failures - even if signatures * signatures and signature check failures - even if signatures
...@@ -2930,6 +2923,13 @@ static int module_sig_check(struct load_info *info, int flags) ...@@ -2930,6 +2923,13 @@ static int module_sig_check(struct load_info *info, int flags)
default: default:
return err; return err;
} }
if (is_module_sig_enforced()) {
pr_notice("%s: loading of %s is rejected\n", info->name, reason);
return -EKEYREJECTED;
}
return security_locked_down(LOCKDOWN_MODULE_SIGNATURE);
} }
#else /* !CONFIG_MODULE_SIG */ #else /* !CONFIG_MODULE_SIG */
static int module_sig_check(struct load_info *info, int flags) static int module_sig_check(struct load_info *info, int flags)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册