From patchwork Fri Feb 25 14:25:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Sakoman X-Patchwork-Id: 4261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 738E7C433EF for ; Fri, 25 Feb 2022 14:27:05 +0000 (UTC) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mx.groups.io with SMTP id smtpd.web11.6911.1645799225040828622 for ; Fri, 25 Feb 2022 06:27:05 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@sakoman-com.20210112.gappssmtp.com header.s=20210112 header.b=tg1rRj6w; spf=softfail (domain: sakoman.com, ip: 209.85.214.170, mailfrom: steve@sakoman.com) Received: by mail-pl1-f170.google.com with SMTP id e13so4960654plh.3 for ; Fri, 25 Feb 2022 06:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakoman-com.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=41FsmRH49fMUtepX4+4hyhYspY0Fk0dmP/kuBSTAbhU=; b=tg1rRj6w/w94kHk6DBJ5bY/6MCLSI2Zelats8vui7yAcv3F2XMMvxww4RXrddQBDch 3xW/uRRBjAaT1geiSYNFUtEcJESoH6VPTCDnfPF/bGD8vQQsWWurk8HG0ZINIb9kVoEW Er6fumvQSxF1Vvb0i+VqitV1lhNO2I6SF38fYQGQ74k8tJ6z3QjYifHTtEhfUnsSNisn 1GBE2qqJew/Y+UNC7q1y7iiTEVDSny8EdUI6p8ODKl4CysPqGxgRds21YSigwj3dJ2IH b34I7wJyEXg1XcJ0dKBLkldf5cZ2l2iFUta5BQtyiSdk73uPD5oB8Y6hTkn9MtHhxO8A z/7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=41FsmRH49fMUtepX4+4hyhYspY0Fk0dmP/kuBSTAbhU=; b=FNDCVzhVMKyShLmpwxTvuxZKybTe13dZiE1/J33Ha52jTsfU/8I3+iN67CV2I7LRu1 PcsdUG2WcwFwSC6g3ycwf548j6HkM3CIdmzpuuPo3peyEAjxD2YOXCcLnn7+wXq8thKm 41cQ/ACoU6BJkxNHF880SGYdOG2HhLtX9HLrz6RJ3g6qJ6FM1F7xcOXouFEMaiadZc/B kM/aCuTlTTinT2ZO3oyQhB1f7IcMZjYkHcU0QkNmFfUElIQvcgUI501NwJkjxIx9zEe6 khR//7ouGaE3LE2BKZsFBmc2JRZgDsG93jU55toIKm0eTjFrbS8o4fY70vj1Ymezqm94 KqKQ== X-Gm-Message-State: AOAM5336vCU8BVot+SIql91VtVuykffNiIKjt39o8aSEhNsGmS6BsS7k uKnW9oVOQTYPddCFfTmG5Dj3mGEhyg95IIsm X-Google-Smtp-Source: ABdhPJxFXbjuf/dqDxnhRP6NTQZsAxhY4MBBeo8thhf+ks0vFKfdBaFVljlnM65lLuUEEFIXRVWo/w== X-Received: by 2002:a17:902:d2c6:b0:150:128:b276 with SMTP id n6-20020a170902d2c600b001500128b276mr7977756plc.5.1645799224075; Fri, 25 Feb 2022 06:27:04 -0800 (PST) Received: from hexa.router0800d9.com (dhcp-72-253-6-214.hawaiiantel.net. [72.253.6.214]) by smtp.gmail.com with ESMTPSA id h17-20020a63df51000000b0036b9776ae5bsm2864538pgj.85.2022.02.25.06.27.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 06:27:03 -0800 (PST) From: Steve Sakoman To: openembedded-core@lists.openembedded.org Subject: [OE-core][dunfell 07/50] grub: fix a dangling memory pointer Date: Fri, 25 Feb 2022 04:25:47 -1000 Message-Id: <17a06ced4ed9305e0a4064bdaad49e653c18284b.1645798648.git.steve@sakoman.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 25 Feb 2022 14:27:05 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/162353 From: Marta Rybczynska This change fixes a dangling memory pointer in the grub TFTP code. It is a part of a security series [1]. [1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html Signed-off-by: Marta Rybczynska Signed-off-by: Steve Sakoman --- ...net-tftp-Fix-dangling-memory-pointer.patch | 33 +++++++++++++++++++ meta/recipes-bsp/grub/grub2.inc | 1 + 2 files changed, 34 insertions(+) create mode 100644 meta/recipes-bsp/grub/files/0003-net-tftp-Fix-dangling-memory-pointer.patch diff --git a/meta/recipes-bsp/grub/files/0003-net-tftp-Fix-dangling-memory-pointer.patch b/meta/recipes-bsp/grub/files/0003-net-tftp-Fix-dangling-memory-pointer.patch new file mode 100644 index 0000000000..3b4633507d --- /dev/null +++ b/meta/recipes-bsp/grub/files/0003-net-tftp-Fix-dangling-memory-pointer.patch @@ -0,0 +1,33 @@ +From 09cc0df477758b60f51fbc0da1dee2f5d54c333d Mon Sep 17 00:00:00 2001 +From: Darren Kenny +Date: Fri, 19 Feb 2021 17:12:23 +0000 +Subject: [PATCH] net/tftp: Fix dangling memory pointer + +The static code analysis tool, Parfait, reported that the valid of +file->data was left referencing memory that was freed by the call to +grub_free(data) where data was initialized from file->data. + +To ensure that there is no unintentional access to this memory +referenced by file->data we should set the pointer to NULL. + +Signed-off-by: Darren Kenny +Reviewed-by: Daniel Kiper + +Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=0cb838b281a68b536a09681f9557ea6a7ac5da7a] +Signed-off-by: Marta Rybczynska +--- + grub-core/net/tftp.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c +index 7d90bf6..f76b19f 100644 +--- a/grub-core/net/tftp.c ++++ b/grub-core/net/tftp.c +@@ -468,6 +468,7 @@ tftp_close (struct grub_file *file) + } + destroy_pq (data); + grub_free (data); ++ file->data = NULL; + return GRUB_ERR_NONE; + } + diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc index 2c0bff8fd0..678aa5c4e2 100644 --- a/meta/recipes-bsp/grub/grub2.inc +++ b/meta/recipes-bsp/grub/grub2.inc @@ -49,6 +49,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \ file://CVE-2020-25647.patch \ file://0001-mmap-Fix-memory-leak-when-iterating-over-mapped-memo.patch \ file://0002-net-net-Fix-possible-dereference-to-of-a-NULL-pointe.patch \ + file://0003-net-tftp-Fix-dangling-memory-pointer.patch \ " SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934" SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"