Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nuJBC-0007hx-OD for mharc-grub-devel@gnu.org; Thu, 26 May 2022 15:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJBB-0007ho-Oh for grub-devel@gnu.org; Thu, 26 May 2022 15:29:53 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:36334) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuJB8-0004NQ-FJ for grub-devel@gnu.org; Thu, 26 May 2022 15:29:52 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24QHNCus014863 for ; Thu, 26 May 2022 19:29:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2021-07-09; bh=pKrT6Jh7OwXBczxkAXHrlYpzkRiK8k5if79UejVZ2AA=; b=ZRJrsLGOuZKylQCqDFfQN14zbQpf+Wukl4NvANFDFMhW72GYqO1wRA94zAo59GdSCh/H KWuMJLKqf4d1v/oac/91mDD+/IdtVhzRbDXg8QzS0lce5lvwS61HKnc1W/SZKkk8ag5Y xWrqoiQbfAlMKfFdJ3GPgaqI01DXSNUog3F0g5lj/7EegYc0B/2DM5euYtZVcmVrL6jH K01FSS9uoOiPq+sQ285G/d78OLGm0X21WifV/+vTpwlApCz7r43v4S5DIhHPZrvLfKkD 0OpoIgqLg2a6fSiJ83gpe0wTX1u8dnd5RlyoXXXt164RkCq7Mc7wCoMWY/ABnkfrLyzA bg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3g93tdwjm8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:44 +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 24QJAduo004290 for ; Thu, 26 May 2022 19:29:44 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3g93x1u4c6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 26 May 2022 19:29:44 +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 24QJThYP007445 for ; Thu, 26 May 2022 19:29:43 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 3g93x1u4bx-1; Thu, 26 May 2022 19:29:43 +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 0/6] Fix coverity bugs and add checks for elf values in grub-core Date: Thu, 26 May 2022 15:29:46 -0400 Message-Id: <1653593392-1932-1-git-send-email-alec.r.brown@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-GUID: oINPlKkmqiXUik8d7A1_kj1lznGkf06y X-Proofpoint-ORIG-GUID: oINPlKkmqiXUik8d7A1_kj1lznGkf06y 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:29:54 -0000 Coverity identified several untrusted loop bounds and untrusted allocation size bugs in grub-core/loader/i386/bsdXX.c and grub-core/loader/multiboot_elfXX.c. Upon review of these bugs, I found that specific checks weren't being made to various elf header values based on the elf manual page. The first four patches in this patch series address the coverity bugs, as well as adds functions to check for the correct elf header values. The last two patches adds fixes to previous work done in util/grub-module-verifierXX.c that also relates to making checks of elf header values. The Coverity bugs being addressed are: CID 314018 CID 314030 CID 314031 CID 314039 Alec Brown (6): grub-core/loader/i386/bsdXX.c: Avoid downcasting (char *) to (Elf_Shdr *) elf: Validate number of elf section header table entries elf: Validate elf section header table index for section name string table elf: Validate number of elf program header table entries util/grub-module-verifierXX.c: Add e_shoff check in get_shdr() util/grub-module-verifierXX.c: Changed get_shnum() return type grub-core/kern/elf.c | 18 ++++++++++++++++++ grub-core/kern/elfXX.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ grub-core/loader/i386/bsdXX.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------- grub-core/loader/multiboot_elfxx.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------- include/grub/elf.h | 23 +++++++++++++++++++++++ util/grub-module-verifierXX.c | 13 +++++++++---- 6 files changed, 290 insertions(+), 86 deletions(-)