0020-fs-ext2-Ignore-the-large_dir-incompat-feature.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 2e9fa73a040462b81bfbfe56c0bc7ad2d30b446b Mon Sep 17 00:00:00 2001
  2. From: Theodore Ts'o <tytso@mit.edu>
  3. Date: Tue, 30 Aug 2022 22:41:59 -0400
  4. Subject: [PATCH] fs/ext2: Ignore the large_dir incompat feature
  5. Recently, ext4 added the large_dir feature, which adds support for
  6. a 3 level htree directory support.
  7. The GRUB supports existing file systems with htree directories by
  8. ignoring their existence, and since the index nodes for the hash tree
  9. look like deleted directory entries (by design), the GRUB can simply do
  10. a brute force O(n) linear search of directories. The same is true for
  11. 3 level deep htrees indicated by large_dir feature flag.
  12. Hence, it is safe for the GRUB to ignore the large_dir incompat feature.
  13. Fixes: https://savannah.gnu.org/bugs/?61606
  14. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  15. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  16. Upstream: 2e9fa73a040462b81bfbfe56c0bc7ad2d30b446b
  17. Signed-off-by: Jens Maus <mail@jens-maus.de>
  18. ---
  19. grub-core/fs/ext2.c | 10 +++++++++-
  20. 1 file changed, 9 insertions(+), 1 deletion(-)
  21. diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c
  22. index 0989e26e1..e1cc5e62a 100644
  23. --- a/grub-core/fs/ext2.c
  24. +++ b/grub-core/fs/ext2.c
  25. @@ -104,6 +104,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
  26. #define EXT4_FEATURE_INCOMPAT_MMP 0x0100
  27. #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
  28. #define EXT4_FEATURE_INCOMPAT_CSUM_SEED 0x2000
  29. +#define EXT4_FEATURE_INCOMPAT_LARGEDIR 0x4000 /* >2GB or 3 level htree */
  30. #define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
  31. /* The set of back-incompatible features this driver DOES support. Add (OR)
  32. @@ -129,10 +130,17 @@ GRUB_MOD_LICENSE ("GPLv3+");
  33. * checksummed filesystem. Safe to ignore for now since the
  34. * driver doesn't support checksum verification. However, it
  35. * has to be removed from this list if the support is added later.
  36. + * large_dir: Not back-incompatible given that the GRUB ext2 driver does
  37. + * not implement EXT2_FEATURE_COMPAT_DIR_INDEX. If the GRUB
  38. + * eventually supports the htree feature (aka dir_index)
  39. + * it should support 3 level htrees and then move
  40. + * EXT4_FEATURE_INCOMPAT_LARGEDIR to
  41. + * EXT2_DRIVER_SUPPORTED_INCOMPAT.
  42. */
  43. #define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
  44. | EXT4_FEATURE_INCOMPAT_MMP \
  45. - | EXT4_FEATURE_INCOMPAT_CSUM_SEED)
  46. + | EXT4_FEATURE_INCOMPAT_CSUM_SEED \
  47. + | EXT4_FEATURE_INCOMPAT_LARGEDIR)
  48. #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U
  49. --
  50. 2.34.1