From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (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 021443596EE for ; Fri, 9 Jan 2026 09:27:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767950830; cv=none; b=DLWIOlcJao+tjCjBav0BmUq/4rwmVKy6cGbJhOdCWz7McWGHnELazpXAp91YCu4HEv67ymHZ0EEftyiZrNO0oM+kuu4LI7viO9sTfn5L3apw9hH1OHog9mWG+ZpN7M4j9dGEHDFoDcM41TUQKLsO1NM401cWQa09m8dHpR5EgfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767950830; c=relaxed/simple; bh=ttAsDYBjr9+AAKnLH15MfAvzPA3bn3B6sE13eniF7OA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZUtnnyZDAe8i5BzATYSes0uRS9MnCQE1ES4eEKLNfIl4QEmh3YLS6LMjnAIDsOfVs+BCLLWQ5yspPj0nNomrihOJpFxxoex0wQNcsOGwyfR0M7vSQ54pKQzfgZJkub9AGudTJCQwNKGYwD6Vf0Mh6bd67Rfcv66fUcgm9gx5zIQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=VXtPCYIy; arc=none smtp.client-ip=209.85.221.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="VXtPCYIy" Received: by mail-wr1-f65.google.com with SMTP id ffacd0b85a97d-42fbbc3df8fso2024120f8f.2 for ; Fri, 09 Jan 2026 01:27:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767950827; x=1768555627; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=Z056gdaBGJYpZh5RAuVD8uudiJ6oWt4yO8116qnzGIA=; b=VXtPCYIyzZonjtCMMy45Mjr9o8nmfCC6K003XEWEWP1f7XskKF+EIbv7ncZHesFnhR PwlN+gkVbgkd9YMnDuXxnud8dKDlngNzSOjC4jL6eDlLWJhiog//DuEoSIwTXpUKYkD3 6kLyftAgsc6oK8JscTccX+xhrwZPxs4GLYoDTwvmeTGTShyLTSLVx1zAFiCdJMHxdMZu S4UXk4msLDE5viQQt3bUprIdD4g+qWED4N8TNQqbdxxzsB8YJZOSQUJeuSME05FTKPTi CKRNY1ENygcGpDKQ3NUjYnAonfqAmTzBw0PK5Al8nCoiW0ZiZbp5zTADPccQ91K3QlMm LOcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767950827; x=1768555627; h=in-reply-to:content-transfer-encoding:content-disposition :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; bh=Z056gdaBGJYpZh5RAuVD8uudiJ6oWt4yO8116qnzGIA=; b=PNk9hgFXgRPtPoYC/R7K2QmzXIonsMJZ/ozAPAhR2XQrIQ4y+D4Kuwr/yaZ6tweLZz SOKofgo924G9mNXUv1/8d2ON0lN05VIltLkAT/asz67/VUcxzC7wx92T4EXlcOIo/d0A CymWJewE4shYmCnO0OX1Prga7Dyjs81UW4i2UErsBGrFQPgNTxQcWrXInt84a9a4mbtF uxVLZdErF2SpNAja+W0cvBBCmOhnJV1bDZ9yPOTBiFwLk/aGd5Y2xa8kk2oQVTUqheHC vZ2M0vUfpBNP4WJQuHV/spancamTvk4JSnevxe6BluZxvTrXFZqegL9daL8h5NX2+kjR 4MGQ== X-Forwarded-Encrypted: i=1; AJvYcCWsZp1mM4X5h9l8w7qpTlATRjS/eaJZqrihHjhKOPk0hsXYag2x5J8Gaeert5aEJNW+7n1qQ0CPkxQoG2c=@vger.kernel.org X-Gm-Message-State: AOJu0YyX/aF3tZnAC/n+h1a0nCN/kZks1sIK/W02isHXr7vFjs6wuyMa lr554nGa1tLYhGUD8qfTQtZQjYiXphwYteFtxI6vpbHqHXH/BpwlkgA0dYTIYal3pbs= X-Gm-Gg: AY/fxX76nBWR8B+MtFyx2M61ICGPvUGIYfdRUa7oz7+EgDrssBl7Hi47mskFjO+8j34 iKVoqhyt0CnfwItQ7WBNWtG9GpPJXJZXgj/wk3wh7vBDKnaPjy6Z12INJKzbc0GJd2baY+5rZKN QWoJkl8dUWhbuzk/xSh8u8TxvDhTdrP3F43+txLR7mHRyhdfv9ROaQz9mziK5bjvKuYXoxOM2HX Fy55msPJM8VZuxTWyJMzLpQw7owr3m64kVUQBHNsi0F/075trPA8XKat54ZFeZM1rlv0m3nlKX5 GlFtl4HhfPXtqXa5xTinQFZJWoV54spSh6r0bh39huNGMEqSnomDvIqGzzDQlN++SYAzih9u95g STD4OQXLu/NA12QDRWCS2vEJAxN8q/gQXHgaJxsSW1J3GuZWyPYfLn7Qc+j0TY1uh2e0N+u9Kst xIJMIItNTfNFanjd/K X-Google-Smtp-Source: AGHT+IHGEE558Ypawf1N0D/PfF+kFXDSmDZa1cnIjVVu45cBHmCPRkreIC0JvO646k8QflO4jCUK0w== X-Received: by 2002:a05:6000:26c2:b0:431:8f8:7f24 with SMTP id ffacd0b85a97d-432c379d19emr10849333f8f.39.1767950827126; Fri, 09 Jan 2026 01:27:07 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0e19bfsm20920486f8f.18.2026.01.09.01.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 01:27:06 -0800 (PST) Date: Fri, 9 Jan 2026 12:27:03 +0300 From: Dan Carpenter To: Dheeraj Kumar Srivastava Cc: joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org, robin.murphy@arm.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Vasant.Hegde@amd.com, Sairaj Kodilkar , kernel test robot , Dan Carpenter Subject: Re: [PATCH] iommu/amd: Use array_index_nospec() for rlookup_table index Message-ID: References: <20260109052040.938-1-dheerajkumar.srivastava@amd.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Jan 09, 2026 at 02:19:03PM +0530, Dheeraj Kumar Srivastava wrote: > Hi Dan, > > On 1/9/2026 11:35 AM, Dan Carpenter wrote: > > On Fri, Jan 09, 2026 at 10:50:40AM +0530, Dheeraj Kumar Srivastava wrote: > > > Use array_index_nospec() to prevent speculative out-of-bounds > > > access when indexing pci_seg->rlookup_table with a user provided > > > device id. > > > > > > Signed-off-by: Dheeraj Kumar Srivastava > > > Reviewed-by: Sairaj Kodilkar > > > Reported-by: kernel test robot > > > Reported-by: Dan Carpenter > > > Closes: https://lore.kernel.org/r/202510281233.q4cBnp3z-lkp@intel.com/ > > > > This is interesting because more and more people are using lei to > > recieve email and now they get unfiltered Smatch warnings from zero day > > bot. > > > > Normally, I just ignore these warnings because they're hard to review > > and I recently modified Smatch to stop the zero day bot from warning > > about them. > > > > The problem is that I've tried to contact people from Intel to help > > review some of the warnings but I've never recieved a response. I've > > heard that Intel has a handful of people that deal with Spectre v1 bugs > > but I've never seen any evidence of that... I've never tried reaching > > out to AMD. > > > > > --- > > > drivers/iommu/amd/debugfs.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/iommu/amd/debugfs.c b/drivers/iommu/amd/debugfs.c > > > index 10fa217a7119..4990f6db99ef 100644 > > > --- a/drivers/iommu/amd/debugfs.c > > > +++ b/drivers/iommu/amd/debugfs.c > > > @@ -174,6 +174,7 @@ static ssize_t devid_write(struct file *filp, const char __user *ubuf, > > > kfree(srcid_ptr); > > > return -EINVAL; > > > } > > > + devid = array_index_nospec(devid, (u32)pci_seg->last_bdf + 1); > > > > This is debugfs so it's already root only. The cast to (u32) is > > unnecessary. > > > > I agree that the (u32) cast is unnecessary here and will remove it. > > When you mentioned that this is debugfs and therefore root-only, could you > clarify the context of that comment? I just want to make sure I’m > interpreting the rationale correctly. > Debugfs is always read only unless you are root. Anything else is insane. So it's like sure, this patch is correct from a correctness point of view but in terms of is this exploitable? No. regards, dan carpenter