Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

lsm: group lsm_order_parse() with the other lsm_order_*() functions

Move the lsm_order_parse() function near the other lsm_order_*()
functions to improve readability.

No code changes.

Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: John Johansen <john.johhansen@canonical.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>

+70 -70
+70 -70
security/lsm_init.c
··· 170 170 } 171 171 172 172 /** 173 + * lsm_order_parse - Parse the comma delimited LSM list 174 + * @list: LSM list 175 + * @src: source of the list 176 + */ 177 + static void __init lsm_order_parse(const char *list, const char *src) 178 + { 179 + struct lsm_info *lsm; 180 + char *sep, *name, *next; 181 + 182 + /* Handle any Legacy LSM exclusions if one was specified. */ 183 + if (lsm_order_legacy) { 184 + /* 185 + * To match the original "security=" behavior, this explicitly 186 + * does NOT fallback to another Legacy Major if the selected 187 + * one was separately disabled: disable all non-matching 188 + * Legacy Major LSMs. 189 + */ 190 + lsm_for_each_raw(lsm) { 191 + if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) && 192 + strcmp(lsm->id->name, lsm_order_legacy)) { 193 + lsm_enabled_set(lsm, false); 194 + lsm_pr_dbg("skip legacy LSM conflict %s:%s\n", 195 + src, lsm->id->name); 196 + } 197 + } 198 + } 199 + 200 + /* LSM_ORDER_FIRST */ 201 + lsm_for_each_raw(lsm) { 202 + if (lsm->order == LSM_ORDER_FIRST) 203 + lsm_order_append(lsm, "first"); 204 + } 205 + 206 + /* Normal or "mutable" LSMs */ 207 + sep = kstrdup(list, GFP_KERNEL); 208 + next = sep; 209 + /* Walk the list, looking for matching LSMs. */ 210 + while ((name = strsep(&next, ",")) != NULL) { 211 + lsm_for_each_raw(lsm) { 212 + if (!strcmp(lsm->id->name, name) && 213 + lsm->order == LSM_ORDER_MUTABLE) 214 + lsm_order_append(lsm, src); 215 + } 216 + } 217 + kfree(sep); 218 + 219 + /* Legacy LSM if specified. */ 220 + if (lsm_order_legacy) { 221 + lsm_for_each_raw(lsm) { 222 + if (!strcmp(lsm->id->name, lsm_order_legacy)) 223 + lsm_order_append(lsm, src); 224 + } 225 + } 226 + 227 + /* LSM_ORDER_LAST */ 228 + lsm_for_each_raw(lsm) { 229 + if (lsm->order == LSM_ORDER_LAST) 230 + lsm_order_append(lsm, "last"); 231 + } 232 + 233 + /* Disable all LSMs not previously enabled. */ 234 + lsm_for_each_raw(lsm) { 235 + if (lsm_order_exists(lsm)) 236 + continue; 237 + lsm_enabled_set(lsm, false); 238 + lsm_pr_dbg("skip disabled LSM %s:%s\n", src, lsm->id->name); 239 + } 240 + } 241 + 242 + /** 173 243 * lsm_blob_size_update - Update the LSM blob size and offset information 174 244 * @sz_req: the requested additional blob size 175 245 * @sz_cur: the existing blob size ··· 309 239 lsm_pr_dbg("initializing %s\n", lsm->id->name); 310 240 ret = lsm->init(); 311 241 WARN(ret, "%s failed to initialize: %d\n", lsm->id->name, ret); 312 - } 313 - 314 - /** 315 - * lsm_order_parse - Parse the comma delimited LSM list 316 - * @list: LSM list 317 - * @src: source of the list 318 - */ 319 - static void __init lsm_order_parse(const char *list, const char *src) 320 - { 321 - struct lsm_info *lsm; 322 - char *sep, *name, *next; 323 - 324 - /* Handle any Legacy LSM exclusions if one was specified. */ 325 - if (lsm_order_legacy) { 326 - /* 327 - * To match the original "security=" behavior, this explicitly 328 - * does NOT fallback to another Legacy Major if the selected 329 - * one was separately disabled: disable all non-matching 330 - * Legacy Major LSMs. 331 - */ 332 - lsm_for_each_raw(lsm) { 333 - if ((lsm->flags & LSM_FLAG_LEGACY_MAJOR) && 334 - strcmp(lsm->id->name, lsm_order_legacy)) { 335 - lsm_enabled_set(lsm, false); 336 - lsm_pr_dbg("skip legacy LSM conflict %s:%s\n", 337 - src, lsm->id->name); 338 - } 339 - } 340 - } 341 - 342 - /* LSM_ORDER_FIRST */ 343 - lsm_for_each_raw(lsm) { 344 - if (lsm->order == LSM_ORDER_FIRST) 345 - lsm_order_append(lsm, "first"); 346 - } 347 - 348 - /* Normal or "mutable" LSMs */ 349 - sep = kstrdup(list, GFP_KERNEL); 350 - next = sep; 351 - /* Walk the list, looking for matching LSMs. */ 352 - while ((name = strsep(&next, ",")) != NULL) { 353 - lsm_for_each_raw(lsm) { 354 - if (!strcmp(lsm->id->name, name) && 355 - lsm->order == LSM_ORDER_MUTABLE) 356 - lsm_order_append(lsm, src); 357 - } 358 - } 359 - kfree(sep); 360 - 361 - /* Legacy LSM if specified. */ 362 - if (lsm_order_legacy) { 363 - lsm_for_each_raw(lsm) { 364 - if (!strcmp(lsm->id->name, lsm_order_legacy)) 365 - lsm_order_append(lsm, src); 366 - } 367 - } 368 - 369 - /* LSM_ORDER_LAST */ 370 - lsm_for_each_raw(lsm) { 371 - if (lsm->order == LSM_ORDER_LAST) 372 - lsm_order_append(lsm, "last"); 373 - } 374 - 375 - /* Disable all LSMs not previously enabled. */ 376 - lsm_for_each_raw(lsm) { 377 - if (lsm_order_exists(lsm)) 378 - continue; 379 - lsm_enabled_set(lsm, false); 380 - lsm_pr_dbg("skip disabled LSM %s:%s\n", src, lsm->id->name); 381 - } 382 242 } 383 243 384 244 /**