This is a note to let you know that I've just added the patch titled xfs: ensure that the inode uid/gid match values match the icdinode ones to the 5.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: xfs-ensure-that-the-inode-uid-gid-match-values-match-the-icdinode-ones.patch and it can be found in the queue-5.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable-owner@xxxxxxxxxxxxxxx Wed Apr 12 06:27:52 2023 From: Chandan Babu R <chandan.babu@xxxxxxxxxx> Date: Wed, 12 Apr 2023 09:56:10 +0530 Subject: xfs: ensure that the inode uid/gid match values match the icdinode ones To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: sashal@xxxxxxxxxx, mcgrof@xxxxxxxxxx, linux-xfs@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx, djwong@xxxxxxxxxx, chandan.babu@xxxxxxxxxx, amir73il@xxxxxxxxx, leah.rumancik@xxxxxxxxx Message-ID: <20230412042624.600511-4-chandan.babu@xxxxxxxxxx> From: Christoph Hellwig <hch@xxxxxx> commit 3d8f2821502d0b60bac2789d0bea951fda61de0c upstream. Instead of only synchronizing the uid/gid values in xfs_setup_inode, ensure that they always match to prepare for removing the icdinode fields. Signed-off-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Acked-by: Darrick J. Wong <djwong@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/xfs/libxfs/xfs_inode_buf.c | 2 ++ fs/xfs/xfs_icache.c | 4 ++++ fs/xfs/xfs_inode.c | 8 ++++++-- fs/xfs/xfs_iops.c | 3 --- 4 files changed, 12 insertions(+), 5 deletions(-) --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c @@ -223,7 +223,9 @@ xfs_inode_from_disk( to->di_format = from->di_format; to->di_uid = be32_to_cpu(from->di_uid); + inode->i_uid = xfs_uid_to_kuid(to->di_uid); to->di_gid = be32_to_cpu(from->di_gid); + inode->i_gid = xfs_gid_to_kgid(to->di_gid); to->di_flushiter = be16_to_cpu(from->di_flushiter); /* --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -289,6 +289,8 @@ xfs_reinit_inode( uint64_t version = inode_peek_iversion(inode); umode_t mode = inode->i_mode; dev_t dev = inode->i_rdev; + kuid_t uid = inode->i_uid; + kgid_t gid = inode->i_gid; error = inode_init_always(mp->m_super, inode); @@ -297,6 +299,8 @@ xfs_reinit_inode( inode_set_iversion_queried(inode, version); inode->i_mode = mode; inode->i_rdev = dev; + inode->i_uid = uid; + inode->i_gid = gid; return error; } --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -806,15 +806,19 @@ xfs_ialloc( inode->i_mode = mode; set_nlink(inode, nlink); - ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid()); - ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid()); + inode->i_uid = current_fsuid(); + ip->i_d.di_uid = xfs_kuid_to_uid(inode->i_uid); inode->i_rdev = rdev; ip->i_d.di_projid = prid; if (pip && XFS_INHERIT_GID(pip)) { + inode->i_gid = VFS_I(pip)->i_gid; ip->i_d.di_gid = pip->i_d.di_gid; if ((VFS_I(pip)->i_mode & S_ISGID) && S_ISDIR(mode)) inode->i_mode |= S_ISGID; + } else { + inode->i_gid = current_fsgid(); + ip->i_d.di_gid = xfs_kgid_to_gid(inode->i_gid); } /* --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1288,9 +1288,6 @@ xfs_setup_inode( /* make the inode look hashed for the writeback code */ inode_fake_hash(inode); - inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid); - inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid); - i_size_write(inode, ip->i_d.di_size); xfs_diflags_to_iflags(inode, ip); Patches currently in stable-queue which might be from stable-owner@xxxxxxxxxxxxxxx are queue-5.4/xfs-merge-the-projid-fields-in-struct-xfs_icdinode.patch queue-5.4/xfs-simplify-a-check-in-xfs_ioctl_setattr_check_cowextsize.patch queue-5.4/xfs-shut-down-the-filesystem-if-we-screw-up-quota-reservation.patch queue-5.4/irqdomain-fix-mapping-creation-race.patch queue-5.4/xfs-add-a-new-xfs_sb_version_has_v3inode-helper.patch queue-5.4/xfs-only-check-the-superblock-version-for-dinode-size-calculation.patch queue-5.4/xfs-force-log-and-push-ail-to-clear-pinned-inodes-when-aborting-mount.patch queue-5.4/xfs-fix-up-non-directory-creation-in-sgid-directories.patch queue-5.4/xfs-consider-shutdown-in-bmapbt-cursor-delete-assert.patch queue-5.4/xfs-set-inode-size-after-creating-symlink.patch queue-5.4/xfs-remove-the-kuid-kgid-conversion-wrappers.patch queue-5.4/xfs-ensure-that-the-inode-uid-gid-match-values-match-the-icdinode-ones.patch queue-5.4/xfs-remove-the-icdinode-di_uid-di_gid-members.patch queue-5.4/xfs-don-t-reuse-busy-extents-on-extent-trim.patch queue-5.4/irqdomain-refactor-__irq_domain_alloc_irqs.patch queue-5.4/xfs-simplify-di_flags2-inheritance-in-xfs_ialloc.patch queue-5.4/irqdomain-look-for-existing-mapping-only-once.patch queue-5.4/xfs-show-the-proper-user-quota-options.patch queue-5.4/xfs-report-corruption-only-as-a-regular-error.patch queue-5.4/xfs-remove-the-di_version-field-from-struct-icdinode.patch