From: B Horn Date: Sun, 12 May 2024 05:03:58 +0000 (+0100) Subject: fs/xfs: Ensuring failing to mount sets a grub_errno X-Git-Tag: archive/raspbian/2.12-8+rpi1^2~56 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5171d30be655b5f18294edc6009431ede36911c4;p=grub2.git fs/xfs: Ensuring failing to mount sets a grub_errno It was previously possible for grub_xfs_mount() to return NULL without setting grub_errno if the XFS version was invalid. This resulted in it being possible for grub_dl_unref() to be called twice allowing the XFS module to be unloaded while there were still references to it. Fixing this problem in general by ensuring a grub_errno is set if the fail label is reached. Reported-by: B Horn Signed-off-by: B Horn Reviewed-by: Daniel Kiper Gbp-Pq: Topic cve-2025-jan Gbp-Pq: Name fs-xfs-Ensuring-failing-to-mount-sets-a-grub_errno.patch --- diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index d2d5335..56738a1 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -327,6 +327,8 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data) } return 1; } + + grub_error (GRUB_ERR_BAD_FS, "unsupported XFS filesystem version"); return 0; } @@ -1058,7 +1060,7 @@ grub_xfs_mount (grub_disk_t disk) return data; fail: - if (grub_errno == GRUB_ERR_OUT_OF_RANGE) + if (grub_errno == GRUB_ERR_OUT_OF_RANGE || grub_errno == GRUB_ERR_NONE) grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem"); grub_free (data);