Skip to content

Commit

Permalink
module: only handle errors with the *switch* statement in module_sig_…
Browse files Browse the repository at this point in the history
…check()

Let's handle the successful call of mod_verify_sig() right after that call,
making the *switch* statement only handle the real errors, and then move
the comment from the first *case* before *switch* itself and the comment
before *default* after it.  Fix the comment style, add article/comma/dash,
spell out "nomem" as "lack of memory" in these comments, while at it...

Suggested-by: Joe Perches <[email protected]>
Reviewed-by: Miroslav Benes <[email protected]>
Signed-off-by: Sergey Shtylyov <[email protected]>
Signed-off-by: Jessica Yu <[email protected]>
  • Loading branch information
Sergey Shtylyov authored and Jessica Yu committed Nov 4, 2020
1 parent 10ccd1a commit 076aa52
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2895,17 +2895,18 @@ static int module_sig_check(struct load_info *info, int flags)
/* We truncate the module to discard the signature */
info->len -= markerlen;
err = mod_verify_sig(mod, info);
if (!err) {
info->sig_ok = true;
return 0;
}
}

/*
* We don't permit modules to be loaded into the trusted kernels
* without a valid signature on them, but if we're not enforcing,
* certain errors are non-fatal.
*/
switch (err) {
case 0:
info->sig_ok = true;
return 0;

/* We don't permit modules to be loaded into trusted kernels
* without a valid signature on them, but if we're not
* enforcing, certain errors are non-fatal.
*/
case -ENODATA:
reason = "unsigned module";
break;
Expand All @@ -2916,11 +2917,12 @@ static int module_sig_check(struct load_info *info, int flags)
reason = "module with unavailable key";
break;

/* All other errors are fatal, including nomem, unparseable
* signatures and signature check failures - even if signatures
* aren't required.
*/
default:
/*
* All other errors are fatal, including lack of memory,
* unparseable signatures, and signature check failures --
* even if signatures aren't required.
*/
return err;
}

Expand Down

0 comments on commit 076aa52

Please sign in to comment.