From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B49C308F1D for ; Wed, 4 Mar 2026 07:20:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772608842; cv=none; b=OybSwcMl/IYH+2O0eRFI0gJNH4wpukx/gyyBSsfxELOCSxMMblxLd+WJbLQ68lEFjgRMf8KUov2Jj6oQ9rvUHSiBuiPdKOduRbPfCt45I76+xdsqTqhzp5rUHqbMFI14/8OV9tWcB+qqkAlZv4cs7rlob0ySFTmtk3Dp51hbQDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772608842; c=relaxed/simple; bh=D6GYEd3d6gvnRsSCgzPjSlNov5PrrHCdZ5y8IBebYA8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D/5FkAdmZdWBcLHtiRGOTV44Ct7Vny/uIUPAW3CQurwbU+FdfAYVwnj1VOKN1PKlu8rAxXYx5ysKP4OFVpO7OMeOFKsBS2TYGmIMVwIwr83ZIAHlv3baDliWj77IBTesZ90RG/kbZUGLCRnSXE8G1ddsuWwmOzCB5L6QcP6+rsM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jNWDJEWT; arc=none smtp.client-ip=198.175.65.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jNWDJEWT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772608840; x=1804144840; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=D6GYEd3d6gvnRsSCgzPjSlNov5PrrHCdZ5y8IBebYA8=; b=jNWDJEWTUiHLS4JQeMBoSh3iklnL6nY7R39nnbCTUMj1bjrPZVssUaog SV2jpk1UqKvWEj4Jbfzc6xqDxtk2etkIo57zNsNs1BQACh3JkXG0Fp16G ijsGUfKe4yN5aPLM8g/33LSmEuDSp9YAo/HNRvG+CzmoEOmAlKwiJY+KP zyoqce7a1jhc/hhVxX5XFt9WfhvzeXW/AsL/PCFq5mkKlSkNqvBK1JW5/ tcmA+defJ1n4C50R80qmWfeHj5s1RcEWK5Vdj62H5zOOvNAVrNAB8mVTc jD2WV6eomDGeBMtXpdc45Re840CHIHThrZLIA7n0Je9Kvd0E9y96R2uQ5 A==; X-CSE-ConnectionGUID: Kpt8/4GGTIe6rY08Qj6rNg== X-CSE-MsgGUID: tZ0DtjHOSKyQzzc725Upig== X-IronPort-AV: E=McAfee;i="6800,10657,11718"; a="77268457" X-IronPort-AV: E=Sophos;i="6.21,323,1763452800"; d="scan'208";a="77268457" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2026 23:20:29 -0800 X-CSE-ConnectionGUID: Rg4hloOgT4eSbbO7WSHaNA== X-CSE-MsgGUID: 8gdJvCT/Tuy8Xmcr03vmSw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,323,1763452800"; d="scan'208";a="248733762" Received: from allen-sbox.sh.intel.com (HELO [10.239.159.30]) ([10.239.159.30]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2026 23:20:27 -0800 Message-ID: <3b745716-b24a-46be-95a3-fe1e34e005fb@linux.intel.com> Date: Wed, 4 Mar 2026 15:19:48 +0800 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH rc 1/2] iommu: Do not call drivers for empty gathers To: Jason Gunthorpe , iommu@lists.linux.dev, Joerg Roedel , Robin Murphy , Will Deacon Cc: Alejandro Jimenez , Janusz Krzysztofik , Joerg Roedel , Kevin Tian , Pasha Tatashin , patches@lists.linux.dev, Samiullah Khawaja , stable@vger.kernel.org References: <1-v1-13a02eb0e031+a5-iommu_gather_jgg@nvidia.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <1-v1-13a02eb0e031+a5-iommu_gather_jgg@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/3/26 06:22, Jason Gunthorpe wrote: > An empty gather is coded with start=U64_MAX, end=0 and several drivers go > on to convert that to a size with: > > end - start + 1 > > Which gives 2 for an empty gather. This then causes Weird Stuff to > happen (for example an UBSAN splat in VT-d) that is hopefully harmless, > but maybe not. > > Prevent drivers from being called right in iommu_iotlb_sync(). > > Auditing shows that AMD, Intel, Mediatek and RSIC-V drivers all do things > on these empty gathers. > > Further, there are several callers that can trigger empty gathers, > especially in unusual conditions. For example iommu_map_nosync() will call > a 0 size unmap on some error paths. Also in VFIO, iommupt and other > places. > > Cc:stable@vger.kernel.org > Reported-by: Janusz Krzysztofik > Closes:https://lore.kernel.org/r/11145826.aFP6jjVeTY@jkrzyszt- > mobl2.ger.corp.intel.com > Signed-off-by: Jason Gunthorpe Reviewed-by: Lu Baolu