From owner-svn-src-head@freebsd.org Fri Oct 26 23:08:23 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82E4810CC2AD; Fri, 26 Oct 2018 23:08:23 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2D9A16F16D; Fri, 26 Oct 2018 23:08:23 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0015E27752; Fri, 26 Oct 2018 23:08:22 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9QN8M2O055425; Fri, 26 Oct 2018 23:08:22 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9QN8Mmk055424; Fri, 26 Oct 2018 23:08:22 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201810262308.w9QN8Mmk055424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 26 Oct 2018 23:08:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339800 - head/stand/efi/loader X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/stand/efi/loader X-SVN-Commit-Revision: 339800 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2018 23:08:23 -0000 Author: imp Date: Fri Oct 26 23:08:22 2018 New Revision: 339800 URL: https://svnweb.freebsd.org/changeset/base/339800 Log: Ensure we have a full EFI_DEVICE_PATH header before we try to look at its length. Some BIOSes pad the length of the device path to an even amount. When we had a device path that was somehow an odd length, we'd wind up having 1 byte left that we were bogusly interpreting as a full device path. We'd then dereference 2 bytes into that to get a length of the node, which had undefined (and quite undesired) effects. Sponsored by: Netflix, Inc MFC After: 3 days Modified: head/stand/efi/loader/main.c Modified: head/stand/efi/loader/main.c ============================================================================== --- head/stand/efi/loader/main.c Fri Oct 26 22:49:36 2018 (r339799) +++ head/stand/efi/loader/main.c Fri Oct 26 23:08:22 2018 (r339800) @@ -349,7 +349,7 @@ match_boot_info(EFI_LOADED_IMAGE *img __unused, char * edp = (EFI_DEVICE_PATH *)(walker + fplen); if ((char *)edp > ep) return NOT_SPECIFIC; - while (dp < edp) { + while (dp < edp && (size_t)(edp - dp) > sizeof(EFI_DEVICE_PATH)) { text = efi_devpath_name(dp); if (text != NULL) { printf(" BootInfo Path: %S\n", text);