gfs2-utils/0002-fsck.gfs2-Fix-max-xattr-record-length-check.patch

32 lines
1.1 KiB
Diff

From f50a6c8aa6175c5763fb076da0efd07f36adb698 Mon Sep 17 00:00:00 2001
From: Andrew Price <anprice@redhat.com>
Date: Thu, 11 May 2023 18:28:04 +0100
Subject: [PATCH] fsck.gfs2: Fix max xattr record length check
xattr blocks have a meta header so the max size to check ea_rec_len
against is one meta header less than the block size. Fixes detection of
bad ea_rec_len values that result in offsets up to 24 bytes past the end
of the block.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
gfs2/fsck/pass1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 206929fcdbd5..ebd66e2c9bc5 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -881,7 +881,7 @@ static int p1_check_eattr_entries(struct fsck_cx *cx, struct lgfs2_inode *ip,
char ea_name[256];
uint32_t offset = (uint32_t)(((unsigned long)ea_hdr) -
((unsigned long)leaf_bh->b_data));
- uint32_t max_size = sdp->sd_bsize;
+ uint32_t max_size = sdp->sd_bsize - sizeof(struct gfs2_meta_header);
uint32_t avail_size;
int max_ptrs;
--
2.35.3