From nobody Sun Jul 21 13:14:58 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 4WRkR70QNNz5RVVX; Sun, 21 Jul 2024 13:14:59 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WRkR65QmYz4S8f; Sun, 21 Jul 2024 13:14:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721567698; 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=4B45ruZkTaJ2wsc0x/dflLGkpqXFElg5y9ZlbTE7IGE=; b=Ay2L40nFOA0MBeR2Dd+YGt8mM3vs5zu6LkEYOhVJgCdBDSep6awlTKRN58/m6R7mSp3iai 3gzAxmWBFd1G9CQxRVtp5KcnfSqetbsDv0Nqz9fnvqRYjbfv+iXnjQNiJGzdEEZq53D3ul vObk6uuE8fc64QSEvWztUJMfrpqYzlNotaQc8mUuUaosUEm1LJ5adMmnRXowVeJnUE3yAv UQ75r9LdZQ4roworV72Z3bKJ9gVNK/CCPkeH+3HNHVvFKWTsvrfgIIrNqFNVcs5064P0LR 10xrDIDOeJVvdve6ak/HBhMOuT5qc9lYdpl9JG/Y9X1cO6SaqkgI5FYViOlEkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721567698; a=rsa-sha256; cv=none; b=xaNRBNImZgKcalsBO4xcl8ptyx1zAqNXycMzHAA73tUQzmNIeGbPznJyssRqN9855sFyrB E+4puo+jz3yOdLFEPF75iiG6c4CPMWF123obrFWa0eWRDd9DgEoVDlfmGNtYZLEJaISpxB Rg+VA/wIpdgfpNJ8T2qVeV4rwO34lfVzfxjT/fKWEf89CWxW5Sb52OFYpNsQrMB4FzQiiC An32C7NMb8DABR9gK6ke++ZJ79RLjlfUC3PCDttk1hwOScX1NnjXCx/+bLrEB8cWSVGhZD ChtsfheBdfY6sAtZBeyQqiNqo9SOuCqA3ZpnSoWZclvN7fW5wy+04gO+xuFSwg== 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=1721567698; 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=4B45ruZkTaJ2wsc0x/dflLGkpqXFElg5y9ZlbTE7IGE=; b=tZs/aXVHCIPMF6+cFyOVLrTUV6Yd+YXGGk2KprjICTs656vckO8mO/Em8Lau1ognXKEPzt qZBRx5D9DCU7p5L/xt51hsdVYZWnTEX9jm+O898M3iBOgCi/KKk5iTaeTL2JiOzKea4FpD REuwoxTw4q0cSLLM6vBKps+0HyhBeInckuDZBpZQ9KIT9ESnnFMPiZgFUZyPrNvAk5FNoc tXMmWahGpIwzH5Tw+6x9qt5Bp6zbnlwEwzcFBDboJ9JlFoCgjnx7RjsppAIvEluxuE4KkF sPQ7kWHWLxNQzNdQWSI7uNN/3PgMidMgbvUZiFynMQN7yW+6b+5Mbf0o05isIg== 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 4WRkR64fx4z11mB; Sun, 21 Jul 2024 13:14:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46LDEwKA023462; Sun, 21 Jul 2024 13:14:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LDEwoM023459; Sun, 21 Jul 2024 13:14:58 GMT (envelope-from git) Date: Sun, 21 Jul 2024 13:14:58 GMT Message-Id: <202407211314.46LDEwoM023459@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: 14fc33ea3a05 - main - LinuxKPI: Fix resource leak on pci_iounmap-ing of PCI BAR 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 14fc33ea3a0571ca70e609b6f9e67db39f7c6140 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=14fc33ea3a0571ca70e609b6f9e67db39f7c6140 commit 14fc33ea3a0571ca70e609b6f9e67db39f7c6140 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:10:44 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-07-21 13:10:44 +0000 LinuxKPI: Fix resource leak on pci_iounmap-ing of PCI BAR If the resource was allocated with want_iomap_res flag set. Sponsored by: Serenity CyberSecurity, LLC MFC after: 1 week Reviewed by: manu, bz Differential Revision: https://reviews.freebsd.org/D45905 --- sys/compat/linuxkpi/common/src/linux_pci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index 3287a8a15ff5..3376d93053dc 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -780,12 +780,18 @@ void linuxkpi_pci_iounmap(struct pci_dev *pdev, void *res) { struct pci_mmio_region *mmio, *p; + bus_space_handle_t bh = (bus_space_handle_t)res; TAILQ_FOREACH_SAFE(mmio, &pdev->mmio, next, p) { - if ((bus_space_handle_t)res < rman_get_bushandle(mmio->res) || - (bus_space_handle_t)res >= rman_get_bushandle(mmio->res) + - rman_get_size(mmio->res)) - continue; + if (pdev->want_iomap_res) { + if (res != mmio->res) + continue; + } else { + if (bh < rman_get_bushandle(mmio->res) || + bh >= rman_get_bushandle(mmio->res) + + rman_get_size(mmio->res)) + continue; + } bus_release_resource(pdev->dev.bsddev, mmio->type, mmio->rid, mmio->res); TAILQ_REMOVE(&pdev->mmio, mmio, next);