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

fscrypt: remove 'ci' parameter from fscrypt_put_encryption_info()

fscrypt_put_encryption_info() is only called when evicting an inode, so
the 'struct fscrypt_info *ci' parameter is always NULL, and there cannot
be races with other threads. This was cruft left over from the broken
key revocation code. Remove the unused parameter and the cmpxchg().

Also remove the #ifdefs around the fscrypt_put_encryption_info() calls,
since fscrypt_notsupp.h defines a no-op stub for it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Eric Biggers and committed by
Theodore Ts'o
3d204e24 2f46a2bc

+8 -23
+3 -13
fs/crypto/keyinfo.c
··· 355 355 } 356 356 EXPORT_SYMBOL(fscrypt_get_encryption_info); 357 357 358 - void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) 358 + void fscrypt_put_encryption_info(struct inode *inode) 359 359 { 360 - struct fscrypt_info *prev; 361 - 362 - if (ci == NULL) 363 - ci = READ_ONCE(inode->i_crypt_info); 364 - if (ci == NULL) 365 - return; 366 - 367 - prev = cmpxchg(&inode->i_crypt_info, ci, NULL); 368 - if (prev != ci) 369 - return; 370 - 371 - put_crypt_info(ci); 360 + put_crypt_info(inode->i_crypt_info); 361 + inode->i_crypt_info = NULL; 372 362 } 373 363 EXPORT_SYMBOL(fscrypt_put_encryption_info);
+1 -3
fs/ext4/super.c
··· 1069 1069 jbd2_free_inode(EXT4_I(inode)->jinode); 1070 1070 EXT4_I(inode)->jinode = NULL; 1071 1071 } 1072 - #ifdef CONFIG_EXT4_FS_ENCRYPTION 1073 - fscrypt_put_encryption_info(inode, NULL); 1074 - #endif 1072 + fscrypt_put_encryption_info(inode); 1075 1073 } 1076 1074 1077 1075 static struct inode *ext4_nfs_get_inode(struct super_block *sb,
+1 -1
fs/f2fs/inode.c
··· 569 569 !exist_written_data(sbi, inode->i_ino, ORPHAN_INO)); 570 570 } 571 571 out_clear: 572 - fscrypt_put_encryption_info(inode, NULL); 572 + fscrypt_put_encryption_info(inode); 573 573 clear_inode(inode); 574 574 } 575 575
+1 -3
fs/ubifs/super.c
··· 379 379 } 380 380 done: 381 381 clear_inode(inode); 382 - #ifdef CONFIG_UBIFS_FS_ENCRYPTION 383 - fscrypt_put_encryption_info(inode, NULL); 384 - #endif 382 + fscrypt_put_encryption_info(inode); 385 383 } 386 384 387 385 static void ubifs_dirty_inode(struct inode *inode, int flags)
+1 -2
include/linux/fscrypt_notsupp.h
··· 105 105 return -EOPNOTSUPP; 106 106 } 107 107 108 - static inline void fscrypt_put_encryption_info(struct inode *inode, 109 - struct fscrypt_info *ci) 108 + static inline void fscrypt_put_encryption_info(struct inode *inode) 110 109 { 111 110 return; 112 111 }
+1 -1
include/linux/fscrypt_supp.h
··· 96 96 void *, bool); 97 97 /* keyinfo.c */ 98 98 extern int fscrypt_get_encryption_info(struct inode *); 99 - extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *); 99 + extern void fscrypt_put_encryption_info(struct inode *); 100 100 101 101 /* fname.c */ 102 102 extern int fscrypt_setup_filename(struct inode *, const struct qstr *,