fscrypt: remove 'ci' parameter from fscrypt_put_encryption_info()
authorEric Biggers <ebiggers@google.com>
Fri, 12 Jan 2018 04:30:13 +0000 (23:30 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 12 Jan 2018 04:30:13 +0000 (23:30 -0500)
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>
fs/crypto/keyinfo.c
fs/ext4/super.c
fs/f2fs/inode.c
fs/ubifs/super.c
include/linux/fscrypt_notsupp.h
include/linux/fscrypt_supp.h

index c115eac4b4cfa1fed7f271880c84a42b033102e9..05f5ee1f07057ab6484c84c4dc4b66d0f3a1e934 100644 (file)
@@ -355,19 +355,9 @@ out:
 }
 EXPORT_SYMBOL(fscrypt_get_encryption_info);
 
-void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci)
+void fscrypt_put_encryption_info(struct inode *inode)
 {
-       struct fscrypt_info *prev;
-
-       if (ci == NULL)
-               ci = READ_ONCE(inode->i_crypt_info);
-       if (ci == NULL)
-               return;
-
-       prev = cmpxchg(&inode->i_crypt_info, ci, NULL);
-       if (prev != ci)
-               return;
-
-       put_crypt_info(ci);
+       put_crypt_info(inode->i_crypt_info);
+       inode->i_crypt_info = NULL;
 }
 EXPORT_SYMBOL(fscrypt_put_encryption_info);
index 7c46693a14d763d53b84eec9602f4a854918bb4d..152d05d983f6e666be203a0a313625227ff06d38 100644 (file)
@@ -1069,9 +1069,7 @@ void ext4_clear_inode(struct inode *inode)
                jbd2_free_inode(EXT4_I(inode)->jinode);
                EXT4_I(inode)->jinode = NULL;
        }
-#ifdef CONFIG_EXT4_FS_ENCRYPTION
-       fscrypt_put_encryption_info(inode, NULL);
-#endif
+       fscrypt_put_encryption_info(inode);
 }
 
 static struct inode *ext4_nfs_get_inode(struct super_block *sb,
index b4c4f2b2530404d5dc5b60bafab86a910c1a7879..22a5607a051837266c9c9d1722f65c3e36cd3758 100644 (file)
@@ -569,7 +569,7 @@ no_delete:
                        !exist_written_data(sbi, inode->i_ino, ORPHAN_INO));
        }
 out_clear:
-       fscrypt_put_encryption_info(inode, NULL);
+       fscrypt_put_encryption_info(inode);
        clear_inode(inode);
 }
 
index 0beb285b143da6cfe9cc238ede64313f8f75a604..b16ef162344ab382143578d277248c88f2fdc067 100644 (file)
@@ -379,9 +379,7 @@ out:
        }
 done:
        clear_inode(inode);
-#ifdef CONFIG_UBIFS_FS_ENCRYPTION
-       fscrypt_put_encryption_info(inode, NULL);
-#endif
+       fscrypt_put_encryption_info(inode);
 }
 
 static void ubifs_dirty_inode(struct inode *inode, int flags)
index 342eb97e047677938a5e8acdd046dda50e3e44fb..44b50c04bae9a3ad31cb319635c683dfa1899c6b 100644 (file)
@@ -105,8 +105,7 @@ static inline int fscrypt_get_encryption_info(struct inode *inode)
        return -EOPNOTSUPP;
 }
 
-static inline void fscrypt_put_encryption_info(struct inode *inode,
-                                              struct fscrypt_info *ci)
+static inline void fscrypt_put_encryption_info(struct inode *inode)
 {
        return;
 }
index 2dd5767c77b0c3e1f3c7cac0cc7c018466e1175a..477a7a6504d214aa80b994106943d7ef6878ee34 100644 (file)
@@ -96,7 +96,7 @@ extern int fscrypt_inherit_context(struct inode *, struct inode *,
                                        void *, bool);
 /* keyinfo.c */
 extern int fscrypt_get_encryption_info(struct inode *);
-extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *);
+extern void fscrypt_put_encryption_info(struct inode *);
 
 /* fname.c */
 extern int fscrypt_setup_filename(struct inode *, const struct qstr *,