Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5094170rwb; Sun, 22 Jan 2023 03:12:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXv31T+EX3fHXRXV/ty2UYSpeiaONAqucOePgC9pZ12BxGSi7x/FgNMRBtGBL9wbCr8fS1pN X-Received: by 2002:a17:903:2442:b0:195:f06f:84ff with SMTP id l2-20020a170903244200b00195f06f84ffmr8773716pls.50.1674385959497; Sun, 22 Jan 2023 03:12:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674385959; cv=none; d=google.com; s=arc-20160816; b=EWkUDFGYFMiINdgSao1/LPKylTae3w4ownh0sgm93VPxxjBcmInYTxI/nqTS4j/GEH y3g/sVaqHheAu29cwA9Rxm2QVPET873+HOWPfq43FIaXGrEwOc4+hYdibStZhvnCYsNP lk0hdei+a5LBvu0ydVzd7GYou67t+qjqvmg8dYN0Gg04e+BH17vZHkZVjsjM1PUbiLlI 77IYdSjC84c5y7OUtDC3ShPiyoRaGH074+UUA/JF+Uh7k31CPCt1OijLhvrL6pRHAgli irjdIlf901CsjfnZEdr8s+5+uCf82aYbHk/heKE9zHyt6oO62AvflLj78LmxrCIOWSpq 82/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EhWx61TDavKtM7e3DTctYVggLBU5GDPImeNPYOubdH4=; b=E3TfMOQT/+EJkVVLBOeHyk3L0iInolH/SlCpp0x014oDN/Yj6GGhdFTvr4rmWxRimL n135laNqRRo+qpa5OHVSYdIa4Or6J5OCyQyzzV2jQ2+JJbV7JjdPpwVc9LAkWJH4C+LK MB6jZYv4wFl0AK/NCtvT447eOs4rB4bpz4EsBt1TNhph3Ud+X4pnpV1sAmLYSNmDpOkn A4E1/IfOJPqOJA7SxO2DHs2l3cQ05bYLAQKqSlY+uQdpmXIHqNKAdbo63wW5PcO3I3+t qsbve4i4zfh9WIL6m/lC4eV8PxWZPEuxUDnCzu2w9Q91AVVr2vN3SNTyFLm8SPvPNRBc jRCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lovkQmpN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y21-20020a1709027c9500b00175449cf6f8si2154566pll.606.2023.01.22.03.12.32; Sun, 22 Jan 2023 03:12:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lovkQmpN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229877AbjAVK6H (ORCPT + 50 others); Sun, 22 Jan 2023 05:58:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229675AbjAVK6G (ORCPT ); Sun, 22 Jan 2023 05:58:06 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE64D4C35; Sun, 22 Jan 2023 02:58:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8002BB80A36; Sun, 22 Jan 2023 10:58:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8154C433D2; Sun, 22 Jan 2023 10:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1674385082; bh=ByCGf5RX78/mkAxYc+ERxDI9C5SV6TUWVm84iW4jpDw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lovkQmpNtvJJX4n1F8dwQ3UY08y4kjSEABo67kjYmujM4DycY+4aPd5XKzlVYVmyU WpfCEBLzmjPUtsEUV5i31xViPi5dR00JP9FhheHmbROXHogySyE1uUCHX7YrswffOd duYKQpN6ilEDD7m56A5aYm9EdgOxedvYziLV2AMM= Date: Sun, 22 Jan 2023 11:57:58 +0100 From: Greg KH To: Leon Romanovsky Cc: Alexander Shishkin , Bjorn Helgaas , Thomas Gleixner , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Zyngier , darwi@linutronix.de, elena.reshetova@intel.com, kirill.shutemov@linux.intel.com, Mika Westerberg , stable@vger.kernel.org Subject: Re: [PATCH 1/2] PCI/MSI: Cache the MSIX table size Message-ID: References: <20230119170633.40944-1-alexander.shishkin@linux.intel.com> <20230119170633.40944-2-alexander.shishkin@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 22, 2023 at 11:00:04AM +0200, Leon Romanovsky wrote: > On Thu, Jan 19, 2023 at 07:06:32PM +0200, Alexander Shishkin wrote: > > A malicious device can change its MSIX table size between the table > > ioremap() and subsequent accesses, resulting in a kernel page fault in > > pci_write_msg_msix(). > > > > To avoid this, cache the table size observed at the moment of table > > ioremap() and use the cached value. This, however, does not help drivers > > that peek at the PCIE_MSIX_FLAGS register directly. > > > > Signed-off-by: Alexander Shishkin > > Reviewed-by: Mika Westerberg > > Cc: stable@vger.kernel.org > > --- > > drivers/pci/msi/api.c | 7 ++++++- > > drivers/pci/msi/msi.c | 2 +- > > include/linux/pci.h | 1 + > > 3 files changed, 8 insertions(+), 2 deletions(-) > > I'm not security expert here, but not sure that this protects from anything. > 1. Kernel relies on working and not-malicious HW. There are gazillion ways > to cause crashes other than changing MSI-X. Linux does NOT protect from malicious PCIe devices at this point in time, you are correct. If we wish to change that model, then we can work on that with the explict understanding that most all drivers will need to change as will the bus logic for the busses involved. To do piece-meal patches like this for no good reason is not a good idea as it achieves nothing in the end :( thanks, greg k-h