65c99394ff
Grub 2.06 is affected by a number of CVEs, which have been fixed in the master branch of Grub, but are not yet part of any release (there is a 2.12-rc1 release, but nothing else between 2.06 and 2.12-rc1). So this patch backports the relevant fixes for CVE-2022-28736, CVE-2022-28735, CVE-2021-3695, CVE-2021-3696, CVE-2021-3697, CVE-2022-28733, CVE-2022-28734, CVE-2022-2601 and CVE-2022-3775. It should be noted that CVE-2021-3695, CVE-2021-3696, CVE-2021-3697 are not reported as affecting Grub by our CVE matching logic because the NVD database uses an incorrect CPE ID in those CVEs: it uses "grub" as the product instead of "grub2" like all other CVEs for grub. This issue has been reported to the NVD maintainers. This requires backporting a lot of patches, but jumping from 2.06 to 2.12-rc1 implies getting 592 commits, which is quite a lot. All Grub test cases are working fine: https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500585 https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500679 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> [Arnout: fix check-package warning in patch 0002] Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
57 lines
1.8 KiB
Diff
57 lines
1.8 KiB
Diff
From cadde7e36b8797060ac8cdf7cca7d8e1e09697e6 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Axtens <dja@axtens.net>
|
|
Date: Mon, 20 Dec 2021 19:41:21 +1100
|
|
Subject: [PATCH] net/ip: Do IP fragment maths safely
|
|
|
|
We can receive packets with invalid IP fragmentation information. This
|
|
can lead to rsm->total_len underflowing and becoming very large.
|
|
|
|
Then, in grub_netbuff_alloc(), we add to this very large number, which can
|
|
cause it to overflow and wrap back around to a small positive number.
|
|
The allocation then succeeds, but the resulting buffer is too small and
|
|
subsequent operations can write past the end of the buffer.
|
|
|
|
Catch the underflow here.
|
|
|
|
Fixes: CVE-2022-28733
|
|
|
|
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
Upstream: 3e4817538de828319ba6d59ced2fbb9b5ca13287
|
|
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
|
---
|
|
grub-core/net/ip.c | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
|
|
index ea5edf8f1..74e4e8b06 100644
|
|
--- a/grub-core/net/ip.c
|
|
+++ b/grub-core/net/ip.c
|
|
@@ -25,6 +25,7 @@
|
|
#include <grub/net/netbuff.h>
|
|
#include <grub/mm.h>
|
|
#include <grub/priority_queue.h>
|
|
+#include <grub/safemath.h>
|
|
#include <grub/time.h>
|
|
|
|
struct iphdr {
|
|
@@ -512,7 +513,14 @@ grub_net_recv_ip4_packets (struct grub_net_buff *nb,
|
|
{
|
|
rsm->total_len = (8 * (grub_be_to_cpu16 (iph->frags) & OFFSET_MASK)
|
|
+ (nb->tail - nb->data));
|
|
- rsm->total_len -= ((iph->verhdrlen & 0xf) * sizeof (grub_uint32_t));
|
|
+
|
|
+ if (grub_sub (rsm->total_len, (iph->verhdrlen & 0xf) * sizeof (grub_uint32_t),
|
|
+ &rsm->total_len))
|
|
+ {
|
|
+ grub_dprintf ("net", "IP reassembly size underflow\n");
|
|
+ return GRUB_ERR_NONE;
|
|
+ }
|
|
+
|
|
rsm->asm_netbuff = grub_netbuff_alloc (rsm->total_len);
|
|
if (!rsm->asm_netbuff)
|
|
{
|
|
--
|
|
2.41.0
|
|
|