Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3729588pxf; Mon, 29 Mar 2021 09:48:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5rQIfjlwfEaetNiVtqI3PB//k6Q9ZEBjC3KbpbKVnv2t6IGsxuKXFgxvCmmGhlmx/ahfg X-Received: by 2002:a17:906:4955:: with SMTP id f21mr30574974ejt.74.1617036494135; Mon, 29 Mar 2021 09:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617036494; cv=none; d=google.com; s=arc-20160816; b=SGnIpmn8UmngWpkOzULZ0PIwqc4CLRf3nBwlJrxvSgWR8Z8N32x/P/G2vOo0SEJogT JoF2rn7rWdNOVmCmNa6jzZY40KTBYJIvNJJxZv4DKJ+mipBT5BO3QFZSgZUoisjy7Iss MFLSQxVFoF+kRemo1CABkBkEOPnsQCKzYB333CscX2gdBjTl/FloL//YWSUDYCibu6zI qZwTqt1CD+HiZjcKFDezw39W9YhRw6kr6rc41iFomajwkX7D8aBw9RBcJTjDrj6oT9tX kkW9L5XGJ6g8kQtPofRNfGfzhCIjpvbfQIot8T+RwOUNKH20+xwrT+ZgCr5gddbH7qJj 9D2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=KgBMGmQCGLl4y6Xk9OO++PqGivhTIXsjSzI0EdEG61Q=; b=jaGbO/JnGyc6fS73xff8MuowtvDuTXXtBaaX49ctO3SeUeXL9TQdQwEnZjvGeB4SKo PDY9Fmv8uHlUgtU7iAW94RiqRxC9m67lhjVLzFef9Ui8T/QPRjKRmAULd/1bJH73iH6F /twdhuQPmnT7HkD4rXocPF7nuqiL7lSml1BACvGN1vMkkf+JRC+pSQ0z+mgvEDib9prE gu4PrrWSrsY8cRvTId37rGQrQP+FlhWiJ1juc6JWYKRRU2PcpHPdSZmW7M7k2fWq6XuG Tqu2AGS2+PwzzhXuOk6rPt4XKNDb3FCgyd07SZhNu5YyR2D3ojqPQhcbZQfmr1100b37 DZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ywebtNJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si14451894edd.474.2021.03.29.09.47.51; Mon, 29 Mar 2021 09:48:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=ywebtNJM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229502AbhC2Qqy (ORCPT + 99 others); Mon, 29 Mar 2021 12:46:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231332AbhC2Qq3 (ORCPT ); Mon, 29 Mar 2021 12:46:29 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07980C061756 for ; Mon, 29 Mar 2021 09:46:28 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id u9so20490637ejj.7 for ; Mon, 29 Mar 2021 09:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KgBMGmQCGLl4y6Xk9OO++PqGivhTIXsjSzI0EdEG61Q=; b=ywebtNJMhasTzI8DQPJIXLfRgTk6bwco/TQMbndr0OHObnM7O4Y9kwZmHtl5ok9xP0 XcL279cusq6h6HSkXzoTCy7glcdQwu5mqlM9Whhche7cFxk/LefL5r+5I789+WbABUkL FJ3yWGVK1eTB70vLHW8r2spfIOa5lxvZeaFGZ+br9VkfDBRHvGmHcHClJ3TDlztK2ucS BvQtl+0wzNI3PqOaFGvsso3W9KsFm9MolKUfy7Cy3pPJ5VhtFOd4eJETkqcPRJgfVzM2 t2xATKb8hI0+gWjDzCXpHVkBv9yOs++/HvjuymdxdgP+7vqRBHI0AnQvQTuVdDV1Fsw9 LA2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KgBMGmQCGLl4y6Xk9OO++PqGivhTIXsjSzI0EdEG61Q=; b=fLQU0JSEMRaeprm3tYqJEdE8p0E/xl7ldDh/MHfTe5hFFdg0Y5yQKdsP5MSYHGnoZT mdyCNP/IhaHwWWDlaKykc2+cNRqjCREo7K5a2qyTWjQWbe+yBFyIiygnV7n42Ivu/0qB AvVFi+wQZNvxPOKlLRIz3dAFw6lNsJ8v7m9UDMvy0VMnFGZJ9FokCJGzcx8wVDv1lQoq 7yvr9sda0BcvmBezHWOR/d1+8l+Zf4MC9KuEYakm8ZSPWHK7jPpNOnPBNHFKPOq8WT// MkkgKA6ggCe0rMF4oDi9DZqNpbrJ+L/67X/dpbm2AZ64fvgdQSIZXmrlKJXV/xjr+Xnn 1Zew== X-Gm-Message-State: AOAM530ZLL7yPBA566NUHsWeosfbixYKlWdPvsudhY2VFKqrzub+R0ud GCRMCvMd+RXLuuXiXvgrA0U7mzKUErT0OrgspHSoyw== X-Received: by 2002:a17:906:1386:: with SMTP id f6mr29091143ejc.45.1617036387736; Mon, 29 Mar 2021 09:46:27 -0700 (PDT) MIME-Version: 1.0 References: <161663543465.1867664.5674061943008380442.stgit@dwillia2-desk3.amr.corp.intel.com> <20210326161247.GA819704@bjorn-Precision-5520> In-Reply-To: <20210326161247.GA819704@bjorn-Precision-5520> From: Dan Williams Date: Mon, 29 Mar 2021 09:46:15 -0700 Message-ID: Subject: Re: [PATCH] PCI: Allow drivers to claim exclusive access to config regions To: Bjorn Helgaas Cc: Bjorn Helgaas , Greg Kroah-Hartman , Jonathan Cameron , Linux PCI , Linux Kernel Mailing List , Christoph Hellwig Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 26, 2021 at 9:12 AM Bjorn Helgaas wrote: > > [+cc Christoph] > > On Wed, Mar 24, 2021 at 06:23:54PM -0700, Dan Williams wrote: > > The PCIE Data Object Exchange (DOE) mailbox is a protocol run over > > configuration cycles. It assumes one initiator at a time is > > reading/writing the data registers. If userspace reads from the response > > data payload it may steal data that a kernel driver was expecting to > > read. If userspace writes to the request payload it may corrupt the > > request a driver was trying to send. > > IIUC the problem we're talking about is that userspace config access, > e.g., via "lspci" or "setpci" may interfere with kernel usage of DOE. > I attached what I think are the relevant bits from the spec. > > It looks to me like config *reads* should not be a problem: A read of > Write Data Mailbox always returns 0 and looks innocuous. A userspace > read of Read Data Mailbox may return a DW of the data object, but it > doesn't advance the cursor, so it shouldn't interfere with a kernel > read. > > A write to Write Data Mailbox could obviously corrupt an object being > written to the device. A config write to Read Data Mailbox *does* > advance the cursor, so that would definitely interfere with a kernel > user. > > So I think we're really talking about an issue with "setpci" and I > don't expect "lspci" to be a problem. "setpci" is a valuable tool, > and the fact that it can hose your system is not really news. I don't > know how hard we should work to protect against that. True, the threat is smaller than I was reading, I apologize for that noise. Temporary blocking over kernel DOE cycles seems sufficient for now.