From nobody Thu Aug 01 22:28:07 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 4WZkBJ4SJwz5RZnG; Thu, 01 Aug 2024 22:28:08 +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 4WZkBH5x2Bz4Zt5; Thu, 1 Aug 2024 22:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722551287; 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=d6zs9nIHMx9n3PYSvAvV23IVttq7XmRuFKHXCd2HpeA=; b=esdf9oxcUf0M3Fi/s5I3LXEGPm58dGstWcBe5W9gdldGsgsYjLoHeWOTjQWyJblH/GXddM yF7EZ98YPYgeLuanvnl1XZ87AGF+yErdtEAY8rp9caFOJGOGpcXGC8/zmkWLMiJXqyTd38 yEpbG6hONmxz6jYWz5ik4JUw4FjqG7GiPWp8UjxRoC1Uw71ZBVq4ysZQP+bvNWdgMg9P/w rqyUFZM/6IJJebTU5taVx7pYAFYJE46CCgBRZtBVguoaXtVPBvdMfhXJ0ZOlT/fLRNNzY7 ZFW7axhlFtiqGwtLvNdKA8EKzJWeZATeCqajBP5oelD5kf36Jib9o25WFEFeiA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722551287; a=rsa-sha256; cv=none; b=mBfc3efY9vRtCPuUPJ4DoiCDggNBpfKR2Wj2E6PIAUZF6FtquEhOdF+RNGkao73J+UcpuR B4MLO53PixhYUrULbqP4aFOW+7zcsUtrwIAfZKl+4C2GqHUzT2/5JfH6cdZd+fcH9p48KG m5Yc5QkoE8kvC0SILdR8SWJCrTkbk8jNPEk4iskCyrOut78yB44SyTjA9fnKyFAYbx8k0o X8YGa/GOqwXf4LKKOz5Wg16tByojL3cMHsnDkHEgoT0O1ed0+q/MvSGW3bNDKig0FXNn3W DwoCA8PlCzA/qLzqIebn2Eukzz5tznq/RicqXCBLCYjYriNn7Bm8gmPP/FfAdA== 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=1722551287; 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=d6zs9nIHMx9n3PYSvAvV23IVttq7XmRuFKHXCd2HpeA=; b=XcwCDTBfFBqwq+fRbNh6Yt9sZSMni3QpkeI3C8tnedR2LxQgmeXeRRKvscTjYoNnkV6tVU v6P8bslIGCtSYcZAdcJc9eeL0VeYfwKweUMm/6RT21zrHHCoOh4PvePsEmGRBLjs3Cvovn 0LC11CLLscGcJRoMXBj8Q8h5LnlEUOYkqUvFhITodeZB6VvJes2YvdRdTS5pds/XqSOrUU M0MjR19Y2KCm6NnLI6rh5UV7AC03HIVaFff3hm8G9SJZDtbD3eJQ8NeX47AsGdsrk4H1IX MUN8sz89LocHdehznp0glslzBuMf2yPLmzYSXEffYl9ilYr4ciftCQBzbbtukQ== 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 4WZkBH5VlTz12lC; Thu, 1 Aug 2024 22:28:07 +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 471MS7li028782; Thu, 1 Aug 2024 22:28:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 471MS7p0028779; Thu, 1 Aug 2024 22:28:07 GMT (envelope-from git) Date: Thu, 1 Aug 2024 22:28:07 GMT Message-Id: <202408012228.471MS7p0028779@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: a9a364864ebb - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: a9a364864ebbb3f92cf55583affbea311f29afa1 Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=a9a364864ebbb3f92cf55583affbea311f29afa1 commit a9a364864ebbb3f92cf55583affbea311f29afa1 Author: Vladimir Kondratyev AuthorDate: 2024-07-21 13:10:44 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-08-01 21:16:33 +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 (cherry picked from commit 14fc33ea3a0571ca70e609b6f9e67db39f7c6140) --- 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 c41a55fc9f87..59775629e247 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -781,12 +781,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);