Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp946619pxt; Thu, 5 Aug 2021 16:05:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztCX4NGSLEHY0v3LcR3jvYHoMUBKu7zs5psHgPdFXZrBH5tIj8L7p3wMO3XT6vAx6JckNt X-Received: by 2002:a5e:d918:: with SMTP id n24mr372181iop.173.1628204733270; Thu, 05 Aug 2021 16:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628204733; cv=none; d=google.com; s=arc-20160816; b=iEPcwoo7tEd5V9Cif8bvyGWfygu4cfuSYgvoElqQ18a7RD5di8TOBIY02Zj8zaRIO9 LwGBQaeoj1WSx1NxXHvK3Sj5czFw+iXUb4FwNMibn8BMuWOwPitwhUFoxmabsqbrlJ7B COW/q2UxoFIhOhfg2J5WvQ4rUVR7/6b7Oda2jTf99tpQ/mlai9RytTdKcLedk+aXbEgk ZNaQzDneBwUofJ3eFbsAX1T75GKQyzNpOhKWenqu6G7Cxxamr4nPQvvEhmbSwReYog7l ho25NRJ1wpLDpUBmVJO7iC6HDgFIRVgvGKR7DfaTOtpDKGCza3gLqsnNfnUi8bfG3tZI HsTw== 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=++KaK3sXKFcfH87I/TzZgK45NFVsqzYW8QlI/XBfyMY=; b=Te5srxarSOR8FdNh10IXYXy+TDkFTZL1Tp06JIMrC4+qGnvbxT+7rat/ZvJj/6Qmuo ay+yTmtDl2uiST+nSh4qY/J13hPQIzHPT6o0RY9i1iZS/MFSTpCNnk3L8ibu6Z3PMEKk AKZJR7sq4SVide+BHRhGN9tzdykJXt7BkZY19b1LBdVhocNYJaaQ/D4ZwreVARw/5NMw q4bEHo0vRNw4dAcLOXdd5RMzLyHBEMQSLrA3OpK04AS777BoQOHB7DvPSGv7PxxTraQP SEb+dnKQTw7abDzOU0JV8A8g3UCFX7lwyq9G7S5pNn8c6om+/ZNQchl/5oz9Vs7zH47I 6Zeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=zBPK9WHg; 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 w11si7106772ill.114.2021.08.05.16.05.19; Thu, 05 Aug 2021 16:05:33 -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=zBPK9WHg; 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 S230099AbhHEQhy (ORCPT + 99 others); Thu, 5 Aug 2021 12:37:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbhHEQhy (ORCPT ); Thu, 5 Aug 2021 12:37:54 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB663C0613D5 for ; Thu, 5 Aug 2021 09:37:39 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id nh14so10210254pjb.2 for ; Thu, 05 Aug 2021 09:37:39 -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=++KaK3sXKFcfH87I/TzZgK45NFVsqzYW8QlI/XBfyMY=; b=zBPK9WHgCgGdHHQE1HOeQnwkErOz91g2zGgnQO1E2JHkb5vIy9L12GCtg1yfW04Vb2 +WwaUt8WVw6BuR4Pd5e+f6i2Ysxxcr23qoszN9Axjy4n7nNGW4UJdZh3FoOgw4WXgUs1 kIXA547mO0y/lqz6Fb3IGe8J+k9Zx+0UT7QyzwuCC9dlwLsCAHhVCf5xrjWeZlKnnA+M ZRKCL1hP//Lle2YMFoNszMMeABeRaDvf8XbwM284nEZYYETN86rRgUAaP/9uUfoL5wwK w6G2uFBOsiZ188UqEvdUzHaWxfnZovDSiznRyOFXRlR+TRqOwLpxdiZ4sEV6AUhyN1tz UUYA== 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=++KaK3sXKFcfH87I/TzZgK45NFVsqzYW8QlI/XBfyMY=; b=QVpqyRDjU1vufX6+b3TW0VdrenalQUJ/qsgkALkdDztjiWJ67D06nNTS+Yjh0z9XVW nTlRx0dN393XEzSoJwclkvfW7uiyIz/6UpFiDmTfUjGTn7nD/nZyrZU+N63oJQCS8wk7 9S3ck5Kv6wQpAjztlxsehd3ED2fplaBHv0nz6bsfN8THvc5fkP+MWPIQBHvOxpYQg83i 3dTriVSNpZ5rhhCu70+BT4taeRrCduJtDSpwBP1ysRWAw/QrTRtHOWj1O+XDaIXDlr99 rZgJXLbYCaruG99CAp1f80LEL0dOs9gCUOVG4Mcg8iILXZx5U8AWB0ztifo6oTj5NE/F cYog== X-Gm-Message-State: AOAM532prpB0x/uYOz90xjWp55W8rSvEPdtpH701ipr0DmEUe2sgcjIj smGYbarD6yYmpPr/tAjIoSgIEGDnY9HAatwhwKN+BA== X-Received: by 2002:a63:3c7:: with SMTP id 190mr783412pgd.240.1628181459424; Thu, 05 Aug 2021 09:37:39 -0700 (PDT) MIME-Version: 1.0 References: <20210804174322.2898409-1-sathyanarayanan.kuppuswamy@linux.intel.com> In-Reply-To: From: Dan Williams Date: Thu, 5 Aug 2021 09:37:28 -0700 Message-ID: Subject: Re: [PATCH v1] driver: base: Add driver filter support To: Greg Kroah-Hartman Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , "Rafael J . Wysocki" , Jonathan Corbet , Kuppuswamy Sathyanarayanan , Linux Kernel Mailing List , Linux Doc Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 5, 2021 at 12:58 AM Greg Kroah-Hartman wrote: > > On Thu, Aug 05, 2021 at 09:55:33AM +0200, Greg Kroah-Hartman wrote: > > On Thu, Aug 05, 2021 at 09:49:29AM +0200, Greg Kroah-Hartman wrote: > > > On Wed, Aug 04, 2021 at 12:50:24PM -0700, Andi Kleen wrote: > > > > > And what's wrong with the current method of removing drivers from > > > > > devices that you do not want them to be bound to? We offer that support > > > > > for all busses now that want to do it, what driver types are you needing > > > > > to "control" here that does not take advantage of the existing > > > > > infrastructure that we currently have for this type of thing? > > > > > > > > I'm not sure what mechanism you're referring to here, but in general don't > > > > want the drivers to initialize at all because they might get exploited in > > > > any code that they execute. > > > > > > That is exactly the mechanism we have today in the kernel for all busses > > > if they wish to take advantage of it. We have had this for all USB > > > drivers for well over a decade now, this is not a new feature. Please > > > use that instead. > > > > Hm, wait, maybe that didn't get merged yet, let me dig... > > > > Ok, my fault, I was thinking of the generic "removable" support that > recently got added. > > Both thunderbolt and USB have the idea of "authorized" devices, that is > the logic that should be made generic and available for all busses to > use, by moving it to the driver core, just like the "removable" logic > got moved to the driver core recently (see 70f400d4d957 ("driver core: > Move the "removable" attribute from USB to core") > > Please use that type of interface, as we already have userspace tools > using it, and expand it for all busses in the system to use if they > want. Otherwise with this proposal you will end up with multiple ways > to control the same bus type with different types of "filtering", > ensuring a mess. I overlooked the "authorized" attribute in usb and thunderbolt. The collision problem makes sense. Are you open to a core "authorized" attribute that buses like usb and thunderbolt would override in favor of their local implementation? I.e. similar to suppress_bind_attrs: diff --git a/drivers/base/dd.c b/drivers/base/dd.c index daeb9b5763ae..d1780f026d1a 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -511,6 +511,10 @@ static int call_driver_probe(struct device *dev, struct device_driver *drv) { int ret = 0; + if (driver_core_auth_enabled && !dev->bus->suppress_authorized_attrs && + !driver_core_authorized(dev)) + return -ENODEV; + if (dev->bus->probe) ret = dev->bus->probe(dev); else if (drv->probe) diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c index a062befcb3b2..e835be9bee4f 100644 --- a/drivers/thunderbolt/domain.c +++ b/drivers/thunderbolt/domain.c @@ -323,6 +323,7 @@ struct bus_type tb_bus_type = { .probe = tb_service_probe, .remove = tb_service_remove, .shutdown = tb_service_shutdown, + .suppress_authorized_attrs = true, }; static void tb_domain_release(struct device *dev) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 072968c40ade..2cf9c3cc12b4 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -2028,4 +2028,5 @@ struct bus_type usb_bus_type = { .match = usb_device_match, .uevent = usb_uevent, .need_parent_lock = true, + .suppress_authorized_attrs = true, };