aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2018-01-11 23:30:13 -0500
committerTheodore Ts'o <tytso@mit.edu>2018-01-11 23:30:13 -0500
commit3d204e24d452f96704f5feb83f6b7654245defc9 (patch)
tree680d6fad2a6f7a7d6638e828b8ea2542beea4509
parent2f46a2bc2694877332f9c1ff47acb7fa117e168a (diff)
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>
-rw-r--r--fs/crypto/keyinfo.c16
-rw-r--r--fs/ext4/super.c4
-rw-r--r--fs/f2fs/inode.c2
-rw-r--r--fs/ubifs/super.c4
-rw-r--r--include/linux/fscrypt_notsupp.h3
-rw-r--r--include/linux/fscrypt_supp.h2
6 files changed, 8 insertions, 23 deletions
diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c
index c115eac4b4cf..05f5ee1f0705 100644
--- a/fs/crypto/keyinfo.c
+++ b/fs/crypto/keyinfo.c
@@ -355,19 +355,9 @@ out:
355} 355}
356EXPORT_SYMBOL(fscrypt_get_encryption_info); 356EXPORT_SYMBOL(fscrypt_get_encryption_info);
357 357
358void fscrypt_put_encryption_info(struct inode *inode, struct fscrypt_info *ci) 358void fscrypt_put_encryption_info(struct inode *inode)
359{ 359{
360 struct fscrypt_info *prev; 360 put_crypt_info(inode->i_crypt_info);
361 361 inode->i_crypt_info = NULL;
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);
372} 362}
373EXPORT_SYMBOL(fscrypt_put_encryption_info); 363EXPORT_SYMBOL(fscrypt_put_encryption_info);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7c46693a14d7..152d05d983f6 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1069,9 +1069,7 @@ void ext4_clear_inode(struct inode *inode)
1069 jbd2_free_inode(EXT4_I(inode)->jinode); 1069 jbd2_free_inode(EXT4_I(inode)->jinode);
1070 EXT4_I(inode)->jinode = NULL; 1070 EXT4_I(inode)->jinode = NULL;
1071 } 1071 }
1072#ifdef CONFIG_EXT4_FS_ENCRYPTION 1072 fscrypt_put_encryption_info(inode);
1073 fscrypt_put_encryption_info(inode, NULL);
1074#endif
1075} 1073}
1076 1074
1077static struct inode *ext4_nfs_get_inode(struct super_block *sb, 1075static struct inode *ext4_nfs_get_inode(struct super_block *sb,
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index b4c4f2b25304..22a5607a0518 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -569,7 +569,7 @@ no_delete:
569 !exist_written_data(sbi, inode->i_ino, ORPHAN_INO)); 569 !exist_written_data(sbi, inode->i_ino, ORPHAN_INO));
570 } 570 }
571out_clear: 571out_clear:
572 fscrypt_put_encryption_info(inode, NULL); 572 fscrypt_put_encryption_info(inode);
573 clear_inode(inode); 573 clear_inode(inode);
574} 574}
575 575
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 0beb285b143d..b16ef162344a 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -379,9 +379,7 @@ out:
379 } 379 }
380done: 380done:
381 clear_inode(inode); 381 clear_inode(inode);
382#ifdef CONFIG_UBIFS_FS_ENCRYPTION 382 fscrypt_put_encryption_info(inode);
383 fscrypt_put_encryption_info(inode, NULL);
384#endif
385} 383}
386 384
387static void ubifs_dirty_inode(struct inode *inode, int flags) 385static void ubifs_dirty_inode(struct inode *inode, int flags)
diff --git a/include/linux/fscrypt_notsupp.h b/include/linux/fscrypt_notsupp.h
index 342eb97e0476..44b50c04bae9 100644
--- a/include/linux/fscrypt_notsupp.h
+++ b/include/linux/fscrypt_notsupp.h
@@ -105,8 +105,7 @@ static inline int fscrypt_get_encryption_info(struct inode *inode)
105 return -EOPNOTSUPP; 105 return -EOPNOTSUPP;
106} 106}
107 107
108static inline void fscrypt_put_encryption_info(struct inode *inode, 108static inline void fscrypt_put_encryption_info(struct inode *inode)
109 struct fscrypt_info *ci)
110{ 109{
111 return; 110 return;
112} 111}
diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h
index 2dd5767c77b0..477a7a6504d2 100644
--- a/include/linux/fscrypt_supp.h
+++ b/include/linux/fscrypt_supp.h
@@ -96,7 +96,7 @@ extern int fscrypt_inherit_context(struct inode *, struct inode *,
96 void *, bool); 96 void *, bool);
97/* keyinfo.c */ 97/* keyinfo.c */
98extern int fscrypt_get_encryption_info(struct inode *); 98extern int fscrypt_get_encryption_info(struct inode *);
99extern void fscrypt_put_encryption_info(struct inode *, struct fscrypt_info *); 99extern void fscrypt_put_encryption_info(struct inode *);
100 100
101/* fname.c */ 101/* fname.c */
102extern int fscrypt_setup_filename(struct inode *, const struct qstr *, 102extern int fscrypt_setup_filename(struct inode *, const struct qstr *,