lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1638883122-8953-1-git-send-email-dotdot@yandex-team.ru>
Date:   Tue,  7 Dec 2021 16:18:42 +0300
From:   Roman Anufriev <dotdot@...dex-team.ru>
To:     linux-ext4@...r.kernel.org
Cc:     tytso@....edu, jack@...e.cz, dmtrmonakhov@...dex-team.ru,
        dotdot@...dex-team.ru
Subject: [PATCH] ext4: compare inode's i_projid with EXT4_DEF_PROJID rather than check EXT4_INODE_PROJINHERIT flag

Commit 7ddf79a10395 ("ext4: only set project inherit bit for directory")
removes EXT4_INODE_PROJINHERIT flag from regular files. This makes
ext4_statfs() output incorrect (function does not apply quota limits
on used/available space, etc) when called on dentry of regular file
with project quota enabled.

This patch fixes this by comparing inode's i_projid with
EXT4_DEF_PROJID, as there is no point in calling ext4_statfs_project()
for inode with default project id.

$ sudo project_quota info dir/
project   2147516417
usage     4096
limit     5242880
inodes    4
ilimit    0
$ sudo project_quota info dir/file | grep project
project   2147516417
$ df -h /dev/loop0
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      232M  2.1M  214M   1% /mnt/ext4img

without patch:
$ df -h dir/
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img
$ df -h dir/file
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      232M  2.1M  214M   1% /mnt/ext4img

with patch:
$ df -h dir/
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img
$ df -h dir/file
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      5.0M  4.0K  5.0M   1% /mnt/ext4img

Signed-off-by: Roman Anufriev <dotdot@...dex-team.ru>
---
 fs/ext4/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 79b6a0c..682d675 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6074,6 +6074,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	struct super_block *sb = dentry->d_sb;
 	struct ext4_sb_info *sbi = EXT4_SB(sb);
 	struct ext4_super_block *es = sbi->s_es;
+	kprojid_t kprojid;
 	ext4_fsblk_t overhead = 0, resv_blocks;
 	s64 bfree;
 	resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
@@ -6098,9 +6099,10 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
 	buf->f_fsid = uuid_to_fsid(es->s_uuid);
 
 #ifdef CONFIG_QUOTA
-	if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) &&
+	kprojid = EXT4_I(dentry->d_inode)->i_projid;
+	if ((from_kprojid(current_user_ns(), kprojid) != EXT4_DEF_PROJID) &&
 	    sb_has_quota_limits_enabled(sb, PRJQUOTA))
-		ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf);
+		ext4_statfs_project(sb, kprojid, buf);
 #endif
 	return 0;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ