Skip to content

Commit 13a10da

Browse files
committed
fscrypt: don't print name of busy file when removing key
When an encryption key can't be fully removed due to file(s) protected by it still being in-use, we shouldn't really print the path to one of these files to the kernel log, since parts of this path are likely to be encrypted on-disk, and (depending on how the system is set up) the confidentiality of this path might be lost by printing it to the log. This is a trade-off: a single file path often doesn't matter at all, especially if it's a directory; the kernel log might still be protected in some way; and I had originally hoped that any "inode(s) still busy" bugs (which are security weaknesses in their own right) would be quickly fixed and that to do so it would be super helpful to always know the file path and not have to run 'find dir -inum $inum' after the fact. But in practice, these bugs can be hard to fix (e.g. due to asynchronous process killing that is difficult to eliminate, for performance reasons), and also not tied to specific files, so knowing a file path doesn't necessarily help. So to be safe, for now let's just show the inode number, not the path. If someone really wants to know a path they can use 'find -inum'. Fixes: b1c0ec3 ("fscrypt: add FS_IOC_REMOVE_ENCRYPTION_KEY ioctl") Cc: <[email protected]> # v5.4+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Eric Biggers <[email protected]>
1 parent 50d9fad commit 13a10da

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

fs/crypto/keyring.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -776,9 +776,6 @@ static int check_for_busy_inodes(struct super_block *sb,
776776
struct list_head *pos;
777777
size_t busy_count = 0;
778778
unsigned long ino;
779-
struct dentry *dentry;
780-
char _path[256];
781-
char *path = NULL;
782779

783780
spin_lock(&mk->mk_decrypted_inodes_lock);
784781

@@ -797,22 +794,14 @@ static int check_for_busy_inodes(struct super_block *sb,
797794
struct fscrypt_info,
798795
ci_master_key_link)->ci_inode;
799796
ino = inode->i_ino;
800-
dentry = d_find_alias(inode);
801797
}
802798
spin_unlock(&mk->mk_decrypted_inodes_lock);
803799

804-
if (dentry) {
805-
path = dentry_path(dentry, _path, sizeof(_path));
806-
dput(dentry);
807-
}
808-
if (IS_ERR_OR_NULL(path))
809-
path = "(unknown)";
810-
811800
fscrypt_warn(NULL,
812-
"%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu (%s)",
801+
"%s: %zu inode(s) still busy after removing key with %s %*phN, including ino %lu",
813802
sb->s_id, busy_count, master_key_spec_type(&mk->mk_spec),
814803
master_key_spec_len(&mk->mk_spec), (u8 *)&mk->mk_spec.u,
815-
ino, path);
804+
ino);
816805
return -EBUSY;
817806
}
818807

0 commit comments

Comments
 (0)