diff --git a/0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch b/0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch new file mode 100644 index 0000000..58bb03e --- /dev/null +++ b/0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch @@ -0,0 +1,65 @@ +From 7a8d9a29358fbe9eb5dcc70e63c417c4f3cd5068 Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Mon, 3 Feb 2025 15:41:22 -0800 +Subject: [PATCH 1/3] fs/xfs: Add new superblock features added in Linux + 6.12/6.13 + +The Linux port of XFS added a few new features in 2024. The existing +GRUB driver doesn't attempt to read or write any of the new metadata, +so, all three can be added to the incompat allowlist. + +On the occasion align XFS_SB_FEAT_INCOMPAT_NREXT64 value. + +Signed-off-by: Darrick J. Wong +Reviewed-by: Daniel Kiper +--- + grub-core/fs/xfs.c | 19 +++++++++++++++++-- + 1 file changed, 17 insertions(+), 2 deletions(-) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index c17e54e447..e3a69fe498 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -88,7 +88,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); + #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ + #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ + #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ +-#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ ++#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ ++#define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */ ++#define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */ ++#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */ + + /* + * Directory entries with ftype are explicitly handled by GRUB code. +@@ -98,6 +101,15 @@ GRUB_MOD_LICENSE ("GPLv3+"); + * + * We do not currently verify metadata UUID, so it is safe to read filesystems + * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature. ++ * ++ * We do not currently replay the log, so it is safe to read filesystems ++ * with the XFS_SB_FEAT_INCOMPAT_EXCHRANGE feature. ++ * ++ * We do not currently read directory parent pointers, so it is safe to read ++ * filesystems with the XFS_SB_FEAT_INCOMPAT_PARENT feature. ++ * ++ * We do not currently look at realtime or quota metadata, so it is safe to ++ * read filesystems with the XFS_SB_FEAT_INCOMPAT_METADIR feature. + */ + #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ +@@ -105,7 +117,10 @@ GRUB_MOD_LICENSE ("GPLv3+"); + XFS_SB_FEAT_INCOMPAT_META_UUID | \ + XFS_SB_FEAT_INCOMPAT_BIGTIME | \ + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \ +- XFS_SB_FEAT_INCOMPAT_NREXT64) ++ XFS_SB_FEAT_INCOMPAT_NREXT64 | \ ++ XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \ ++ XFS_SB_FEAT_INCOMPAT_PARENT | \ ++ XFS_SB_FEAT_INCOMPAT_METADIR) + + struct grub_xfs_sblock + { +-- +2.48.1 + diff --git a/0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch b/0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch new file mode 100644 index 0000000..31fafd6 --- /dev/null +++ b/0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch @@ -0,0 +1,52 @@ +From 3a69e9126d532214d940c1386f2933a124611a6c Mon Sep 17 00:00:00 2001 +From: Egor Ignatov +Date: Thu, 23 Jan 2025 20:44:14 +0300 +Subject: [PATCH 2/3] fs/xfs: Fix grub_xfs_iterate_dir() return value in case + of failure + +Commit ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS +filesystem) introduced multiple boundary checks in grub_xfs_iterate_dir() +but handled the error incorrectly returning error code instead of 0. +Fix it. Also change the error message so that it doesn't match the +message in grub_xfs_read_inode(). + +Fixes: ef7850c757 (fs/xfs: Fix issues found while fuzzing the XFS filesystem) + +Signed-off-by: Egor Ignatov +Reviewed-by: Daniel Kiper +--- + grub-core/fs/xfs.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index e3a69fe498..30e3e7f6d9 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -859,7 +859,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + grub_uint8_t c; + + if ((inopos + (smallino ? 4 : 8)) > (grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)) +- return grub_error (GRUB_ERR_BAD_FS, "not a correct XFS inode"); ++ { ++ grub_error (GRUB_ERR_BAD_FS, "invalid XFS inode"); ++ return 0; ++ } ++ + + /* inopos might be unaligned. */ + if (smallino) +@@ -968,7 +972,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + + filename = (char *)(direntry + 1); + if (filename + direntry->len + 1 > (char *) end) +- return grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); ++ { ++ grub_error (GRUB_ERR_BAD_FS, "invalid XFS directory entry"); ++ return 0; ++ } + + /* The byte after the filename is for the filetype, padding, or + tag, which is not used by GRUB. So it can be overwritten. */ +-- +2.48.1 + diff --git a/0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch b/0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch new file mode 100644 index 0000000..cd03554 --- /dev/null +++ b/0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch @@ -0,0 +1,49 @@ +From 846b1d8bebd316a18fae9fb90efb3e8451ec70cc Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Wed, 4 Dec 2024 07:50:28 -0600 +Subject: [PATCH 3/3] fs/xfs: fix large extent counters incompat feature + support + +When large extent counter / NREXT64 support was added to grub, it missed +a couple of direct reads of nextents which need to be changed to the new +NREXT64-aware helper as well. Without this, we'll have mis-reads of some +directories with this feature enabled. + +(The large extent counter fix likely raced on merge with +07318ee7e ("fs/xfs: Fix XFS directory extent parsing") which added the new +direct nextents reads just prior, causing this issue.) + +Fixes: aa7c1322671e ("fs/xfs: Add large extent counters incompat feature support") +Signed-off-by: Eric Sandeen +Reviewed-by: Anthony Iliopoulos +Reviewed-by: Jon DeVree +Link: https://lore.kernel.org/r/985816b8-35e6-4083-994f-ec9138bd35d2@redhat.com +--- + grub-core/fs/xfs.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index 30e3e7f6d9..3ba232436e 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -937,7 +937,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + * Leaf and tail information are only in the data block if the number + * of extents is 1. + */ +- if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1)) ++ if (grub_xfs_get_inode_nextents(&dir->inode) == 1) + { + end = (char *) tail; + +@@ -992,7 +992,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, + * The expected number of directory entries is only tracked for the + * single extent case. + */ +- if (dir->inode.nextents == grub_cpu_to_be32_compile_time (1)) ++ if (grub_xfs_get_inode_nextents(&dir->inode) == 1) + { + /* Check if last direntry in this block is reached. */ + entries--; +-- +2.48.1 + diff --git a/grub2.changes b/grub2.changes index 3f4594e..a69360e 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Mar 3 04:30:51 UTC 2025 - Michael Chang + +- Cherry-pick upstream XFS fixes + * 0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch + * 0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch +- Fix "attempt to read of write outside of partition" error message (bsc#1237844) + * 0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch + ------------------------------------------------------------------- Tue Feb 25 02:46:36 UTC 2025 - Michael Chang diff --git a/grub2.spec b/grub2.spec index 4fd3504..7ab03aa 100644 --- a/grub2.spec +++ b/grub2.spec @@ -438,6 +438,9 @@ Patch256: 0018-fs-bfs-Disable-under-lockdown.patch Patch257: 0019-fs-Disable-many-filesystems-under-lockdown.patch Patch258: 0020-fs-Prevent-overflows-when-allocating-memory-for-arra.patch Patch259: 0001-bls-Accept-.conf-suffix-in-setting-default-entry.patch +Patch260: 0001-fs-xfs-Add-new-superblock-features-added-in-Linux-6..patch +Patch261: 0002-fs-xfs-Fix-grub_xfs_iterate_dir-return-value-in-case.patch +Patch262: 0003-fs-xfs-fix-large-extent-counters-incompat-feature-su.patch %if 0%{?suse_version} < 1600 Requires: gettext-runtime