Skip to content

Commit 1155b12

Browse files
author
Chandan Babu R
committed
Merge tag 'fix-scrub-6.6_2023-09-12' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.6-fixesA
xfs: fix out of bounds memory access in scrub This is a quick fix for a few internal syzbot reports concerning an invalid memory access in the scrub code. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org> * tag 'fix-scrub-6.6_2023-09-12' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: only call xchk_stats_merge after validating scrub inputs
2 parents 6ebb650 + e031928 commit 1155b12

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

fs/xfs/scrub/scrub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,15 +588,15 @@ xfs_scrub_metadata(
588588
out_teardown:
589589
error = xchk_teardown(sc, error);
590590
out_sc:
591+
if (error != -ENOENT)
592+
xchk_stats_merge(mp, sm, &run);
591593
kfree(sc);
592594
out:
593595
trace_xchk_done(XFS_I(file_inode(file)), sm, error);
594596
if (error == -EFSCORRUPTED || error == -EFSBADCRC) {
595597
sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
596598
error = 0;
597599
}
598-
if (error != -ENOENT)
599-
xchk_stats_merge(mp, sm, &run);
600600
return error;
601601
need_drain:
602602
error = xchk_teardown(sc, 0);

fs/xfs/scrub/stats.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ xchk_stats_merge_one(
185185
{
186186
struct xchk_scrub_stats *css;
187187

188-
ASSERT(sm->sm_type < XFS_SCRUB_TYPE_NR);
188+
if (sm->sm_type >= XFS_SCRUB_TYPE_NR) {
189+
ASSERT(sm->sm_type < XFS_SCRUB_TYPE_NR);
190+
return;
191+
}
189192

190193
css = &cs->cs_stats[sm->sm_type];
191194
spin_lock(&css->css_lock);

0 commit comments

Comments
 (0)