Skip to contentSkip to conversation

Patch "module: avoid *goto*s in module_sig_check()" has been added to the 5.10-stable tree

DISCUSSION Sergey Shtylyov 2 participants 2 messages Mar 22, 2021 1 message not in the archive Stable branch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

module: avoid *goto*s in module_sig_check()

to the 5.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Quoted 6 lines

The filename of the patch is:
module-avoid-goto-s-in-module_sig_check.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Again, it's just a cleanup...

Quoted 60 lines

commit c5d4af31cebd2d83fdb7bb7b7d11cbc086c18a4a

Author: Sergey Shtylyov <[email protected]>
Date:   Sat Oct 31 23:09:31 2020 +0300

module: avoid *goto*s in module_sig_check()

[ Upstream commit 10ccd1abb808599a6dc7c9389560016ea3568085 ]

Let's move the common handling of the non-fatal errors after the *switch* statement -- this avoids *goto*s inside that *switch*...

kernel/module.c +10 -10
index 3b6dd8200d3d..f1be6b6a3a3d 100644
@@ -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)
maintainer
#2 lore raw
Quoted 9 lines · Sergey Shtylyov
Quoted 7 lines · Sasha Levin

This is a note to let you know that I've just added the patch titled

module: avoid *goto*s in module_sig_check()

to the 5.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

Quoted 8 lines
Quoted 6 lines

The filename of the patch is:
module-avoid-goto-s-in-module_sig_check.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Again, it's just a cleanup...

It is needed for ec2a29593c83 ("module: harden ELF info handling").