nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0439-fs-hfsplus-Don-t-fetch-a-key-beyond-the-end-of-the-n.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Daniel Axtens <dja@axtens.net>
468bd4
Date: Fri, 22 Jan 2021 18:13:56 +1100
468bd4
Subject: [PATCH] fs/hfsplus: Don't fetch a key beyond the end of the node
468bd4
468bd4
Otherwise you get a wild pointer, leading to a bunch of invalid reads.
468bd4
Check it falls inside the given node.
468bd4
468bd4
Signed-off-by: Daniel Axtens <dja@axtens.net>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/fs/hfsplus.c | 4 ++++
468bd4
 1 file changed, 4 insertions(+)
468bd4
468bd4
diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
09e3cc
index 03a33ea24..423f4b956 100644
468bd4
--- a/grub-core/fs/hfsplus.c
468bd4
+++ b/grub-core/fs/hfsplus.c
468bd4
@@ -635,6 +635,10 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
468bd4
 	      pointer = ((char *) currkey
468bd4
 			 + grub_be_to_cpu16 (currkey->keylen)
468bd4
 			 + 2);
468bd4
+
468bd4
+	      if ((char *) pointer > node + btree->nodesize - 2)
468bd4
+		return grub_error (GRUB_ERR_BAD_FS, "HFS+ key beyond end of node");
468bd4
+
468bd4
 	      currnode = grub_be_to_cpu32 (grub_get_unaligned32 (pointer));
468bd4
 	      match = 1;
468bd4
 	    }