@@ -103,14 +103,6 @@ static bool __init lsm_allowed(struct lsm_info *lsm)
if (!is_enabled(lsm))
return false;
- /* Skip major-specific checks if not a major LSM. */
- if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) == 0)
- return true;
-
- /* Disabled if this LSM isn't the chosen one. */
- if (strcmp(lsm->name, chosen_major_lsm) != 0)
- return false;
-
return true;
}
@@ -188,8 +180,24 @@ static void __init prepare_lsm_enable(void)
parse_lsm_enable(chosen_lsm_enable, set_enabled, true);
parse_lsm_enable(chosen_lsm_disable, set_enabled, false);
+ /* Process "security=", if given. */
if (!chosen_major_lsm)
chosen_major_lsm = CONFIG_DEFAULT_SECURITY;
+ if (chosen_major_lsm) {
+ struct lsm_info *lsm;
+
+ /*
+ * To match the original "security=" behavior, this
+ * explicitly does NOT fallback to another Legacy Major
+ * if the selected one was separately disabled: disable
+ * all non-matching Legacy Major LSMs.
+ */
+ for (lsm = __start_lsm_info; lsm < __end_lsm_info; lsm++) {
+ if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) &&
+ strcmp(lsm->name, chosen_major_lsm) != 0)
+ set_enabled(lsm, false);
+ }
+ }
}
/**