提交 92f1d994 编写于 作者: S Sergey Shtylyov 提交者: Zheng Zengkai

module: avoid *goto*s in module_sig_check()

stable inclusion
from stable-5.10.26
commit e2c8978a75e0e13a911b7c9d6e2b3a490f1f24d8
bugzilla: 51363

--------------------------------

[ Upstream commit 10ccd1ab ]

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>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: N  Weilong Chen <chenweilong@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 bb61c8d4
......@@ -2923,20 +2923,13 @@ static int module_sig_check(struct load_info *info, int flags)
*/
case -ENODATA:
reason = "unsigned module";
goto decide;
break;
case -ENOPKG:
reason = "module with unsupported crypto";
goto decide;
break;
case -ENOKEY:
reason = "module with unavailable key";
decide:
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);
break;
/* All other errors are fatal, including nomem, unparseable
* signatures and signature check failures - even if signatures
......@@ -2945,6 +2938,13 @@ static int module_sig_check(struct load_info *info, int flags)
default:
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 */
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.
先完成此消息的编辑!
想要评论请 注册