From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796235940; b=pX4mmhteAQK2sHQfv51KSflTVGSr3VIB2OehfL9d9Z9k55Oiz8Uzc/zJYhJsoUr6fJe8 kogkPzQQBjrPxOgcy1Y3USpXxCuWfXOq0P+9NfSoHEiePpks8sBKKO/HIxrHkaYGJTPhH ZBkUP46ApJACUdZkBsn9A43aK7kXT23xrqszs1x+Qzs3GJBfa5i65le2UyIn1hibFv7UR su9Em67pzExtatBXMeinLUztkP8iQUQ0uNwZhUiaPwV6J2yYuIapbWZtHECGWipvFtbU/ btBLBLkMuT8b1wZSJaK2n49nLl9eBszeSWdKdmie059HijxXqtVbVpdrWy8SVOr0BSw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796235940; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=HCZ1qLBd1pzfcq5TNY7FTg1+gEG9/3B3iNlSE6PVi5g=; b=DaaSOxi0G/aFZSJA1QFCL2lCO1Y2sUHHUwNxjVL6n01qgdW96ZbSdhTU2is2ux5zSSs5 lEq/ZupgKD7YDDH3wB1yvgs+im+WlOfHpGmG6jbaQkT9opv0Q94LTWRYIuokQn1o/XKhp jdcuG0ohNe3zYU9RdZirH4hKYO/aIip4Spq5naIr60bL/ORVsxER0PZWyF41B/eKhkZaV s0w2novQCpjh0EbFASV/PQA7YYbFJBKc/qDi6g3HsqJ2nEGx1e6SYnDzt/ZVSgGf8vAwF ovPpKoSiiDgkFNLXb8b/hGMwV941zrqIkzVlhGzVFlEkrfk9OHOcO+1jRLLU9We933w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UqXODGG3; arc=none smtp.remote-ip=209.85.214.169 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5271606A339 for ; Wed, 2 Dec 2026 18:25:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E5271606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=UqXODGG3 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2f0e8bbc7a4so3605ad.1 for ; Wed, 02 Dec 2026 10:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796235939; x=1796840739; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=HCZ1qLBd1pzfcq5TNY7FTg1+gEG9/3B3iNlSE6PVi5g=; b=UqXODGG3rOu7UyPDON8OI17OTXXYtxAc1bXrL2yYWoSWn8A5ULl2ACP2WNZVwAPnCj HQ8vIEBQEaJjFChfjIJNz4L5mst4m7tz2VCt9uCcYKuZOvYqbNm5tP3qcm2Pd6/vlEcA rG+yClxV6ktaEFZJKoZw926GS8TIDBPgFedsMWEtPzqEjS+HnsS30D4H08H+sEM/zKlj Wn6JmrPznNs9nQ1ip8hjO/KoBNw4dlXzmZqY7Qw51uSQbITufDaBj1qehXoMjL/mA97i LQBR6AztajcjW5Mp22pfKB3foLZj0TYboXbVhE7zqVsJ0VBA0D9I4I+xPo14hjfekz9E TnZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796235939; x=1796840739; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=HCZ1qLBd1pzfcq5TNY7FTg1+gEG9/3B3iNlSE6PVi5g=; b=FbiQi2MmyamPi9fVxgY/rTDHeGeDnUOM9DAjHA0HM75GDU5m6hHIEvb8jdethpmndf bAbMN5Dvj8zeMrdDo7doY7mtThW+GSqh9FHRD61BaRDxVANmoo825eILdo7imXjIv/57 wICTEE6KBSaabmVi8jCtMSgpgFCWYeTW5dDRVfS4dakGECFEJ6EnY1cXFxtC4mtd9rJr MnHHBPzHzVqy2ztQ9aGYMuljeO4RHqeCNgFCVR8GTWIW9z969XgfuBRaHXpKUwTFD0jq De1kBJbAxX2e2GxRclasgjfA463eXJ5Z085TNPS+5FBDsxtjjKhgbHzAVjqw9PPrmhiM 9d2A== X-Forwarded-Encrypted: i=1; AL+hErFW6irlNCmnmSk2P7AyFvVOCgXtxmoCukGtiy5Vj4OiN4QvdUej0tCrnZn1ekS23rCJnf65o3U=@vger.kernel.org X-Gm-Message-State: APuU4Z/Xrqj4DgclgvPfJXMVmOKuFlpV6kRv7IpdokYjQnDYQ2iSgpLF f2QljN25m+/hirdpAXt/liq1PZ2v3+Lwrx382VLNMsgSwQED8EGSY8q6FSNt9560sg== X-Gm-Gg: AZFdTZfWvpaTMwNMAdm5jfmPru02HB0IhU3V05+A0N+ywu2brGDwgKc0FH/E/cv1Fkq bbcGesmjRsVfabeUAvaGNOAoSwoNbI0ALkrj2p5LeVZHZWyTMKVVqBL81RZ18ZOfYxoCPnLiOEZ lnmDQknFYkNWMDcme0+x+lFqcq64sb7EQF7mzBCElTgR3BfOIrTIYske9Isnp8Ax1f5Jj0HbEiu ZhYpB2wGlbWuYiGEPjpL38PUJWTiGEE4YAtAHss/BYeoyeTj6sLK1glWLEXM0XyUdCz64znF8Um 8r2iEIM0QRRB31iFt7mI7TsQMtjmN5X3wpBh710vuCiaH6Iel9+WFU53eEkcrm8zWnoGdsfVbJW ZndOSzh055ACy5hYHCxi2bYKm3tlD0QfKydxcqQH34Z0VIKazGMMw+aJG82iT7njVx5t/bgMqh8 OSMzvlQRZ2uLMkfWi5f+8ppVY37nKOfVMKeMfa76AZAxP0X0nfA6mh5Ip5Cbv73MmVSRIIRPiwp DGojtAffCT0Xvk9UqADTsYzTmY2KiBGoSRLPeN5SSwAZqTyYOctyOPEwom2ENbTR+FehG6J5sRF 5YlJBFriaDC/ITGBMPkZyyqmVxELE07tKKLIyA6oa1pR+blJtrjiCwoRBuiQsahJm5UTTQH035z i0ZwYdZt+Xng5z0fbSnby X-Received: by 2002:a17:902:ef06:b0:2f0:94a7:7538 with SMTP id d9443c01a7336-2f192c029bcmr304555ad.2.1796235938531; Wed, 02 Dec 2026 10:25:38 -0800 (PST) Received: from google.com (25.75.145.34.bc.googleusercontent.com. [34.145.75.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f0d537a522sm135519185ad.47.2026.12.02.10.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 10:25:37 -0800 (PST) Date: Wed, 2 Dec 2026 18:25:34 +0000 From: Samiullah Khawaja To: James Widner Cc: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Robin Murphy , iommu@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH] iommufd: avoid unsigned wrap at the top of the address space Message-ID: References: <20261202131400.2295591-1-jameswidner2@gmail.com> X-Mailing-List: stable@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; format=flowed Content-Disposition: inline In-Reply-To: <20261202131400.2295591-1-jameswidner2@gmail.com> On Wed, Dec 02, 2026 at 01:14:00PM +0000, James Widner wrote: >batch_to_domain() computes a PFN run's exclusive IOVA end using >last_iova + 1 even though last_iova is the inclusive area end. When an >area ends at ULONG_MAX this wraps to zero. The first PFN run can then be >extended over the remaining area while later runs are submitted with a >zero length. On paths that accept the zero-length continuation, the map >succeeds with translations that do not match the pinned PFN runs. > >Teardown reads PFNs back from the domain. It may consequently put the >unintended page installed by the extended first run while retaining the >pin on the intended later page. > >Compute each run size from the remaining inclusive distance instead. Stop >after mapping the terminal byte so the IOVA cursor is never advanced past >ULONG_MAX. > >The final change passed an instrumented current-source mock-domain A/B. A >semantically equivalent Linux 6.12 backport passed a separate emulated >device-DMA A/B. One million randomized arithmetic-model cases also passed. > >This finding, its tests, this fix, and this changelog were prepared with >substantial assistance from language-model-based coding tools. > >Fixes: f394576eb11d ("iommufd: PFN handling for iopt_pages") >Cc: stable@vger.kernel.org >Signed-off-by: James Widner >--- > drivers/iommu/iommufd/pages.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > Reviewed-by: Samiullah Khawaja Tested-by: Samiullah Khawaja Thanks, Sami