Skip to contentSkip to conversation

xfs stable candidate patches for 5.4.y

PATCH Superseded Chandan Babu R 2 participants 5 messages Sep 23, 2022 – Sep 24, 2022 XFS filesystem

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover xfs stable candidate patches for 5.4.y

Hi Darrick,

Two of the commits backported from v5.5
(https://lore.kernel.org/linux-xfs/[email protected]/T/#t)
introduced regressions of their own. Hence this patchset includes two backported commits to fix those regressions.

The first patch i.e. "xfs: fix an ABBA deadlock in xfs_rename" fixes a regression that was introduced by "xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()".

The second patch i.e. "xfs: fix use-after-free when aborting corrupt attr inactivation" fixes a regression that was introduced by "xfs: fix use-after-free when aborting corrupt attr inactivation".

This patchset has been tested by executing fstests (via kdevops) using the following XFS configurations,
1. No CRC (with 512 and 4k block size).
2. Reflink/Rmapbt (1k and 4k block size).
3. Reflink without Rmapbt.
4. External log device.

Darrick J. Wong (2):
xfs: fix an ABBA deadlock in xfs_rename
xfs: fix use-after-free when aborting corrupt attr inactivation

 fs/xfs/libxfs/xfs_dir2.h    |  2 --
 fs/xfs/libxfs/xfs_dir2_sf.c |  2 +-
 fs/xfs/xfs_attr_inactive.c  |  2 +-
 fs/xfs/xfs_inode.c          | 42 ++++++++++++++++++++++---------------
 4 files changed, 27 insertions(+), 21 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 xfs: fix an ABBA deadlock in xfs_rename

From: "Darrick J. Wong" <[email protected]>

commit 6da1b4b1ab36d80a3994fd4811c8381de10af604 upstream.

When overlayfs is running on top of xfs and the user unlinks a file in the overlay, overlayfs will create a whiteout inode and ask xfs to "rename" the whiteout file atop the one being unlinked. If the file being unlinked loses its one nlink, we then have to put the inode on the unlinked list.

This requires us to grab the AGI buffer of the whiteout inode to take it off the unlinked list (which is where whiteouts are created) and to grab the AGI buffer of the file being deleted. If the whiteout was created in a higher numbered AG than the file being deleted, we'll lock the AGIs in the wrong order and deadlock.

Therefore, grab all the AGI locks we think we'll need ahead of time, and in order of increasing AG number per the locking rules.

Fixes 93597ae8dac0 ("xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()")
---
 fs/xfs/libxfs/xfs_dir2.h    |  2 --
 fs/xfs/libxfs/xfs_dir2_sf.c |  2 +-
 fs/xfs/xfs_inode.c          | 42 ++++++++++++++++++++++---------------
 3 files changed, 26 insertions(+), 20 deletions(-)
fs/xfs/libxfs/xfs_dir2.h +0 -2
index 01b1722333a9..f54244779492 100644
@@ -124,8 +124,6 @@ extern int xfs_dir_lookup(struct xfs_trans *tp, struct xfs_inode *dp,
 extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t ino,
 				xfs_extlen_t tot);
-extern bool xfs_dir2_sf_replace_needblock(struct xfs_inode *dp,
-				xfs_ino_t inum);
 extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
 				struct xfs_name *name, xfs_ino_t inum,
 				xfs_extlen_t tot);
fs/xfs/libxfs/xfs_dir2_sf.c +1 -1
index 90eff6c2de7e..f980c3f3d2f6 100644
@@ -947,7 +947,7 @@ xfs_dir2_sf_removename(
 /*
  * Check whether the sf dir replace operation need more blocks.
  */
-bool
+static bool
 xfs_dir2_sf_replace_needblock(
 	struct xfs_inode	*dp,
 	xfs_ino_t		inum)
fs/xfs/xfs_inode.c +25 -17

60 lines not on this page · raw message

Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/2 xfs: fix use-after-free when aborting corrupt attr inactivation

In reply to Chandan Babu R

From: "Darrick J. Wong" <[email protected]>

commit 496b9bcd62b0b3a160be61e3265a086f97adcbd3 upstream.

Log the corrupt buffer before we release the buffer.

Fixes a5155b870d687 ("xfs: always log corruption errors")
---
 fs/xfs/xfs_attr_inactive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_attr_inactive.c +1 -1
index 43ae392992e7..766b1386402a 100644
@@ -209,8 +209,8 @@ xfs_attr3_node_inactive(
 	 * Since this code is recursive (gasp!) we must protect ourselves.
 	 */
 	if (level > XFS_DA_NODE_MAXDEPTH) {
-		xfs_trans_brelse(*trans, bp);	/* no locks for later trans */
 		xfs_buf_corruption_error(bp);
+		xfs_trans_brelse(*trans, bp);	/* no locks for later trans */
 		return -EFSCORRUPTED;
 	}
 
Signature · 1 line
2.35.1
Acked-by on the v1 series
#3 lore raw
In reply to Chandan Babu R
Quoted 7 lines · Chandan Babu R

Hi Darrick,

Two of the commits backported from v5.5
(https://lore.kernel.org/linux-xfs/[email protected]/T/#t)
introduced regressions of their own. Hence this patchset includes two backported commits to fix those regressions.

Quoted 7 lines

The first patch i.e. "xfs: fix an ABBA deadlock in xfs_rename" fixes a regression that was introduced by "xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()".

The second patch i.e. "xfs: fix use-after-free when aborting corrupt attr inactivation" fixes a regression that was introduced by "xfs: fix use-after-free when aborting corrupt attr inactivation".

Looks good to me, thanks for fishing out these two extra fixes.

--D

Quoted 21 lines

This patchset has been tested by executing fstests (via kdevops) using the following XFS configurations,
1. No CRC (with 512 and 4k block size).
2. Reflink/Rmapbt (1k and 4k block size).
3. Reflink without Rmapbt.
4. External log device.

Darrick J. Wong (2):
xfs: fix an ABBA deadlock in xfs_rename
xfs: fix use-after-free when aborting corrupt attr inactivation

 fs/xfs/libxfs/xfs_dir2.h    |  2 --
 fs/xfs/libxfs/xfs_dir2_sf.c |  2 +-
 fs/xfs/xfs_attr_inactive.c  |  2 +-
 fs/xfs/xfs_inode.c          | 42 ++++++++++++++++++++++---------------
 4 files changed, 27 insertions(+), 21 deletions(-)
Signature · 1 line
2.35.1
#4 lore raw
Quoted 12 lines · Darrick J. Wong
Quoted 11 lines · Chandan Babu R

Hi Darrick,

Two of the commits backported from v5.5
(https://lore.kernel.org/linux-xfs/[email protected]/T/#t)
introduced regressions of their own. Hence this patchset includes two backported commits to fix those regressions.

The first patch i.e. "xfs: fix an ABBA deadlock in xfs_rename" fixes a regression that was introduced by "xfs: Fix deadlock between AGI and AGF when target_ip exists in xfs_rename()".

Quoted 7 lines
Quoted 3 lines

The second patch i.e. "xfs: fix use-after-free when aborting corrupt attr inactivation" fixes a regression that was introduced by "xfs: fix use-after-free when aborting corrupt attr inactivation".

Looks good to me, thanks for fishing out these two extra fixes.

Thanks for ack-ing the patchset. Btw, these two fixes were identified by Greg.

Signature · 1 line
chandan