0071-fs-xfs-Propagate-incorrect-inode-error-from-grub_xfs.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. From 6becb747027c4f9cdb10f23d6eb24fcc238e8b68 Mon Sep 17 00:00:00 2001
  2. From: Egor Ignatov <egori@altlinux.org>
  3. Date: Thu, 23 Jan 2025 20:44:15 +0300
  4. Subject: [PATCH] fs/xfs: Propagate incorrect inode error from
  5. grub_xfs_read_inode
  6. The incorrect inode error from grub_xfs_read_inode did not propagate because
  7. grub_print_error() resetted grub_errno, and grub_xfs_iterate_dir() did not
  8. handle it at all.
  9. Signed-off-by: Egor Ignatov <egori@altlinux.org>
  10. Upstream: https://www.mail-archive.com/grub-devel@gnu.org/msg40098.html
  11. [Not accepted upstream, but in Debian]
  12. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  13. ---
  14. grub-core/fs/xfs.c | 14 ++++++++++++--
  15. 1 file changed, 12 insertions(+), 2 deletions(-)
  16. diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c
  17. index e0daeb45f..28a342996 100644
  18. --- a/grub-core/fs/xfs.c
  19. +++ b/grub-core/fs/xfs.c
  20. @@ -806,7 +806,6 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
  21. fdiro = grub_malloc (sz);
  22. if (!fdiro)
  23. {
  24. - grub_print_error ();
  25. return 0;
  26. }
  27. @@ -818,7 +817,6 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename,
  28. err = grub_xfs_read_inode (ctx->diro->data, ino, &fdiro->inode);
  29. if (err)
  30. {
  31. - grub_print_error ();
  32. grub_free (fdiro);
  33. return 0;
  34. }
  35. @@ -858,9 +856,13 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
  36. /* Synthesize the direntries for `.' and `..'. */
  37. if (iterate_dir_call_hook (diro->ino, ".", &ctx))
  38. return 1;
  39. + else if (grub_errno)
  40. + return 0;
  41. if (iterate_dir_call_hook (parent, "..", &ctx))
  42. return 1;
  43. + else if (grub_errno)
  44. + return 0;
  45. for (i = 0; i < head->count &&
  46. (grub_uint8_t *) de < ((grub_uint8_t *) dir + grub_xfs_fshelp_size (dir->data)); i++)
  47. @@ -901,6 +903,9 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
  48. }
  49. de->name[de->len] = c;
  50. + if (grub_errno)
  51. + return 0;
  52. +
  53. de = grub_xfs_inline_next_de(dir->data, head, de);
  54. }
  55. break;
  56. @@ -998,6 +1003,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
  57. grub_free (dirblock);
  58. return 1;
  59. }
  60. + else if (grub_errno)
  61. + {
  62. + grub_free (dirblock);
  63. + return 0;
  64. + }
  65. /*
  66. * The expected number of directory entries is only tracked for the
  67. --
  68. 2.50.1