Re: [syzbot] [xfs?] KASAN: slab-out-of-bounds Read in xlog_cksum
From: Edward Adam Davis
Date: Tue Mar 04 2025 - 20:53:44 EST
#syz test
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index f8851ff835de..160eb6738c8c 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1581,8 +1581,12 @@ xlog_cksum(
union xlog_in_core2 *xhdr = (union xlog_in_core2 *)rhead;
int i;
int xheads;
+ int tail_xhead_len;
xheads = DIV_ROUND_UP(size, XLOG_HEADER_CYCLE_SIZE);
+ tail_xhead_len = size % XLOG_HEADER_CYCLE_SIZE;
+ if (sizeof(struct xlog_rec_ext_header) > tail_xhead_len)
+ xheads -= 1;
for (i = 1; i < xheads; i++) {
crc = crc32c(crc, &xhdr[i].hic_xheader,