Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp480499ybg; Wed, 3 Jun 2020 06:00:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDTmrVl03u1+NhDLxLwu0xu4acLmBxauwxjMH/b4TdaPdX9DL50VjcyaO5y2ygsN1SCazw X-Received: by 2002:a17:906:4cd9:: with SMTP id q25mr28933104ejt.175.1591189221057; Wed, 03 Jun 2020 06:00:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591189221; cv=none; d=google.com; s=arc-20160816; b=koqwFpIywI545Vb4ovPI6Yfenmj0NDPmD52Mw+L/tl+rJbSs0ElfILAifjbfy9yvK1 Tx0GSEKj/ETvtk0bVGPP02/Pa2JUHXMvUqgSCvtG4l2+9bfFcLuuJm6/zCQQY3eKE1k0 gKx34BJG89cUaxLVlybSxorfUbP+gM1z3tBYSfyBGit1CtJ/N1FaT7JF5PoBolN2iJLm WQy0vt8L6y5QqccZ9AmShg4d7Nt0SYTFeFTo6YMW/ETMc51Q7Kw0/r88dQiZ1d6BXGte Ng61FoGOZ+51uIs1oEZerbuElAmi1vl3gBULI8eJQsSVUGkTgM3aR6K/NzT6wxKNhlEQ N+KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=dCxVfxCrSSvJ1heapBVBhtwf6LbvPjf1sTBIQx1UBaM=; b=LY0tVQnCZmtcJ5qCFMKXUC14tXCe/GDp0OWoxygV5P6/SLwh2D9S3QHpp5nPIZiiTq ZitDTpR0pQKcI8ZEYD1HZPmcDegT8PE+IzRr2ecvztuW1D1D9/f7QZbqU6u0cd7UgDHk 3/0bskLmVvbNbzNi9ZG/wKajFKi8LQm6QuVxGevGAXKzNORjU4Hnce4DnESz97TQbYXt VKNIMNjXQqzV188lahEZDHHIc+0aaGoX/RyDlnqT9cz3vPZAEouse5sLSvVBWsZ21NWs YW6qqkV8SGwhnpGkrgWXVZbK1LVk71dUuwLW2CuMcxIlnRUvZfm+tEnlIGPZzXo04i+j 9+/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IQUmjbdC; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si1106312edi.491.2020.06.03.05.59.57; Wed, 03 Jun 2020 06:00:21 -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=@google.com header.s=20161025 header.b=IQUmjbdC; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725917AbgFCM5n (ORCPT + 99 others); Wed, 3 Jun 2020 08:57:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725833AbgFCM5m (ORCPT ); Wed, 3 Jun 2020 08:57:42 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E24AC08C5C1 for ; Wed, 3 Jun 2020 05:57:42 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id r125so1225169lff.13 for ; Wed, 03 Jun 2020 05:57:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dCxVfxCrSSvJ1heapBVBhtwf6LbvPjf1sTBIQx1UBaM=; b=IQUmjbdCDziM8wOcD5JwWxDWgCqYExkvwyTsNu4BaU5djWrB/6LZr5jocRhVSLt02u ss6vOIas9V/vMnYoRwNZWxX17OjcnTaCHJSzWAGCMJ1tQyHXIHTSkI8pdZro2Vs9TmJC ddhvuSG85jXvqykzYV+OyrsGIdePfWkqlTfXGyRNP6AFeBK9SU/UNOvMV7wNe2sxGHsZ FIo8hcWOjb6p6VYSWTrzkAs2akFq73RT+1iU82MqyvzCXaX8iOXTVh4iHFUQX9iKP67M iJVBizLXZ1bDRIRgaNJoBrUvn1yF+74hPocpaLC9OEuyqj/G7HX/WFTGEC5PkKEt90qF IGbg== 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=dCxVfxCrSSvJ1heapBVBhtwf6LbvPjf1sTBIQx1UBaM=; b=X6580dfdjZ2G4e3fFiHLyTs9YtfrkMPQAoGPhp7JF1F0nO+Dl8idhFyhE2dnK0EkHT /UL0cnmvJurCZsEKLfK8rF7jGaV76RP5XJ8t2J71563lmA107otU4CA90L2Cd9V1BBd6 RTOnAyu7LLQm5TxBgUbTr1vZ2LbJ1BW32iTBkZTWrfasdXidGizuL7HZVUg6IJClTGnc ZVQw7yh6nqyesjrCXTHow/qokbkAXidVRTInS7R7rrTnMjR978Njgg07W3LEl4iKPJ5i zZ4rMhAmNUES3m6SCl6OTrGSaJh4Ibw5XXPlonhYJWE+p3rpnF3SFAOJni1XWNT0n5Qi YGbA== X-Gm-Message-State: AOAM5318OnoSxyXnq/v7joI1EE13gYkN0VZ1xqwKS6ajGzXrAfKZN+C+ TWmsEYuIKc3InyjxDRQxnSmxfma+numuh35RF4rmUw== X-Received: by 2002:ac2:5473:: with SMTP id e19mr2412645lfn.21.1591189059461; Wed, 03 Jun 2020 05:57:39 -0700 (PDT) MIME-Version: 1.0 References: <20200601232542.GA473883@bjorn-Precision-5520> <20200602050626.GA2174820@kroah.com> <20200603060751.GA465970@kroah.com> <20200603121613.GA1488883@kroah.com> In-Reply-To: <20200603121613.GA1488883@kroah.com> From: Rajat Jain Date: Wed, 3 Jun 2020 05:57:02 -0700 Message-ID: Subject: Re: [RFC] Restrict the untrusted devices, to bind to only a set of "whitelisted" drivers To: Greg Kroah-Hartman Cc: Rajat Jain , Bjorn Helgaas , "Raj, Ashok" , "Krishnakumar, Lalithambika" , Bjorn Helgaas , linux-pci , Mika Westerberg , Jean-Philippe Brucker , Prashant Malani , Benson Leung , Todd Broch , Alex Levin , Mattias Nissler , Zubin Mithra , Bernie Keany , Aaron Durbin , Diego Rivas , Duncan Laurie , Furquan Shaikh , Jesse Barnes , Christian Kellner , Alex Williamson , Joerg Roedel , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, Thanks for looking into this thread. On Wed, Jun 3, 2020 at 5:16 AM Greg Kroah-Hartman wrote: > > On Wed, Jun 03, 2020 at 04:51:18AM -0700, Rajat Jain wrote: > > Hello, > > > > > > > > > Thanks for the pointer! I'm still looking at the details yet, but a > > > > quick look (usb_dev_authorized()) seems to suggest that this API is > > > > "device based". The multiple levels of "authorized" seem to take shape > > > > from either how it is wired or from userspace choice. Once authorized, > > > > USB device or interface is authorized to be used by *anyone* (can be > > > > attached to any drivers). Do I understand it right that it does not > > > > differentiate between drivers? > > > > > > Yes, and that is what you should do, don't fixate on drivers. Users > > > know how to control and manage devices. Us kernel developers are > > > responsible for writing solid drivers and getting them merged into the > > > kernel tree and maintaining them over time. Drivers in the kernel > > > should always be trusted, ... > > > > 1) Yes, I agree that this would be ideal, and this should be our > > mission. I should clarify that I may have used the wrong term > > "Trusted/Certified drivers". I didn't really mean that the drivers may > > be malicious by intent. What I really meant is that a driver may have > > an attack surface, which is a vulnerability that may be exploited. > > Any code has such a thing, proving otherwise is a tough problem :) > > > Realistically speaking, finding vulnerabilities in drivers, creating > > attacks to exploit them, and fixing them is a never ending cat and > > mouse game. At Least "identifying the vulnerabilities" part is better > > performed by security folks rather than driver writers. > > Are you sure about that? It's hard to prove a negative :) > > > Earlier in the > > thread I had mentioned certain studies/projects that identified and > > exploited such vulnerabilities in the drivers. I should have used the > > term "Vetted Drivers" maybe to convey the intent better - drivers that > > have been vetted by a security focussed team (admin). What I'm > > advocating here is an administrator's right to control the drivers > > that he wants to allow for external ports on his systems. > > That's an odd thing, but sure, if you want to write up such a policy for > your systems, great. But that policy does not belong in the kernel, it > belongs in userspace. Agree. > > > 2) In addition to the problem of driver negligences / vulnerabilities > > to be exploited, we ran into another problem with the "whitelist > > devices only" approach. We did start with the "device based" approach > > only initially - but quickly realized that anything we use to > > whitelist an external device can only be based on the info provided by > > *that device* itself. So until we have devices that exchange > > certificates with kernel [1], it is easy for a malicious device to > > spoof a whitelisted device (by presenting the same VID:DID or any > > other data that is used by us to whitelist it). > > > > [1] https://www.intel.com/content/www/us/en/io/pci-express/pcie-device-security-enhancements-spec.html > > > > I hope that helps somewhat clarify how / why we reached here? > > Kind of, I still think all you need to do is worry about controlling the > devices and if a driver should bind to it or not. Agree. That is precisely what this RFC had in mind: (1) controlling whether a device is authorized and if so (2) What drivers can bind to it. > Again, much like USB > has been doing for a very long time now. The idea of "spoofing" ids > also is not new, and has been around for a very long time as well, and > again, the controls that the USB core gives you allows you to make any > type of policy decision you want to, in userspace. > > So please, in summary: > - don't think this is some new type of thing, it's an old issue > transferred to yet-another-hardware-bus. Not to say this is > not important, just please look at the work that others have > done in the past to help mitigate and solve this (reading the > Wireless USB spec should help you out here too, as they > detailed all of this.) > - do copy what USB did, by moving that logic into the driver > core so that all busses who want to take advantage of this > type of functionality, easily can do so. Understood, will keep that in mind. I may first present a "PCI subsystem only" draft just to get a feel for it, since that is more familiar to me and also already has some bits and pieces we need for this. Thanks & Best Regards, Rajat > > thanks, > > greg k-h