Skip to content

Commit f631e92

Browse files
ebiggersbwhacks
authored andcommitted
smack: use GFP_NOFS while holding inode_smack::smk_lock
commit e5bfad3 upstream. inode_smack::smk_lock is taken during smack_d_instantiate(), which is called during a filesystem transaction when creating a file on ext4. Therefore to avoid a deadlock, all code that takes this lock must use GFP_NOFS, to prevent memory reclaim from waiting for the filesystem transaction to complete. Reported-by: [email protected] Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Casey Schaufler <[email protected]> [bwh: Backported to 3.16: - Drop change to smk_netlbl_mls(), where GFP_ATOMIC is used - Adjust context] Signed-off-by: Ben Hutchings <[email protected]>
1 parent eadea2c commit f631e92

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

security/smack/smack_access.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ char *smk_parse_smack(const char *string, int len)
430430
if (i == 0 || i >= SMK_LONGLABEL)
431431
return NULL;
432432

433-
smack = kzalloc(i + 1, GFP_KERNEL);
433+
smack = kzalloc(i + 1, GFP_NOFS);
434434
if (smack != NULL) {
435435
strncpy(smack, string, i + 1);
436436
smack[i] = '\0';
@@ -502,7 +502,7 @@ struct smack_known *smk_import_entry(const char *string, int len)
502502
if (skp != NULL)
503503
goto freeout;
504504

505-
skp = kzalloc(sizeof(*skp), GFP_KERNEL);
505+
skp = kzalloc(sizeof(*skp), GFP_NOFS);
506506
if (skp == NULL)
507507
goto freeout;
508508

security/smack/smack_lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip,
7070
if (ip->i_op->getxattr == NULL)
7171
return NULL;
7272

73-
buffer = kzalloc(SMK_LONGLABEL, GFP_KERNEL);
73+
buffer = kzalloc(SMK_LONGLABEL, GFP_NOFS);
7474
if (buffer == NULL)
7575
return NULL;
7676

0 commit comments

Comments
 (0)