Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp545482pxb; Thu, 30 Sep 2021 11:29:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5wv1u0mWqcea4qIC3ZaHHD4jz+++KSg6iJaqH1QA/32GEpCZ2p2KMul1zavZlxU3Cr83a X-Received: by 2002:a17:90a:e7ca:: with SMTP id kb10mr14648301pjb.33.1633026558707; Thu, 30 Sep 2021 11:29:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633026558; cv=none; d=google.com; s=arc-20160816; b=ByFUq+C233UslepncsMJlhkuYR26zPNIZZvr+I6izoRdZm2iEZYvEfkDb8PwVnKGQD dM2tRueBOVaCx9x52JV1GOqwtnv+q+CSgMTAN5UIUgjqXkvKN6yeE7Z5sUvJEHvsoLSt zuTiuvCUwi2L9AoSsrsDuSLH9R7aDrDPO7XVf/GQP9PwegW/TVIUuW1iEUUUCM3QC86W thc1yFXcqArWNZSbesY5/GNkiOS5OZHvbUA+bxdGijsKNPVMehuMDGvUxPsJVoidjtuh cjVgb/FGbSNmMSQYen/ozKeSfNTw7KnFMPdzf7HYoJ97X33vGInQqt1Tsh0F4p/ETgjM 1fzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=yqz6urE4RzGxays4Ew88ZQS7yo6biFi+U5zOoCFOxtA=; b=VpiesIuFeENZ8jf+af6hGw2aUkCjE4IpsxKgEunWO7XfALkPXW+4XLlMQmI/ilpvRN 0eyUmiVYVzYyFef6cnjyaqF50kTW/7MGRbMuAMJ9fyhEAlEvjpZUBFXiXBxtRDWVlq+7 ahyIKRVWVCH3DPYdhfKcSQMYOUsTCEUnvvsZxi7iD/21iF8ZUeKbNBFC/pBAwqk2hyqe T1Kq3rOD9GQC5HsJdXHRVvB3MAmkan6dy0uj6d8s3QFd+knepWDdUhqTMXjSbx+O3vIt b/UD0LU3jhP0ICwxWJmniPaJZ9Lg37KAz1VvIrw3lzxpYnE1VwVKuej2kd3/zcuueWkc OVQw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si4879594pgu.364.2021.09.30.11.29.04; Thu, 30 Sep 2021 11:29:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350332AbhI3Oou (ORCPT + 99 others); Thu, 30 Sep 2021 10:44:50 -0400 Received: from netrider.rowland.org ([192.131.102.5]:60717 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1350272AbhI3Oot (ORCPT ); Thu, 30 Sep 2021 10:44:49 -0400 Received: (qmail 465943 invoked by uid 1000); 30 Sep 2021 10:43:05 -0400 Date: Thu, 30 Sep 2021 10:43:05 -0400 From: Alan Stern To: Greg Kroah-Hartman Cc: "Michael S. Tsirkin" , Kuppuswamy Sathyanarayanan , Borislav Petkov , x86@kernel.org, Bjorn Helgaas , Thomas Gleixner , Ingo Molnar , Andreas Noever , Michael Jamet , Yehezkel Bernat , "Rafael J . Wysocki" , Mika Westerberg , Jonathan Corbet , Jason Wang , Dan Williams , Andi Kleen , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v2 2/6] driver core: Add common support to skip probe for un-authorized devices Message-ID: <20210930144305.GA464826@rowland.harvard.edu> References: <20210930010511.3387967-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930010511.3387967-3-sathyanarayanan.kuppuswamy@linux.intel.com> <20210930065807-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 30, 2021 at 03:52:52PM +0200, Greg Kroah-Hartman wrote: > On Thu, Sep 30, 2021 at 06:59:36AM -0400, Michael S. Tsirkin wrote: > > On Wed, Sep 29, 2021 at 06:05:07PM -0700, Kuppuswamy Sathyanarayanan wrote: > > > While the common case for device-authorization is to skip probe of > > > unauthorized devices, some buses may still want to emit a message on > > > probe failure (Thunderbolt), or base probe failures on the > > > authorization status of a related device like a parent (USB). So add > > > an option (has_probe_authorization) in struct bus_type for the bus > > > driver to own probe authorization policy. > > > > > > Reviewed-by: Dan Williams > > > Signed-off-by: Kuppuswamy Sathyanarayanan > > > > > > > > So what e.g. the PCI patch > > https://lore.kernel.org/all/CACK8Z6E8pjVeC934oFgr=VB3pULx_GyT2NkzAogdRQJ9TKSX9A@mail.gmail.com/ > > actually proposes is a list of > > allowed drivers, not devices. Doing it at the device level > > has disadvantages, for example some devices might have a legacy > > unsafe driver, or an out of tree driver. It also does not > > address drivers that poke at hardware during init. > > Doing it at a device level is the only sane way to do this. > > A user needs to say "this device is allowed to be controlled by this > driver". This is the trust model that USB has had for over a decade and > what thunderbolt also has. > > > Accordingly, I think the right thing to do is to skip > > driver init for disallowed drivers, not skip probe > > for specific devices. > > What do you mean by "driver init"? module_init()? > > No driver should be touching hardware in their module init call. They > should only be touching it in the probe callback as that is the only > time they are ever allowed to talk to hardware. Specifically the device > that has been handed to them. > > If there are in-kernel PCI drivers that do not do this, they need to be > fixed today. > > We don't care about out-of-tree drivers for obvious reasons that we have > no control over them. I don't see any point in talking about "untrusted drivers". If a driver isn't trusted then it doesn't belong in your kernel. Period. When you load a driver into your kernel, you are implicitly trusting it (aside from limitations imposed by security modules). The code it contains, the module_init code in particular, runs with full superuser permissions. What use is there in loading a driver but telling the kernel "I don't trust this driver, so don't allow it to probe any devices"? Why not just blacklist it so that it never gets modprobed in the first place? Alan Stern