From nobody Sat Jun 25 10:05:35 2022 X-Original-To: dev-commits-src-main@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 F0077863E7A; Sat, 25 Jun 2022 10:05:35 +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 4LVV3z6QX4z3LTt; Sat, 25 Jun 2022 10:05:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656151535; 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=mnWR3pdXB84se1YwqhLVjqxHREuqfFUt//JYRUS8NvE=; b=UWYL/WJvkr2X7jwn+KhQGwYSSVesi1LU2rpH0CuUr8vfvDqsHhwXJV7muhqlyllvIxKheT AFcf+SgSNy5plC2G0lqQApHfqZIRen23FcYxyg7A1f3sjrzuohKBudDcl0k7N9gBmr2oBB MmLzFDgXsjeCnForzcnxgEYe1YxoMVCs8EaZ/Be+Q540zeGIMt6bNDTLOnGt3ag1R7JTNT YjWDSwHLN5ZfaohMg6b31nNppaqFQhl7tVvVhjmzNdyW6aTf/J60DRcR4ilU/eIFgj3xKf DYnXfoBP77GiiXoKg4c+yUyr3iWpBH5rv8dfh0kU0mTPb9lAytNttay/nF0KYg== 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 BD881226A9; Sat, 25 Jun 2022 10:05:35 +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 25PA5ZJg068653; Sat, 25 Jun 2022 10:05:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25PA5Zk9068652; Sat, 25 Jun 2022 10:05:35 GMT (envelope-from git) Date: Sat, 25 Jun 2022 10:05:35 GMT Message-Id: <202206251005.25PA5Zk9068652@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: 6c4b6f55f77d - main - busdma: Protect ARM busdma bounce page counters using the bounce page lock. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6c4b6f55f77d8d7cee1b277bd6579a77d6890ef9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656151535; 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=mnWR3pdXB84se1YwqhLVjqxHREuqfFUt//JYRUS8NvE=; b=WB47bz6+bfLjkYivR22B1cPm/EsVG6WBN2MEmVTxQirzjNFLFOMrhKF9rEv8EVx4Rc2d4r l0wZr97tjBmXbxUA7e27YvWMcsOUoebnpvCAjRRFb7CO5f1qiOZ6GGp3Xx5CQB18a2v0k5 E5BJ0jZP30psFS+Gk8/iibVtP3CP2go9uNvtGa8uXH6WlVhO706CZICeVMNzpCvCtZSQAH ByuBr7PGCu04ttDOJV6Nwa4Ogqbxluc6B/BJ3opG7LGFDGwZSAUmI5dgE0cmdlIpetZ4Ws HLaP+aIpfZzH3UQ2qnL1ntC20BGqvTBQ4QQQ00meAFe438MvQ+3KDHL5RZThAg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656151535; a=rsa-sha256; cv=none; b=ZzllSzBggwck13UXduIyx+NxquSLlt/XxLrZyfAIHLy4R+N39kTP7lxlpmR+Nw80hV/aIF jYWjhs6rce7rOBsjVQmfPV1KxZbhyICDl0veeP4vM2oa00XAR0vO2FbEsAdbHQBcFYd4jP Ig6G/acjYb9wXXKN1gLjaL2G43IZGvIa4DwVzMkYay5RNGeUJ+iEWQP8GF+FrdmboGmYIk qtnbnhhGXZuSTwIoH8gIBqed/7EcQiDbtwf0/v//BLaYhtL18xmC/y12jgfVkoaiv+UmH5 33ZxkC/5gHcwMhQdAk4hWivzR+0uIyc3n/vWKT17WtVx1s5xE3hgiNhLfgzuPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=6c4b6f55f77d8d7cee1b277bd6579a77d6890ef9 commit 6c4b6f55f77d8d7cee1b277bd6579a77d6890ef9 Author: Hans Petter Selasky AuthorDate: 2022-06-23 09:31:17 +0000 Commit: Hans Petter Selasky CommitDate: 2022-06-25 10:01:59 +0000 busdma: Protect ARM busdma bounce page counters using the bounce page lock. In bus_dmamap_unload() on ARM, the counters for free_bpages and reserved_bpages appear to be vulnerable to unprotected read-modify-write operations that result in accounting that looks like a page leak. This was noticed on a 2GB quad core i.MX6 system that has more than one device attached via FTDI based USB serial connection. Submitted by: John Hein Differential Revision: https://reviews.freebsd.org/D35553 PR: 264836 MFC after: 3 days Sponsored by: NVIDIA Networking --- sys/arm/arm/busdma_machdep.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c index b4110a9c7d84..2540e15f75c5 100644 --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -1183,10 +1183,13 @@ bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map) if ((bz = dmat->bounce_zone) != NULL) { free_bounce_pages(dmat, map); - bz = dmat->bounce_zone; - bz->free_bpages += map->pagesreserved; - bz->reserved_bpages -= map->pagesreserved; - map->pagesreserved = 0; + if (map->pagesreserved != 0) { + mtx_lock(&bounce_lock); + bz->free_bpages += map->pagesreserved; + bz->reserved_bpages -= map->pagesreserved; + mtx_unlock(&bounce_lock); + map->pagesreserved = 0; + } map->pagesneeded = 0; } map->sync_count = 0;