Skip to content

Commit d3cc1b0

Browse files
ebiggersjankara
authored andcommitted
quota: explicitly forbid quota files from being encrypted
Since commit d7e7b9a ("fscrypt: stop using keyrings subsystem for fscrypt_master_key"), xfstest generic/270 causes a WARNING when run on f2fs with test_dummy_encryption in the mount options: $ kvm-xfstests -c f2fs/encrypt generic/270 [...] WARNING: CPU: 1 PID: 2453 at fs/crypto/keyring.c:240 fscrypt_destroy_keyring+0x1f5/0x260 The cause of the WARNING is that not all encrypted inodes have been evicted before fscrypt_destroy_keyring() is called, which violates an assumption. This happens because the test uses an external quota file, which gets automatically encrypted due to test_dummy_encryption. Encryption of quota files has never really been supported. On ext4, ext4_quota_read() does not decrypt the data, so encrypted quota files are always considered invalid on ext4. On f2fs, f2fs_quota_read() uses the pagecache, so trying to use an encrypted quota file gets farther, resulting in the issue described above being possible. But this was never intended to be possible, and there is no use case for it. Therefore, make the quota support layer explicitly reject using IS_ENCRYPTED inodes when quotaon is attempted. Cc: [email protected] Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Jan Kara <[email protected]> Message-Id: <[email protected]>
1 parent 3f86ed6 commit d3cc1b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/quota/dquot.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,20 @@ static int vfs_setup_quota_inode(struct inode *inode, int type)
23392339
if (sb_has_quota_loaded(sb, type))
23402340
return -EBUSY;
23412341

2342+
/*
2343+
* Quota files should never be encrypted. They should be thought of as
2344+
* filesystem metadata, not user data. New-style internal quota files
2345+
* cannot be encrypted by users anyway, but old-style external quota
2346+
* files could potentially be incorrectly created in an encrypted
2347+
* directory, hence this explicit check. Some reasons why encrypted
2348+
* quota files don't work include: (1) some filesystems that support
2349+
* encryption don't handle it in their quota_read and quota_write, and
2350+
* (2) cleaning up encrypted quota files at unmount would need special
2351+
* consideration, as quota files are cleaned up later than user files.
2352+
*/
2353+
if (IS_ENCRYPTED(inode))
2354+
return -EINVAL;
2355+
23422356
dqopt->files[type] = igrab(inode);
23432357
if (!dqopt->files[type])
23442358
return -EIO;

0 commit comments

Comments
 (0)