Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nuJBh-0007tr-4c for mharc-grub-devel@gnu.org; Thu, 26 May 2022 15:30:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJBT-0007qA-B9 for grub-devel@gnu.org; Thu, 26 May 2022 15:30:11 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:40908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJBR-0004Ns-19 for grub-devel@gnu.org; Thu, 26 May 2022 15:30:11 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24QHNGY5021674 for ; Thu, 26 May 2022 19:29:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2021-07-09; bh=dqtjB7A03ufNXTUBp236EkdT8gAD3MjXJXBcewpIwy0=; b=dS1X0doayVZZxEIsXpWgEq2f3ZVEUq980Uavd3T4zce1f9J5Sjsc+vVSJXzJJjIoD+qI Lb3D/HdswZlZsXcbgvd4YL4aW4BRi8CxXvHf2juQkSteBBdGHdMTderWALAvoA2ZNmP2 fb5dsMFGIN4L7D4gqott/cjjTlVlx3MktPs2JMc+nTM8dt96u/k9HzXjk3Q2XGzCltbQ KmYDh3m+a8dFOCAAQEmrzIJPYN5f1n5mEG3JkS80gvPec6e9tHecUIgfWyoaDu2DIBiQ Kl+PeJRE8HueR4ewSgnJ26XgqylzQ3KcMNvnCn05EHv5NDCUk3rQxUd5vYB8MNxr2shy ZQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3g93tbwqek-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:47 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 24QJAdhN004337 for ; Thu, 26 May 2022 19:29:47 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3g93x1u4cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:47 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 24QJTkUG007484 for ; Thu, 26 May 2022 19:29:46 GMT Received: from localhost (dhcp-10-152-14-18.usdhcp.oraclecorp.com [10.152.14.18]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3g93x1u4cj-1; Thu, 26 May 2022 19:29:46 +0000 From: Alec Brown To: grub-devel@gnu.org Cc: daniel.kiper@oracle.com, darren.kenny@oracle.com, alec.r.brown@oracle.com Subject: [PATCH 5/6] util/grub-module-verifierXX.c: Add e_shoff check in get_shdr() Date: Thu, 26 May 2022 15:29:51 -0400 Message-Id: <1653593392-1932-6-git-send-email-alec.r.brown@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1653593392-1932-1-git-send-email-alec.r.brown@oracle.com> References: <1653593392-1932-1-git-send-email-alec.r.brown@oracle.com> X-Proofpoint-GUID: ysATy-ZLcnWZAs0mhKd_dkUMlk_Z4D5_ X-Proofpoint-ORIG-GUID: ysATy-ZLcnWZAs0mhKd_dkUMlk_Z4D5_ Received-SPF: pass client-ip=205.220.165.32; envelope-from=alec.r.brown@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2022 19:30:11 -0000 In util/grub-module-verifierXX.c, the function get_shdr() is used to obtain the section header at a given index but isn't checking that there is an offset for the section header table. To validate that there is, we can check that e_shoff isn't 0. Signed-off-by: Alec Brown --- util/grub-module-verifierXX.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 4e6cf133f..cf3ff0dfa 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -134,6 +134,9 @@ grub_target_to_host_real (const struct grub_module_verifier_arch *arch, grub_uin static Elf_Shdr * get_shdr (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word index) { + if (grub_target_to_host (e->e_shoff) == 0) + grub_util_error ("Invalid section header offset"); + return (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + index * grub_target_to_host16 (e->e_shentsize)); } -- 2.27.0