From: Jan Kara Date: Wed, 7 Dec 2022 11:59:27 +0000 (+0100) Subject: ext4: initialize quota before expanding inode in setproject ioctl X-Git-Tag: v4.9.337~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56836c32a4b5df796b19635b84a7ba4e202ffca9;p=thirdparty%2Fkernel%2Fstable.git ext4: initialize quota before expanding inode in setproject ioctl commit 1485f726c6dec1a1f85438f2962feaa3d585526f upstream. Make sure we initialize quotas before possibly expanding inode space (and thus maybe needing to allocate external xattr block) in ext4_ioctl_setproject(). This prevents not accounting the necessary block allocation. Signed-off-by: Jan Kara Cc: stable@kernel.org Link: https://lore.kernel.org/r/20221207115937.26601-1-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index ccb584e60904d..ac9f678ac4aed 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -333,6 +333,10 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid) if (IS_NOQUOTA(inode)) goto out_unlock; + err = dquot_initialize(inode); + if (err) + goto out_unlock; + err = ext4_get_inode_loc(inode, &iloc); if (err) goto out_unlock; @@ -345,10 +349,6 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid) } brelse(iloc.bh); - err = dquot_initialize(inode); - if (err) - return err; - handle = ext4_journal_start(inode, EXT4_HT_QUOTA, EXT4_QUOTA_INIT_BLOCKS(sb) + EXT4_QUOTA_DEL_BLOCKS(sb) + 3);