0003-fs-ufs-Fix-a-heap-OOB-write.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From ab0f52dadcda56782b3e82be0b15fa6eb0e9cee1 Mon Sep 17 00:00:00 2001
  2. From: B Horn <b@horn.uk>
  3. Date: Sun, 12 May 2024 02:03:33 +0100
  4. Subject: [PATCH] fs/ufs: Fix a heap OOB write
  5. grub_strcpy() was used to copy a symlink name from the filesystem
  6. image to a heap allocated buffer. This led to a OOB write to adjacent
  7. heap allocations. Fix by using grub_strlcpy().
  8. Fixes: CVE-2024-45781
  9. Reported-by: B Horn <b@horn.uk>
  10. Signed-off-by: B Horn <b@horn.uk>
  11. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  12. Upstream: c1a291b01f4f1dcd6a22b61f1c81a45a966d16ba
  13. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  14. ---
  15. grub-core/fs/ufs.c | 2 +-
  16. 1 file changed, 1 insertion(+), 1 deletion(-)
  17. diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c
  18. index a354c92d9..01235101b 100644
  19. --- a/grub-core/fs/ufs.c
  20. +++ b/grub-core/fs/ufs.c
  21. @@ -463,7 +463,7 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino)
  22. /* Check against zero is paylindromic, no need to swap. */
  23. if (data->inode.nblocks == 0
  24. && INODE_SIZE (data) <= sizeof (data->inode.symlink))
  25. - grub_strcpy (symlink, (char *) data->inode.symlink);
  26. + grub_strlcpy (symlink, (char *) data->inode.symlink, sz);
  27. else
  28. {
  29. if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0)
  30. --
  31. 2.50.1