From: Sergey Shtylyov <s.shtylyov@omprussia.ru>
To: Jessica Yu <jeyu@kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Joe Perches <joe@perches.com>
Subject: [PATCH v2 2/3] module: avoid *goto*s in module_sig_check()
Date: Sat, 31 Oct 2020 23:09:31 +0300 [thread overview]
Message-ID: <ea07f954-0cf2-a552-792e-d1b83f1a8fba@omprussia.ru> (raw)
In-Reply-To: <22e48a3d-06ee-5b8e-6e56-3694871a7c2f@omprussia.ru>
Let's move the common handling of the non-fatal errors after the *switch*
statement -- this avoids *goto*s inside that *switch*...
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergey Shtylyov <s.shtylyov@omprussia.ru>
---
Changes in version 2:
- new patch.
kernel/module.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
Index: linux/kernel/module.c
===================================================================
--- linux.orig/kernel/module.c
+++ linux/kernel/module.c
@@ -2908,20 +2908,13 @@ static int module_sig_check(struct load_
*/
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
@@ -2930,6 +2923,13 @@ static int module_sig_check(struct load_
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)
next prev parent reply other threads:[~2020-10-31 20:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-31 20:05 [PATCH v2 0/3] module: refactor module_sig_check() Sergey Shtylyov
2020-10-31 20:06 ` [PATCH v2 1/3] module: merge repetitive strings in module_sig_check() Sergey Shtylyov
2020-10-31 20:09 ` Sergey Shtylyov [this message]
2020-10-31 20:10 ` [PATCH v2 3/3] module: only handle errors with the *switch* statement " Sergey Shtylyov
2020-11-04 14:00 ` [PATCH v2 0/3] module: refactor module_sig_check() Miroslav Benes
2020-11-04 14:41 ` Jessica Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea07f954-0cf2-a552-792e-d1b83f1a8fba@omprussia.ru \
--to=s.shtylyov@omprussia.ru \
--cc=jeyu@kernel.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®