From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.155 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796082752; b=k0JNxpp/4uUkgMA5ycRz3qVt6azJVTSAyfMbRl73YQ0xwn550arbIe4xTy7JZd/tzFrv qkP89IcptTlibgdJkFsfOsOByVzRCKnuGi03LCAlDhi4pa9nEm2qjJVyabVHp42XinRu2 HwpFcE0gbReScUE+nps4rpZvV/Y8CJEDyRju0FkEDTF5mSHMeAoCFKu+nXqc67eoXYE1M AHMVe/DLdgCtkC8qq5xJyLMSwdOumWP3BTkGomBxt8PUvPZsbvIcKAjwJK8vZIh3vjNm/ 6VIfYNoYRDcroqQYqVdJZ57AdgcDmwTHsQWxiemmnBNloVhCos0qNP8fFVwZw+qgoHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796082752; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: X-Mailer:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=PkohF0/TrdcxgYjOOf0+vD3Myc867rcuF0k07Qf9rAE=; b=w5npORwG+Qu8oQXFPlgLaEkmkqHeDLsC1gxBo7Ge+jiayxBxryOnoUysgjZvx2A8UK6L +wEQZEDHDi+BI3uT6xxRu9R016ber3OBiQowxzl/q2A/H0Et8q1l6CdqKOFrnxi51W/Yo k6joaUQx5nTV0YMdG8ViEuUmFaA6KWGcA2d+MPT8D7cT1M+/1GsTg3xuY7THJlWGyzw6W mIB3EYBmml5fW6w8G7WW91mWWf5UnReLUqwotTOHFo5UatQ0HV1Y6aFXTQfT19OII51gf MMfqk7ibjnb7KAfP4cfaMItmuwzst8LSdxQjbkH1mcdp8ryIjHoh22LbyMk7tBF29Tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=shazbot.org; spf=pass smtp.mailfrom=shazbot.org; dkim=pass header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256 header.s=fm3 header.b=eQNjLPSd; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=Clyc0A2b; arc=none smtp.remote-ip=202.12.124.155 Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F2EF606A31A for ; Mon, 30 Nov 2026 23:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2F2EF606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shazbot.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shazbot.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=shazbot.org header.i=@shazbot.org header.a=rsa-sha256 header.s=fm3 header.b=eQNjLPSd; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=Clyc0A2b Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3BB637A0343 for ; Mon, 30 Nov 2026 18:52:30 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 30 Nov 2026 18:52:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shazbot.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1796082749; x=1796169149; bh=PkohF0/TrdcxgYjOOf0+vD3Myc867rcuF0k07Qf9rAE=; b= eQNjLPSdKXFbQBBn2M0rouQjHeCbwRtcifN/e50MPnPwF6j7xE1BYv1c4FNMnyJv gV7tqshhQ/t0i+FrlcOuxPqh1J3sIDh/DyANvEiFuFsEDxFJZOQ8IhvoqBiqh3Ka AW08hJzO0io13WGU1pd1c8/1qEMcFhn9m4/An9wD0Peixt+R5c5O0rG4TFfGutit O49uVBqR/XyuXoy1KIbmRqqnxapoDJ1QQW1RX6CAcxOuLixG5oq33+V/xL/GV/MU eMg3ofRgsP1YGYLBxkdoUKPQaETIoH+DSh6sj8aLvfAG3YBwyv2DHpVj9y5e/3N0 A4MLU4IKy6ylM3W9tjKd0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1796082749; x= 1796169149; bh=PkohF0/TrdcxgYjOOf0+vD3Myc867rcuF0k07Qf9rAE=; b=C lyc0A2baMAZ5s0qR6uWgOJel/k7JPnlFQcwSr5IxB0rlRBZ6oH26PjBrr1FjPnLB 3uIPT1cosEfMuzgK5Ix3sp962uNYbgZsTFStZ3lTmLN9WNkdFjwGu0KD/T8RXcal uB2zJx+j57/VietIG9y1xz1IeKeVSldt8LCAm6hb0s5TSbmPXFW+xY/PpnAOHHlh /uec5bkwJWoJ/fR16LctjE0IxZVb8vvElGdhuJmyi/v1uu2SI2DiLM3pKprwkEZC q/vs30QfcoMfl7v181WkcAv6Nohhr2ITX1/1+gCSfYThoxKG7ri3Hy279ZQUojHg yzSA7I3Vte8icmgHXNe7g== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=shazbot.org a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796082749; d=shazbot.org; mf=PGFsZXhAc2hhemJvdC5vcmc+; rt=PGt2bUB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:H5pcw7IKqM/wdtn0QSBfC7Ua1eVUsm+IDtWMUC8tcU+6mPH 97Y9REEc5JvLr/syfbRYz/3JZ7HDKnCRss2REdc16V9olL+bmUqqyMxy0kWhcMEs vAkunYk5XDSawreJhyx4+3Ptk2psi41xHUvLFTbdRi20aS01bg3/iJbslFDDSJ+P SnrDfYDJiOtLAK5YOwvV/E4A+JxTMQAvVVuXfifkbAHcouhPniWVQi6gdvT5i2z8 OhK3BheXDrYLWImtVBtdRtyEW8ueH/aEA6HBSP5avLFLkY8ZEY0FDJz3Mw2qExyY kJ9Bqe+N16TBKzNfSxZbwj5igmlL94QATFgvwbg==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:LmUSOyz2EM8eUo63hYHmCk7tkd4tkZM6QKOYX0KPI44=:MVlzaRqGuSp27f9lYCYdzVJnfW0ctX78yJjGgrsXCi4=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE+c+OPej588cyYOP514WdP4Ld48g/TWIM78iTAz6be5nDJuhiaKVSTDvoFjwn/B6 QHMfgLQVLvMPRv0j5hfi/VWuiegnzKux12xEI/8DYbEPQUNeZuLdAEcn6mbT6WbgCGh/ae MGd4/O+1XG92Me76RpNFmnShk9sAGBLWj3Xt3M+/6+g/shDk7Rr0cFyPh4Io/Epq6qiLw/ AXQiZDiIp2ERd2vUwg8u3I4TNxNNZRb3qExJkMTOheGs5Yw1MGj+fLeg7v7UOnb2TwPtTT D3xbDfZOUCDk8rfc5n+l0hDLQfHScXMgfyAT09M9eR01yQMKQMa8OJkXlNAQMgX71UlLPg DJPl+Om57Y3QEOl9pYF0CCPf6Th2/79GAE9bYe7l4DlFVTEXlhUZWo3ZDGbuql/p94WIuR ZUfUjagacBs3bj9T/wa6UPMIiwXhELZgK8gXUm88Kj6bzhEyTlyShwXXwSfgXePR4VKM8E l3pxRRCz42WhrIclaJ29Mq7s30zxErZxHYjN1ZSI2+PT9SJ2gwIwctxvugw9KvxlMwP5z9 IhvgKVA6EVAFtM1e5lCRnguoBW8+Sb5KlYFLVJeRXYJuGbZx4u6sICLvM5gUciwmF3ZxS6 ylq3IaSCjxnGp2cApyJihtZomQCwjcBu+ZnCQSctCoZIQeuQj9KADfs7iK3A X-ME-Proxy: Feedback-ID: i03f14258:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 Nov 2026 18:52:28 -0500 (EST) Date: Mon, 30 Nov 2026 16:52:27 -0700 From: Alex Williamson To: Aaron Lewis Cc: Jason Gunthorpe , kvm@vger.kernel.org, dmatlack@google.com, alex@shazbot.org Subject: Re: [PATCH 0/3] vfio/type1: Fix pin leaks for reserved GUP-pinned pages Message-ID: <20261130165227.5cdba5ad@shazbot.org> In-Reply-To: References: <20261119185659.889654-1-aaronlewis@google.com> <20261119202713.GU2245175@nvidia.com> <20261125123432.353f392d@shazbot.org> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 30 Nov 2026 06:40:01 -0800 Aaron Lewis wrote: > > Are you only suggesting 1 & 2 because the RLIMIT enforcement is user > > visible in 3? I'd tend to think we should consider them all, they're > > real fixes, even if the usage scope is pretty narrow, currently. > > No, both patches 2 & 3 charge reserved GUP-pinned pages against > RLIMIT_MEMLOCK (I can make that just as explicit in patch 2's commit > message in v2). I only suggested 1 & 2 to offer a smaller scope focused > on the DMA map/unmap paths, in case there was reluctance to take broader > changes to type1. After all, that was my main motivation for putting > this patch series together in the first place. I wanted refcounting to > work properly for reserved GUP-pinned pages (e.g. DevDax). > > That said, I would definitely prefer to keep all 3 patches so external > page pinning stays consistent as well. > > > > > More reviews would of course be welcome. Thanks, > > Sounds good, I'll ask a few folks internally to take a look and help > review. I ran a local sashiko review with codex that came up with this issue on patch 2 that I haven't been able to dismiss yet: --- > @@ -742,32 +762,20 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr, [ ... ] > nr_pages = num_pages_contiguous( > &batch->pages[batch->offset], > batch->size); > - if (!rsvd) { > - acct_pages = nr_pages; > - acct_pages -= vpfn_pages(dma, iova, nr_pages); > - } > + acct_pages = nr_pages - vpfn_pages(dma, iova, nr_pages); [Severity: Medium] Could this introduce a memlock accounting regression in vfio_pin_pages_remote() in drivers/vfio/vfio_iommu_type1.c when a single registered range contains both reserved pages pinned through /dev/dax and pages mapped through /dev/mem, even without external pins? The reserved pinned pages now contribute to acct_pages. With both has_pfnmap and has_gup_pinned set, vfio_unpin_pages_remote() uses put_pfn(), which skips reserved pages and returns zero for them. Wouldn't their new charges therefore be omitted from unlocked? vfio_unmap_unpin() subtracts only unlocked, and vfio_remove_dma() frees the bookkeeping without reconciling the remaining dma->locked_vm. Could repeated map/unmap operations therefore exhaust the process's memlock limit? The same imbalance can occur during mapping-failure cleanup and vfio_iommu_replay() rollback once both flags are set. The reserved-page pin leak already existed, but the baseline did not charge these pages. The follow-up change to external-pin accounting leaves this case unchanged. Could the mixed-mapping cleanup also balance these newly introduced charges? --- While the scenario is unlikely, it's a new accounting regression. Anything we can do short of disallowing these mixed mappings? Thanks, Alex