From owner-dev-commits-src-main@freebsd.org Thu Jun 3 21:22:30 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DF68641122; Thu, 3 Jun 2021 21:22:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FwzPf0sD5z4prY; Thu, 3 Jun 2021 21:22:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 06544114B9; Thu, 3 Jun 2021 21:22:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 153LMTUf054634; Thu, 3 Jun 2021 21:22:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 153LMTkK054633; Thu, 3 Jun 2021 21:22:29 GMT (envelope-from git) Date: Thu, 3 Jun 2021 21:22:29 GMT Message-Id: <202106032122.153LMTkK054633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 5deb35002545 - main - uefisign: fix SizeOfHeaders sanity check. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5deb35002545ca5081cc90795fec68bcea30f75d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2021 21:22:30 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=5deb35002545ca5081cc90795fec68bcea30f75d commit 5deb35002545ca5081cc90795fec68bcea30f75d Author: Kenneth Camann AuthorDate: 2021-01-03 02:11:42 +0000 Commit: Warner Losh CommitDate: 2021-06-03 21:22:14 +0000 uefisign: fix SizeOfHeaders sanity check. This check was too aggressive: it is fine if SizeOfHeaders is exactly equal to the size of the DOS stub + PE header + section table. Despite being wrong this code typically worked for most EFI binaries because SizeOfHeaders is rounded up to a multiple of FileAlignment, which is often large (e.g., 512 bytes for the FreeBSD loader) so most binaries made it through. Reviewed by: imp@ Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/445 --- usr.sbin/uefisign/pe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c index 6459321441d8..09b5edd56ab7 100644 --- a/usr.sbin/uefisign/pe.c +++ b/usr.sbin/uefisign/pe.c @@ -232,7 +232,7 @@ parse_section_table(struct executable *x, off_t off, int number_of_sections) range_check(x, off, sizeof(*psh) * number_of_sections, "section table"); - if (x->x_headers_len <= off + sizeof(*psh) * number_of_sections) + if (x->x_headers_len < off + sizeof(*psh) * number_of_sections) errx(1, "section table outside of headers"); psh = (const struct pe_section_header *)(x->x_buf + off);