From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA34936A344 for ; Sun, 26 Jul 2026 16:20:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785082853; cv=none; b=YZHbFLgyRqLXku1TtyGRqen+KQRtBbwih9WSNVqWBT2Kwab2iTZiWwuULB4+JJBWSLNIAWRdw7sXU7qQwBBzcsIpvUhKC61LIaMSSQrZ76Z774zpfCCS1jZ07Jd8mrumMNrfornMLBZPHtGyG+uu+QD1BCqgQ7sa3awl+qT9pvM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785082853; c=relaxed/simple; bh=weMclR0JbsCcCqPg/uiyIcYyJq2ObcwTZTr15YLIsZc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=i3C8wwgbC0lmlFROS3/3L4Mc+YhGW1+ojCi6lBEEFpkPlj4k9BHs510UNrekKQ4MmfW2RYnhCf6oNv4/F2qVKy6PdA/OaXmmgACbefI9DI8Sk2+s6w8V8DVzs8m0NLQzVkKYstLGuuZUqk602MAIIzNyExS3Emb0msr6kax5SR4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=aRKFtZ0G; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="aRKFtZ0G" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2cedda2ce6fso16439815ad.1 for ; Sun, 26 Jul 2026 09:20:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1785082850; x=1785687650; 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=xYJV2WaFKQ0XZvcTBC+xPmoK69d/4/DPGZNWJ9OK0BA=; b=aRKFtZ0GJHrHpuqfvgmauuVULU5WKy+KGy3cOAVR1mgQBRvm/iSX0/WCP36wpnVbtY 6rcTV6s3+Ia4wTNM6zssepggNdWhDa7Yw4CM+RjI1XLGQy3dVx/rOadhfje4Zl0qmLOZ zZ0nQ90jZQe0XOHXH66+EUbZJJOS3emFwNB8heI+3IIc9QYQRZTmwlDlmdRpQXP0kSGH Cy0kiYAmgGOXG4SAKsN9xLHOD/H8mnIiNLJ54oapbbs1ixU5eWqPnNJVmV3Felm8T7ws olnTG7wNF4g9oR5WvcJGqivS5sW5phqgZFAD1S69POvoJmkW/Hrz4zUCXRjgr0BDBabm jzJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785082850; x=1785687650; 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=xYJV2WaFKQ0XZvcTBC+xPmoK69d/4/DPGZNWJ9OK0BA=; b=XsYhJXdyaubl1JFdnlZ5dXcTpm5kM31UTfy0y/k1ZYGga0O6WXHYq6Kg1J4EEWE2Vm b3BW1i5nikcoxSDCdroI59HP9enU/c+cFfgk2dIbP13R9b+BeLkoCjtXHzB5TUqtjTcY eC4xkm4+HZMeBfY/BX8Uchhk2ZLfhtXROUDuQT6RFyqTX/E3m1lgWHJXu1ErBEThVa0U hsZ720a5kVfrVhfj0x6Lmg9uaPTZtNMdnEo8y9Mv7fkxnpIgzg1UovuiLgDwYhIrJQHv gsfo+MaaWFviqcBiYn+LEef/JULgu2YmCN1/LjkUUee6MJ1IdtIpHmD6nmvWoMeF4cqk LmVA== X-Forwarded-Encrypted: i=1; AHgh+RqN0L8zwG/Kj5CPU6WgqNu/A/3Sc1Q3rQRGrooRAlexrwDkUVQVblGo1aV6YUnmDPTVD8TaGD419F+6j54=@vger.kernel.org X-Gm-Message-State: AOJu0YxILc0AXlrmsqZ5XHJo0NZN7FciksPzUGS2I3QMdnv8lzIy2n/C 7H6tZQ+WIuTrrDpcQskkMgn9QJNZNhatIo27D9uHXvAtXy/vH9Occy4UtKDGIfOHvgkwIoZ81NN wz/K0 X-Gm-Gg: AR+sD13b+0fIjq+WDgbW1fEA4tObpoZGiUkyFCNZiAdtBat3LyGWqJ3qL583Y8Jf88p 8cY196b9z1Cw4B5uk5BhN1OBoub6Mcd1avbSjnRPhevkL5WsSJedeyAW2V5jVuFYVjrpg8B1oeu njb/GvmswJV0fsAaKdBS0tX+kil/2mp6shBvykykJlE2XVDrGvsumTKgRPMi47EFZhlJsLmLzSh 4USoSAKBgWgwD43dUcI6EajGYSJhWAuI/sHoQ3Rb9fiG7+ODkEu5jL0XfVFxmw+sip+LBgf3tyC s+FU12KzGVo7a7hL5vE4XYDi0jaELa6ig8IYylIlrkurie+ctG59M0nQMRG9Z0NTz9t3gt0WuGT 4JgxrmXVYltHDSS2TZ69fYtq8yxFweQpCcX6WixvUhcOB6M09dvo= X-Received: by 2002:a17:903:98f:b0:2ca:9d5a:8b6c with SMTP id d9443c01a7336-2cfde68785bmr51728885ad.5.1785082850240; Sun, 26 Jul 2026 09:20:50 -0700 (PDT) Received: from ziepe.ca ([64.114.68.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cfde81cd27sm22021795ad.79.2026.07.26.09.20.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 09:20:49 -0700 (PDT) Received: from jgg by jggl with local (Exim 4.95) (envelope-from ) id 1wo1ar-0001SV-DZ; Sun, 26 Jul 2026 13:20:49 -0300 Date: Sun, 26 Jul 2026 13:20:49 -0300 From: Jason Gunthorpe To: Peiyang He Cc: joro@8bytes.org, will@kernel.org, kevin.tian@intel.com, robin.murphy@arm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, baolu.lu@linux.intel.com, stable@vger.kernel.org Subject: Re: [PATCH v3 1/2] iommu/iommufd: Fix IOPF group ownership UAF Message-ID: References: <20260720085017.3998878-1-peiyang_he@smail.nju.edu.cn> <3CFD314D0FE4D7EC+20260720085017.3998878-2-peiyang_he@smail.nju.edu.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3CFD314D0FE4D7EC+20260720085017.3998878-2-peiyang_he@smail.nju.edu.cn> On Mon, Jul 20, 2026 at 04:50:16PM +0800, Peiyang He wrote: > iopf_group_alloc() links each last-page IOPF group into the generic IOPF > pending list before invoking the domain fault handler. > iommufd_fault_iopf_handler() also queued an accepted group in the > IOMMUFD deliver list without removing it from the generic pending list. > > When detach or HWPT replacement drops the device's IOPF reference count > to zero, an IOMMU driver may call iopf_queue_remove_device(). That > function responds to and frees groups through the generic pending list > without removing the same groups from IOMMUFD's deliver list or response > xarray. A later read, response, or cleanup can then access the freed > group and cause a UAF. > > Fix this by dequeuing an accepted group from the generic pending list > before IOMMUFD queues it for userspace response. > Make iopf_group_response() send a response regardless of pending-list > membership, so the dequeued group can still be completed by IOMMUFD. > > Closes: https://lore.kernel.org/all/B4F28798E2E784CA+d29f723c-b2b5-4b67-8d1c-4f7b9b0b27cb@smail.nju.edu.cn/ > Fixes: 34765cbc679c ("iommufd: Associate fault object with iommufd_hw_pgtable") > Cc: stable@vger.kernel.org > Tested-by: Peiyang He > Assisted-by: Codex:gpt-5.6-sol > Signed-off-by: Peiyang He > --- > drivers/iommu/io-pgfault.c | 24 +++++++++++++++++++----- > drivers/iommu/iommufd/eventq.c | 2 ++ > include/linux/iommu.h | 5 +++++ > 3 files changed, 26 insertions(+), 5 deletions(-) Applied to for-rc Thanks, Jason