Commit e830b39412ca2bbedd7508243f21c04d57ad543c
1 parent
2f823ff8be
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
Smack: Add smkfstransmute mount option
Suppliment the smkfsroot mount option with another, smkfstransmute, that does the same thing but also marks the root inode as transmutting. This allows a freshly created filesystem to be mounted with a transmutting heirarchy. Targeted for git://git.gitorious.org/smack-next/kernel.git Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Showing 2 changed files with 21 additions and 5 deletions Side-by-side Diff
security/smack/smack.h
security/smack/smack_lsm.c
... | ... | @@ -261,8 +261,9 @@ |
261 | 261 | sbsp->smk_default = smack_known_floor.smk_known; |
262 | 262 | sbsp->smk_floor = smack_known_floor.smk_known; |
263 | 263 | sbsp->smk_hat = smack_known_hat.smk_known; |
264 | - sbsp->smk_initialized = 0; | |
265 | - | |
264 | + /* | |
265 | + * smk_initialized will be zero from kzalloc. | |
266 | + */ | |
266 | 267 | sb->s_security = sbsp; |
267 | 268 | |
268 | 269 | return 0; |
... | ... | @@ -306,6 +307,8 @@ |
306 | 307 | dp = smackopts; |
307 | 308 | else if (strstr(cp, SMK_FSROOT) == cp) |
308 | 309 | dp = smackopts; |
310 | + else if (strstr(cp, SMK_FSTRANS) == cp) | |
311 | + dp = smackopts; | |
309 | 312 | else |
310 | 313 | dp = otheropts; |
311 | 314 | |
312 | 315 | |
... | ... | @@ -341,8 +344,9 @@ |
341 | 344 | char *op; |
342 | 345 | char *commap; |
343 | 346 | char *nsp; |
347 | + int transmute = 0; | |
344 | 348 | |
345 | - if (sp->smk_initialized != 0) | |
349 | + if (sp->smk_initialized) | |
346 | 350 | return 0; |
347 | 351 | |
348 | 352 | sp->smk_initialized = 1; |
... | ... | @@ -373,6 +377,13 @@ |
373 | 377 | nsp = smk_import(op, 0); |
374 | 378 | if (nsp != NULL) |
375 | 379 | sp->smk_root = nsp; |
380 | + } else if (strncmp(op, SMK_FSTRANS, strlen(SMK_FSTRANS)) == 0) { | |
381 | + op += strlen(SMK_FSTRANS); | |
382 | + nsp = smk_import(op, 0); | |
383 | + if (nsp != NULL) { | |
384 | + sp->smk_root = nsp; | |
385 | + transmute = 1; | |
386 | + } | |
376 | 387 | } |
377 | 388 | } |
378 | 389 | |
379 | 390 | |
380 | 391 | |
... | ... | @@ -380,10 +391,14 @@ |
380 | 391 | * Initialize the root inode. |
381 | 392 | */ |
382 | 393 | isp = inode->i_security; |
383 | - if (isp == NULL) | |
394 | + if (inode->i_security == NULL) { | |
384 | 395 | inode->i_security = new_inode_smack(sp->smk_root); |
385 | - else | |
396 | + isp = inode->i_security; | |
397 | + } else | |
386 | 398 | isp->smk_inode = sp->smk_root; |
399 | + | |
400 | + if (transmute) | |
401 | + isp->smk_flags |= SMK_INODE_TRANSMUTE; | |
387 | 402 | |
388 | 403 | return 0; |
389 | 404 | } |