File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -205,14 +205,19 @@ static int allocate_filesystem_keyring(struct super_block *sb)
205
205
}
206
206
207
207
/*
208
- * This is called at unmount time to release all encryption keys that have been
209
- * added to the filesystem, along with the keyring that contains them.
208
+ * Release all encryption keys that have been added to the filesystem, along
209
+ * with the keyring that contains them.
210
210
*
211
- * Note that besides clearing and freeing memory, this might need to evict keys
212
- * from the keyslots of an inline crypto engine. Therefore, this must be called
213
- * while the filesystem's underlying block device(s) are still available.
211
+ * This is called at unmount time. The filesystem's underlying block device(s)
212
+ * are still available at this time; this is important because after user file
213
+ * accesses have been allowed, this function may need to evict keys from the
214
+ * keyslots of an inline crypto engine, which requires the block device(s).
215
+ *
216
+ * This is also called when the super_block is being freed. This is needed to
217
+ * avoid a memory leak if mounting fails after the "test_dummy_encryption"
218
+ * option was processed, as in that case the unmount-time call isn't made.
214
219
*/
215
- void fscrypt_sb_delete (struct super_block * sb )
220
+ void fscrypt_destroy_keyring (struct super_block * sb )
216
221
{
217
222
struct fscrypt_keyring * keyring = sb -> s_master_keys ;
218
223
size_t i ;
Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ static void __put_super(struct super_block *s)
291
291
WARN_ON (s -> s_inode_lru .node );
292
292
WARN_ON (!list_empty (& s -> s_mounts ));
293
293
security_sb_free (s );
294
+ fscrypt_destroy_keyring (s );
294
295
put_user_ns (s -> s_user_ns );
295
296
kfree (s -> s_subtype );
296
297
call_rcu (& s -> rcu , destroy_super_rcu );
@@ -479,7 +480,7 @@ void generic_shutdown_super(struct super_block *sb)
479
480
evict_inodes (sb );
480
481
/* only nonzero refcount inodes can have marks */
481
482
fsnotify_sb_delete (sb );
482
- fscrypt_sb_delete (sb );
483
+ fscrypt_destroy_keyring (sb );
483
484
security_sb_delete (sb );
484
485
485
486
if (sb -> s_dio_done_wq ) {
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ fscrypt_free_dummy_policy(struct fscrypt_dummy_policy *dummy_policy)
307
307
}
308
308
309
309
/* keyring.c */
310
- void fscrypt_sb_delete (struct super_block * sb );
310
+ void fscrypt_destroy_keyring (struct super_block * sb );
311
311
int fscrypt_ioctl_add_key (struct file * filp , void __user * arg );
312
312
int fscrypt_add_test_dummy_key (struct super_block * sb ,
313
313
const struct fscrypt_dummy_policy * dummy_policy );
@@ -521,7 +521,7 @@ fscrypt_free_dummy_policy(struct fscrypt_dummy_policy *dummy_policy)
521
521
}
522
522
523
523
/* keyring.c */
524
- static inline void fscrypt_sb_delete (struct super_block * sb )
524
+ static inline void fscrypt_destroy_keyring (struct super_block * sb )
525
525
{
526
526
}
527
527
You can’t perform that action at this time.
0 commit comments