Skip to content

xfs: fix NULL deref in log recovery reorder

Weiming Shi linux-xfs stable 2 versions – Applied

Status from this message: Applied to for-next, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 of 3 patches 1 replyApplied
  2. v23 patches 8 repliesSuperseded

Changes in v3 from the cover letter

- patches 1 and 2: picked up the Reviewed-by tags, plus the s/encountered/encounter/ fix in patch 2 that Darrick noted
- patch 3: reworked the changelog per Darrick and Christoph. The empty item comes from the len == sizeof(xfs_trans_header) path; the check can only run at commit time because a split header may still get regions from later ops; and the runtime commit path never emits this, so it is only reachable on a crafted log. It came from an AI-assisted code audit of the parser. Added Cc: stable # v4.3.

2 of 3 patches are in this archive. The cover letter announces 3.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/3xfs: drop ASSERT(0) on unrecognized log item typefs/xfs/xfs_log_recover.c+0 -10 replies
2/3xfs: splice unsorted log items back to the transaction after the loopfs/xfs/xfs_log_recover.c+9 -70 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDarrick J. WongChristoph Hellwig
SeriesR-b R-b
1/3R-b R-b
2/3R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] xfs: fix NULL deref in log recovery reorder

A crafted on-disk log can commit a transaction whose only item is a bare transaction header (ri_cnt == 0, ri_buf == NULL). xlog_recover_reorder_trans() then runs ITEM_TYPE() on it and dereferences the NULL ri_buf, faulting the kernel at mount time.

v3:
- patches 1 and 2: picked up the Reviewed-by tags, plus the s/encountered/encounter/ fix in patch 2 that Darrick noted
- patch 3: reworked the changelog per Darrick and Christoph. The empty item comes from the len == sizeof(xfs_trans_header) path; the check can only run at commit time because a split header may still get regions from later ops; and the runtime commit path never emits this, so it is only reachable on a crafted log. It came from an AI-assisted code audit of the parser. Added Cc: stable # v4.3.

Tested on xfs-7.2-fixes with KASAN: the unpatched kernel oopses in xlog_recover_reorder_trans; the patched kernel fails the mount with -EFSCORRUPTED and no splat.

Weiming Shi (3):
xfs: drop ASSERT(0) on unrecognized log item type
xfs: splice unsorted log items back to the transaction after the loop
xfs: fail recovery on a committed log item with no regions

 fs/xfs/xfs_log_recover.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0