mirror of
https://git.yoctoproject.org/poky
synced 2026-04-23 00:32:12 +02:00
grub: fix a memory leak
Add a fix for a memory leak in grub'd disk/ldm. It is a part of a security series [1]. [1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html (From OE-Core rev: eb899a83bab5ab12143bd75a96427fa7615f2a6e) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
b854e27c58
commit
40d7b77030
@@ -0,0 +1,50 @@
|
||||
From 3e1d2f1959acbe5152cdd5818d495f6455d1a158 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 10:00:51 +0000
|
||||
Subject: [PATCH] disk/ldm: Fix memory leak on uninserted lv references
|
||||
|
||||
The problem here is that the memory allocated to the variable lv is not
|
||||
yet inserted into the list that is being processed at the label fail2.
|
||||
|
||||
As we can already see at line 342, which correctly frees lv before going
|
||||
to fail2, we should also be doing that at these earlier jumps to fail2.
|
||||
|
||||
Fixes: CID 73824
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=156c281a1625dc73fd350530630c6f2d5673d4f6]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/ldm.c | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
|
||||
index 54713f4..e82e989 100644
|
||||
--- a/grub-core/disk/ldm.c
|
||||
+++ b/grub-core/disk/ldm.c
|
||||
@@ -321,7 +321,10 @@ make_vg (grub_disk_t disk,
|
||||
lv->visible = 1;
|
||||
lv->segments = grub_zalloc (sizeof (*lv->segments));
|
||||
if (!lv->segments)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (lv);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
lv->segments->start_extent = 0;
|
||||
lv->segments->type = GRUB_DISKFILTER_MIRROR;
|
||||
lv->segments->node_count = 0;
|
||||
@@ -329,7 +332,10 @@ make_vg (grub_disk_t disk,
|
||||
lv->segments->nodes = grub_calloc (lv->segments->node_alloc,
|
||||
sizeof (*lv->segments->nodes));
|
||||
if (!lv->segments->nodes)
|
||||
- goto fail2;
|
||||
+ {
|
||||
+ grub_free (lv);
|
||||
+ goto fail2;
|
||||
+ }
|
||||
ptr = vblk[i].dynamic;
|
||||
if (ptr + *ptr + 1 >= vblk[i].dynamic
|
||||
+ sizeof (vblk[i].dynamic))
|
||||
@@ -64,6 +64,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0015-kern-partition-Check-for-NULL-before-dereferencing-i.patch \
|
||||
file://0016-disk-ldm-Make-sure-comp-data-is-freed-before-exiting.patch \
|
||||
file://0017-disk-ldm-If-failed-then-free-vg-variable-too.patch \
|
||||
file://0018-disk-ldm-Fix-memory-leak-on-uninserted-lv-references.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
Reference in New Issue
Block a user