Skip to content

Commit fbf06ce

Browse files
cinghioGithubmimizohar
authored andcommitted
ima: fix wrong zero-assignment during securityfs dentry remove
In case of error during ima_fs_init() all the dentry already created are removed. {ascii, binary}_securityfs_measurement_lists are freed calling for each array the remove_securityfs_measurement_lists(). This function, at the end, assigns to zero the securityfs_measurement_list_count. This causes during the second call of remove_securityfs_measurement_lists() to leave the dentry of the array pending, not removing them correctly, because the securityfs_measurement_list_count is already zero. Move the securityfs_measurement_list_count = 0 after the two remove_securityfs_measurement_lists() calls to correctly remove all the dentry already allocated. Fixes: 9fa8e76 ("ima: add crypto agility support for template-hash algorithm") Signed-off-by: Enrico Bravi <[email protected]> Reviewed-by: Roberto Sassu <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent c3f38fa commit fbf06ce

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

security/integrity/ima/ima_fs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,6 @@ static void __init remove_securityfs_measurement_lists(struct dentry **lists)
427427

428428
kfree(lists);
429429
}
430-
431-
securityfs_measurement_list_count = 0;
432430
}
433431

434432
static int __init create_securityfs_measurement_lists(void)
@@ -625,6 +623,7 @@ int __init ima_fs_init(void)
625623
securityfs_remove(binary_runtime_measurements);
626624
remove_securityfs_measurement_lists(ascii_securityfs_measurement_lists);
627625
remove_securityfs_measurement_lists(binary_securityfs_measurement_lists);
626+
securityfs_measurement_list_count = 0;
628627
securityfs_remove(ima_symlink);
629628
securityfs_remove(ima_dir);
630629

0 commit comments

Comments
 (0)