Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2433408rbb; Wed, 28 Feb 2024 01:21:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVrVX2d4KcmC6EADLXWF31kxNYIQgxCnGAjDO6TdQaSnx0h3Nu5ITRby/4I1iRASeCrVlm9Y5p97lKrjCCA/2eDjEjiYslBlemmRJEMFg== X-Google-Smtp-Source: AGHT+IGsgS9YbW33FEnNqy1c2+3JZIL2jFkieG6eixGqbmqTRJHShsk0miaolLR8ubOQeQ2FLWwn X-Received: by 2002:a05:6214:27c6:b0:68f:5c6a:172e with SMTP id ge6-20020a05621427c600b0068f5c6a172emr5723686qvb.48.1709112104305; Wed, 28 Feb 2024 01:21:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709112104; cv=pass; d=google.com; s=arc-20160816; b=DfSAtHTJU6rey3eStXSv77qq8pm8zwT45HiMpdWkLCvOAjS6lkkaM6A/45zctHeMwE M5fod6PTF8mkCgip5WE+18R00JF6lRotrVbw7OVh+qpC0kwRXyAxbDOmrMWODwiFanxD L0o1H9dlOeJGbn/91vfjz9TyX2AeKT+N++CBQyDgkAUf716dAaDpckxnC8WJgkGh8X3E UM0T+El2d70mYS/04hLD53LfeiVgqMB4w/CLSp25UqJcp5ViL+1NuxaAm9gRHb6uhxoQ OR5hWA1jIHQ393k3PVw51pFTzqEI3oXZHo/2Z3VBU7T6KKPgJQHy2/3s7V4+WSlMTEBx +e9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=6kFPsFJMw5/+9rOW298zKEDiFT0i/B24+eA7lkn5oiI=; fh=/7zXNETWcKegmhnj+96BzU7oYM1NbWV3Wimm0TaMrMk=; b=YTW35cHM94KbGSOY1pgE62B29VRziUprM3xIuKVS/ILNshcHAdNrNslOKoy8ffg4QS odM2dW5rafFx7UVH4jeqn0Bh0UVWFChD7HK12Y4QubD4qV6L9n1gliyjvkq2wLQ6WZ8D F1Wn9+0mpDLq9TezmJQuSk9NzfcGwyf2CjvuYwQFkrHw9jmr67En6iV7bMWyfFMvAp/g XmD5cWLfcUXd8hI/5YJ0obti6AblttD8PznqMJ9nuTKyj64WPs4/LHdP89WQwGTccLox PKkt9BI2eeTHibA5BSlcPtqd5qVjnsL5/X4OiLFi8BX0D4CXVelXHkBXKtA7fKVa2jdX GxtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gJynUbTV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id iy10-20020a0562140f6a00b0068f45b756f5si9572141qvb.69.2024.02.28.01.21.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 01:21:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gJynUbTV; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-84753-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84753-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 732D61C25416 for ; Wed, 28 Feb 2024 09:20:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A27A821A06; Wed, 28 Feb 2024 09:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gJynUbTV" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CCEB22E64F for ; Wed, 28 Feb 2024 09:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709112012; cv=none; b=k1jOsG0eKBARfw1Ra7Lmbj6bK5vJ9l5X+WWH6K2DngS2BOHLFhxYG4WMbQHya2+YebdtvbZg5AzIg3+Za7olAR2D+ywqc/3tEmRnKeyOy8S1Sp5F8wjd2woi+89Mh4AKZycTEq6vA+CLoIMLKZfjexEgFZbzOuQBfiUgmtlNCfY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709112012; c=relaxed/simple; bh=HnyQ8g0HLMtXdCZ8EJhrVdx4C/CLJyXQkFRs51GeN3o=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=DduTfKwgw3VcgpOh+6Nc6WW7c9nHNHEFWFZSZRE9MrXk8FK4FGfvC0S2mBf3gu2i/o8/Eeti36DdC0rkJ5kDPvF3skX9NoOFYI9M4vwVXY2BAmdQFjJZL9l5IsaKOXjq7fsrvn6OpVcyIoGLWnWIVJqs+4H+U0Vxaw4+uupbzx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gJynUbTV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3338C433C7; Wed, 28 Feb 2024 09:20:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709112012; bh=HnyQ8g0HLMtXdCZ8EJhrVdx4C/CLJyXQkFRs51GeN3o=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=gJynUbTVCFxqBN9o2Wnyssp2HwEVYmz+PwITJtV8iHWL6Ts0bHCKq9ICqNix4aeSh CGIlzDPa/q6VCjJ0nZXRuaZTxMUiiunVxo6bT7EpoSznv4y6QdkQl2SBEorMPQSFL3 9aZK34wNXZ4MJPKLC1DsYh+VK8MTxDsI2+UNOdI+Yc5EDB65m9QBTSsqV2ddiCnVFB hd+ERmqEoyJa/4nIqO72m3MuwoMOX4uiqE0wyp5PwAgMBUNRLft5h3Hz8ZPyX5s9pf 7IILd2js0y8hk+vapT7qCCcYBRtJ/TaRycuaVFpWeMMNkcP0Bcuuwft5Ig8zgMEi66 fVTDid9TGgVtA== Date: Wed, 28 Feb 2024 10:20:13 +0100 (CET) From: Jiri Kosina To: Greg Kroah-Hartman cc: Bjorn Helgaas , =?ISO-8859-15?Q?Carlos_L=F3pez?= , cve@kernel.org, linux-kernel@vger.kernel.org, Bjorn Helgaas , Jonas Gorski , Andy Shevchenko , Mika Westerberg Subject: Re: CVE-2023-52466: PCI: Avoid potential out-of-bounds read in pci_dev_for_each_resource() In-Reply-To: <2024022706-kindle-tapering-5f66@gregkh> Message-ID: References: <2024022709-magazine-handshake-50da@gregkh> <20240227150744.GA235367@bhelgaas> <2024022706-kindle-tapering-5f66@gregkh> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) 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 On Tue, 27 Feb 2024, Greg Kroah-Hartman wrote: > > 09cc90063240 ("PCI: Introduce pci_dev_for_each_resource()") added > > pci_dev_for_each_resource(), which expands to: > > > > for (...; res = (&(dev)->resource[(bar)]), bar < PCI_NUM_RESOURCES; ...) > > > > We compute "res" before the bounds-check of "bar", so the pointer may > > be out-of-bounds, but the body of the pci_dev_for_each_resource() loop > > is never executed with that out-of-bounds value. > > > > So I don't think this is a security issue, no matter how > > pci_dev_for_each_resource() is used, unless the mere presence of an > > invalid address in a register is an issue. > > Ah, yeah, now I remember, stuff like this was fixed up in other loops as > just reading off into the wild can be a speculation issue and so we had > to fix up a bunch of places in the kernel where we did have "invalid > data" in a register. The code didn't use that, but the processor would > fetch from there, and boom, speculation mess. There's a whole research > paper published on this type of thing somewhere... Greg, could you please elaborate on this? Where in this whole construct do you see a potential for *_uncached_* (!) memory access that'd cause CPU to speculate into the wild? I just don't see it. Thanks, -- Jiri Kosina SUSE Labs