From owner-svn-src-head@freebsd.org Wed Jun 10 09:31:38 2020 Return-Path: Delivered-To: svn-src-head@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 7E08132E8BC; Wed, 10 Jun 2020 09:31:38 +0000 (UTC) (envelope-from andrew@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49hhZf2sGXz3Rw2; Wed, 10 Jun 2020 09:31:38 +0000 (UTC) (envelope-from andrew@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 5D6882496F; Wed, 10 Jun 2020 09:31:38 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 05A9VcZ5031695; Wed, 10 Jun 2020 09:31:38 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 05A9Vclw031694; Wed, 10 Jun 2020 09:31:38 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <202006100931.05A9Vclw031694@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 10 Jun 2020 09:31:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r362008 - head/stand/efi/loader X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/stand/efi/loader X-SVN-Commit-Revision: 362008 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.33 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: Wed, 10 Jun 2020 09:31:38 -0000 Author: andrew Date: Wed Jun 10 09:31:37 2020 New Revision: 362008 URL: https://svnweb.freebsd.org/changeset/base/362008 Log: Fix the efi serial console in the Arm models. On some UEFI implementations the ConsOut EFI variable is not a device path end type so we never move to the next node. Fix this by always incrementing the device path node pointer, with a sanity check that the node length is large enough so no two nodes overlap. While here return failure on malloc failure rather than a NULL pointer dereference. Reviewed by: tsoome, imp (previous version) Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D25202 Modified: head/stand/efi/loader/efiserialio.c Modified: head/stand/efi/loader/efiserialio.c ============================================================================== --- head/stand/efi/loader/efiserialio.c Wed Jun 10 07:46:22 2020 (r362007) +++ head/stand/efi/loader/efiserialio.c Wed Jun 10 09:31:37 2020 (r362008) @@ -216,8 +216,9 @@ comc_get_con_serial_handle(const char *name) status = efi_global_getenv(name, buf, &sz); if (status == EFI_BUFFER_TOO_SMALL) { buf = malloc(sz); - if (buf != NULL) - status = efi_global_getenv(name, buf, &sz); + if (buf == NULL) + return (NULL); + status = efi_global_getenv(name, buf, &sz); } if (status != EFI_SUCCESS) { free(buf); @@ -232,17 +233,13 @@ comc_get_con_serial_handle(const char *name) free(buf); return (handle); } - if (IsDevicePathEndType(node) && - DevicePathSubType(node) == - END_INSTANCE_DEVICE_PATH_SUBTYPE) { - /* - * Start of next device path in list. - */ - node = NextDevicePathNode(node); - continue; - } - if (IsDevicePathEnd(node)) + + /* Sanity check the node before moving to the next node. */ + if (DevicePathNodeLength(node) < sizeof(*node)) break; + + /* Start of next device path in list. */ + node = NextDevicePathNode(node); } free(buf); return (NULL);