From nobody Sat Jan 15 19:13:13 2022 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 0D3241955C83; Sat, 15 Jan 2022 19:13:14 +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 4Jbnr96NJzz4Ynd; Sat, 15 Jan 2022 19:13:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642273993; 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=PwxcbRfzaEvXleRgLR1H5/AaPd5KYWURgrGDQK0cvIA=; b=mFrxuNW5088hdrwI+SNl4VEXpYbE/ArFAYo+K/SDYrr46+ryKobAa40lgrWD5Wuz4xpFmh diBIWJWNFxZzef/QaSQ2AdnA06SJz0c83QWbk8PP0VAhQYty+EX687PEjyVs8Hqb+Jaci+ lo7IFf5AF0ErUftOFbjVTtjK/t5GtJ70buMzlyjLHtOy0/mT9RXNn24hF3JJlpXfYpIFY/ GvixnpvTH4dIdmmVOCFUgfRs/dDY2tOJXc8veMyY+rWFu2MClv3KNJbIUoyomM39belC23 5l8y89tW4MA6kURYRNIbPgmLRZkXXEjP0yjXl7+C1w4Kj9fb4MhjlrlB85Sqcg== 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 B0196476B; Sat, 15 Jan 2022 19:13:13 +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 20FJDDv4002096; Sat, 15 Jan 2022 19:13:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20FJDDC6002095; Sat, 15 Jan 2022 19:13:13 GMT (envelope-from git) Date: Sat, 15 Jan 2022 19:13:13 GMT Message-Id: <202201151913.20FJDDC6002095@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: 4e3a43905e3f - main - ofw_pci: Fix incorrectly sized softc causing pci(4) out-of-bounds reads 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e3a43905e3ff7b9fcf228022f05d636f79c4b42 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642273993; 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=PwxcbRfzaEvXleRgLR1H5/AaPd5KYWURgrGDQK0cvIA=; b=JkEEgQL4zBdpbwNipHewXHFRBO+qcfcFBD5pAk266t79GeYl0YmOjfxRTDiLAuk6HaKzXL sPDHOCW3vanOHvWVbZiJ6ao04bT3dj7WuoEeiIBzQN/PPEaPJ1MfPLa2gKPkIViforFYAd ZdGn8ZRB3LvlDHeWqUfwHk7jsIaQOIfKLQn7shFzpieN2HpLOdI9NLijeNMGwqij34gV/L JGD+WFuqlpHsHrWmZ9vJbsq/FFgbwb7/nP03k8YKQEZGch0V9rERD3sdPqrO5MlIKXp3PP p34Qd6MI0mHfpNuuixDuuAHHkXA6fLVTT1z4BM8rGjc6wkdaXwqKSDswDwAKNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642273993; a=rsa-sha256; cv=none; b=L0gWzD5EtitjjYA59sHvG5tfZs/hArpeDrkugaDp7zW5KJFpn9u2PQuhZPK+76nOE1W9M6 9lXOr3aNUvhR4e7ZFElGIW9cLCLbqF935hzi0CZ6KDCNLXMGbuLdx/Car87tKsqcNJz6hI Xi3JpsInW9jZ5OvJPElMveufGh+MvGhidh3o4NVtJux1mkW7Fh8E/n+xULpmBJstKSGSZk bNMnm48d8hQ/L5iwOIZPTKjknfwoJg8KwD0qv9TOu8x4/FSPjmQux5Z94WxdGaMOz/XhuG sfYfHzIeBy0KAyXi13Y0EZYRaf8G7RaJhCSZgKQi8oORv378LtuyBRy2qLhmuA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=4e3a43905e3ff7b9fcf228022f05d636f79c4b42 commit 4e3a43905e3ff7b9fcf228022f05d636f79c4b42 Author: Jessica Clarke AuthorDate: 2022-01-15 19:03:53 +0000 Commit: Jessica Clarke CommitDate: 2022-01-15 19:03:53 +0000 ofw_pci: Fix incorrectly sized softc causing pci(4) out-of-bounds reads We do not include sys/rman.h and so machine/resource.h ends up not being included by the time pci_private.h is included. This means PCI_RES_BUS is never defined, and so the sc_bus member of pci_softc is not present when compiling ofw_pci, resulting in the wrong softc size being passed to DEFINE_CLASS_1 and thus any attempts by pci(4) to access that member are out-of-bounds reads or writes. This is pretty fragile; arguably pci_private.h should be including sys/rman.h, but this is the minimal needed change to fix the bug whilst maintaining the status quo. Found by: CHERI Reported by: andrew --- sys/dev/ofw/ofw_pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/ofw/ofw_pci.c b/sys/dev/ofw/ofw_pci.c index 7f7aad379ddc..4bd6ccd64420 100644 --- a/sys/dev/ofw/ofw_pci.c +++ b/sys/dev/ofw/ofw_pci.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include