xfs: various fixes for 6.2

This is an assorted collection of bug fixes that have been bundled
 together.  The first patch fixes a metadump corruption vector resulting
 from a three-way race between a slow-running blkid process, the kernel
 mounting, changing, and unmounting the fs, and xfs_db reading stale
 block device pagecache contents.
 
 The middle two patches address gcc warnings.
 
 The final patch fixes a subtle corruption bug wherein making a delalloc
 reservation on a filesystem with quotas enabled would sample the data
 mapping, try to attach dquots, unlock the inode to attach the dquots,
 relock the inode, and fail to reverify the sampled data.  If another
 process updated the data mapping while the inode was unlocked, the
 reservation would proceed with stale data and corrupt the data fork.
 
 Signed-off-by: Darrick J. Wong <djwong@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEUzaAxoMeQq6m2jMV+H93GTRKtOsFAmOHjswACgkQ+H93GTRK
 tOuSKQ//dBLc5nx9HRFXdFMPi+uytPXzu8twkLfogkHh2F0oL7En5MnRdTY6jhTN
 zf/f+pQhLIqctYhV7xtMvUT6bC6HD95jJGjcOS8gA8/lSNoeVPJBEhCjo5+6uqyk
 /Nb3RaDAVvP4fG6eb03pbt/dQn8swgxyt7XDzxIfhGfAkKXm/ksSIcisv0EsSQdc
 PFZfbklCw1PzMcAUhysHyrNlhf3bAYk1o/IYY855P/OHRxBZxyf3CAFwlhyP5Cl+
 jCV1JcgkCR5VCV4iuCsmxMIwx0FVJwuk2YTLZNipEOrehR7Kzubgdg159eFzNBZS
 a0lXCLWSRCvNIvl/yUbWk+tBEKgk9WPdP/ihHRw9qxR+3wN2TmcEMkSTBqbPqxDz
 C42iaInjVXw+Tg7hm6XdHaHcLp3xR24l3uZvp9LCEXZ8SdltQoglbsyO0KcMqgfl
 qjgyoub9KOR4N/CaNPgV1nObDbGAy+j12hmqX4BaPlTz7SjFios3rEZi+i9K1clj
 Z/O7aIBVgFKDkE691f9S2VsHNnIFxWSgCQWKAsfr9ES96AA7UdnE/wgXeeKbu74Q
 GNDIJ5hicFjn2HqO/xyxp+b9plvAzLdBAxAHXm3l00QKrNmHDbHzVqHSXSeFk0u7
 +JvOaFH8vgZsjetT4tNIyBXYEsGc+/NRV+AT4HJriuoSIstoSS4=
 =tQJn
 -----END PGP SIGNATURE-----

Merge tag 'random-fixes-6.2_2022-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.2-mergeC

xfs: various fixes for 6.2

This is an assorted collection of bug fixes that have been bundled
together.  The first patch fixes a metadump corruption vector resulting
from a three-way race between a slow-running blkid process, the kernel
mounting, changing, and unmounting the fs, and xfs_db reading stale
block device pagecache contents.

The middle two patches address gcc warnings.

The final patch fixes a subtle corruption bug wherein making a delalloc
reservation on a filesystem with quotas enabled would sample the data
mapping, try to attach dquots, unlock the inode to attach the dquots,
relock the inode, and fail to reverify the sampled data.  If another
process updated the data mapping while the inode was unlocked, the
reservation would proceed with stale data and corrupt the data fork.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>

* tag 'random-fixes-6.2_2022-11-30' of git://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: attach dquots to inode before reading data/cow fork mappings
  xfs: shut up -Wuninitialized in xfsaild_push
  xfs: use memcpy, not strncpy, to format the attr prefix during listxattr
  xfs: invalidate block device page cache during unmount
This commit is contained in:
Darrick J. Wong 2022-11-30 09:25:25 -08:00
commit 4b4d11bbec
4 changed files with 9 additions and 6 deletions

View File

@ -1945,6 +1945,7 @@ xfs_free_buftarg(
list_lru_destroy(&btp->bt_lru);
blkdev_issue_flush(btp->bt_bdev);
invalidate_bdev(btp->bt_bdev);
fs_put_dax(btp->bt_daxdev, btp->bt_mount);
kmem_free(btp);

View File

@ -978,6 +978,10 @@ xfs_buffered_write_iomap_begin(
ASSERT(!XFS_IS_REALTIME_INODE(ip));
error = xfs_qm_dqattach(ip);
if (error)
return error;
error = xfs_ilock_for_iomap(ip, flags, &lockmode);
if (error)
return error;
@ -1081,10 +1085,6 @@ xfs_buffered_write_iomap_begin(
allocfork = XFS_COW_FORK;
}
error = xfs_qm_dqattach_locked(ip, false);
if (error)
goto out_unlock;
if (eof && offset + count > XFS_ISIZE(ip)) {
/*
* Determine the initial size of the preallocation.

View File

@ -422,7 +422,7 @@ xfsaild_push(
struct xfs_ail_cursor cur;
struct xfs_log_item *lip;
xfs_lsn_t lsn;
xfs_lsn_t target;
xfs_lsn_t target = NULLCOMMITLSN;
long tout;
int stuck = 0;
int flushing = 0;
@ -472,6 +472,8 @@ xfsaild_push(
XFS_STATS_INC(mp, xs_push_ail);
ASSERT(target != NULLCOMMITLSN);
lsn = lip->li_lsn;
while ((XFS_LSN_CMP(lip->li_lsn, target) <= 0)) {
int lock_result;

View File

@ -210,7 +210,7 @@ __xfs_xattr_put_listent(
return;
}
offset = context->buffer + context->count;
strncpy(offset, prefix, prefix_len);
memcpy(offset, prefix, prefix_len);
offset += prefix_len;
strncpy(offset, (char *)name, namelen); /* real name */
offset += namelen;