From nobody Tue Jun 04 07:11:14 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vthb73CYqz5MfQJ; Tue, 04 Jun 2024 07:11:15 +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 4Vthb71tq4z4qGG; Tue, 4 Jun 2024 07:11:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717485075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iUSDn3ruVB6P+rtVcH0BYIu8MUgHabU+bOs4p9Z9xZM=; b=lArkWPrNmcCQdTZLAgiS4Xe+sE6hophzyNzoT2R+OqCvMuN07yl/p1verEh11UnURK6X0X URpY3lzynnjAsybhSE0Obv0qxYEcxs1pRKlw+kvVc+NoBmbRcduSLGgf2OGAKPZjkAGXGe z8KmjEnFaXxLEcWUuzEdvRiWK4XWnoRFy0UoXc1nf+w2YwCIvlgRCN5z4LC8QnMnfBOyvU zFm7XeYRZ3l3OiF5B9tOoje3FuRZISsG1jF3NWL4i8xKa25PbA7UtfA2Q6MbhI/IUZP4Y9 spVhr0/ne0XriORz83eJG9Xu2pJp706nMVErclteeLNbS169brv1H7LX6OPohg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717485075; a=rsa-sha256; cv=none; b=RAplpUyWIqts7dfoWkB8PQwfzorinyNfIDALQA8TJDaWfon04+lTuIMQ/ZbTS3SLFwRORa iVwrL0mgfxmkwhOft3Aebvbv3soeHyVgvPghA1rFfb/NGPQM6WwG+TwyvJxEHj2izfD5GM RAa+2itYpG9VSWsKt46i6Ph145Sm9oEDdhFSZhZZO77H6DZZZ0af46KRxKVIGKHgXL32mR XiuQM7lUTaisl49iMudI6X4NGpBP74AGZHUpzhvFhhJq5WngTjFQP03W9bgf9LqSlLlPar T+N3raUkJrBppr3x+MPiZzAbUm+PA5S85B2jVuQWnYJ3kh/FqVzSnmeyvgU8mw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717485075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iUSDn3ruVB6P+rtVcH0BYIu8MUgHabU+bOs4p9Z9xZM=; b=xOY1Cr3iAMdZEPK6YXKr/uplhfjt+ohOsQpX/NY49dVMhlZBma222QbHhJo6dj+SJji/pg 3qlxwrUatCyOMdgknMV9QyIxsb/fSYRjXCqJ5uMFsagM/olnPZEC25WVAoUtLTL+pDuSJt Fyauk9i/UQW2F+cvrxX5pm2XvA5JUkMBuDKboFSjRxMM2AsOCzP9uCnzVxQURULbujuB/p LuPAal9aNJ+b837NVbwe/Jzn8x6h65T8NPoocg9DHfxP9YohzIB+fHsJNyqHeUWJVWvu5G 4uJiFdTr+tXUFG5nNtpEoXE7yWVSN6pWiaeYJ4EYv1yLlV2aPCPJTklaQ6w01g== 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 4Vthb66p8Gz185v; Tue, 4 Jun 2024 07:11:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4547BEVF071101; Tue, 4 Jun 2024 07:11:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4547BEfm071098; Tue, 4 Jun 2024 07:11:14 GMT (envelope-from git) Date: Tue, 4 Jun 2024 07:11:14 GMT Message-Id: <202406040711.4547BEfm071098@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Corvin =?utf-8?Q?K=C3=B6hne?= Subject: git: e425e601b978 - main - bhyve: verify OpRegion size List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e425e601b9781c3585fcee4adf29a295a6b2aa45 Auto-Submitted: auto-generated The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=e425e601b9781c3585fcee4adf29a295a6b2aa45 commit e425e601b9781c3585fcee4adf29a295a6b2aa45 Author: Corvin Köhne AuthorDate: 2023-12-15 11:46:09 +0000 Commit: Corvin Köhne CommitDate: 2024-06-04 07:08:49 +0000 bhyve: verify OpRegion size If the OpRegion size doesn't match the size of our igd_opregion struct, it's using a different layout than we're expecting. To avoid strange issues, we should exit hard. If we see any devices in the field with a different OpRegion size, we can analyse it and fix it accordingly. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D45335 --- usr.sbin/bhyve/amd64/pci_gvt-d.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr.sbin/bhyve/amd64/pci_gvt-d.c b/usr.sbin/bhyve/amd64/pci_gvt-d.c index 95f9066498d6..8cd5d21c8e6d 100644 --- a/usr.sbin/bhyve/amd64/pci_gvt-d.c +++ b/usr.sbin/bhyve/amd64/pci_gvt-d.c @@ -222,6 +222,13 @@ gvt_d_setup_opregion(struct pci_devinst *const pi) opregion->len = header->size * KB; munmap(header, sizeof(*header)); + if (opregion->len != sizeof(struct igd_opregion)) { + warnx("%s: Invalid OpRegion size of 0x%lx", __func__, + opregion->len); + close(memfd); + return (-1); + } + opregion->hva = mmap(NULL, opregion->len, PROT_READ, MAP_SHARED, memfd, opregion->hpa); if (opregion->hva == MAP_FAILED) {