Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2261098rwb; Thu, 17 Nov 2022 08:28:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf6eQDlIbzFtw+yE+4cvxPrIf2XCBYpqGb/x3ZTcObeqPCN62U0ksUBy24FnAB4LezKSoirG X-Received: by 2002:a17:903:182:b0:188:a40b:47c9 with SMTP id z2-20020a170903018200b00188a40b47c9mr3494976plg.75.1668702495561; Thu, 17 Nov 2022 08:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668702495; cv=none; d=google.com; s=arc-20160816; b=GjrVOULQ4MJsbrgBVbH5N4BaynCDKn1E59s7BaAJIzvqI0/Abj8UWXhGaatE4/9m+n gpnHhXV7i9Balo66lDoI4AGylPBiAuXXO/vljeTBw6kVeoZQpyb1EmJcj82Xs+AvVGy9 //a/ZZ+W5T+kynvJvNBhy6liUo2BigHXdjHbs7WqzU5hAO5iSn7p4jI/ZzPBsJ9j3k5d Dq7EYEq4ekqHMy86gaiyViD12QSxV+wiIZB3lEEhbDabcVvPk4nLFtvftDOV/mQe6yze Xy83XTHyheFe+mhoNToc8nOJu2DUu5b0y4QYQJ8wYUlvuD1orD+6RvWnFofqFr7f7pMq pN1g== 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=L8qQcAQYUMz9YEZBHNuU4s/sqJmlGCLX2PQ6PvoERas=; b=TzSeKRnUhJkh7H1EoVJ1boHc2B3beTksygeUPF/cNV6iNI4f3BpO7VI/q8aHdXbb6j 9/v2qYPL5IlAiQOOcdZmSP3u6D3pvSw/s+DfBqg5pnXnMPwwiERbDNA5PO4cdxbcgM+c 4dRAzv9Hl+avjVCL4Z+EeTtXN7bRh+WYhjyZG+dUNGYBoPWW0rLDQJR7Adm+KInDTfOq B5W5aMr55AE1JY1DGmNOzPDrPuwoBfqqkuZmXjDgDA8INcPKB+7UBZHN2jM8CHzlHoYn 5NytgfdYBDpYib4DCkIGFCR+eytx07A1EpRByqnT/eKfkWk7BrDdTkZLWBKCMJ71RgCM q15Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nKSqxuRw; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j191-20020a6380c8000000b00450b99448b0si1427828pgd.341.2022.11.17.08.28.03; Thu, 17 Nov 2022 08:28:15 -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=@kernel.org header.s=k20201202 header.b=nKSqxuRw; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234844AbiKQPyV (ORCPT + 92 others); Thu, 17 Nov 2022 10:54:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231469AbiKQPyT (ORCPT ); Thu, 17 Nov 2022 10:54:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB28DED8; Thu, 17 Nov 2022 07:54:18 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 391366209A; Thu, 17 Nov 2022 15:54:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85D37C433C1; Thu, 17 Nov 2022 15:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668700457; bh=EsSvC1Bd9cCDqcgDGICCIVHG9/jMhUY/m8+coxXZkIM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nKSqxuRw1M0PQaaRRBx71A6+DEbyathvdZpqW62OcEVQcqq66SN1DGGjENCcWh4cq MjmtHm2SdOvguZkN3E9gQDA7LLPO5qXfd31kuDc/kItR/WyOB4HAS0AOqT+YNhGncv Mfj3Klu1lYWj1WBRuDtqB4C7FqrVOSZ9AS5rvZ52DExkzlyQPcKar3aCZdIrBVU7gp IIuVdodU0xScbxBMl9gb3nS0Ahkc0D0222sEUaXwIKxfpB6zPLIw1ZQDDsNQ/F4xNg RKn6TPHASeH1+d4WzahD3dhaccxoheWpEDl/Mlp8j23CorWG4cXtEj6CaoEk/w3C7L r9gkfO3LWEZAw== Date: Thu, 17 Nov 2022 16:54:12 +0100 From: Alexey Gladkov To: Allen Webb Cc: Luis Chamberlain , Lucas De Marchi , Christophe Leroy , Greg Kroah-Hartman , "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "Rafael J. Wysocki" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] modules: add modalias file to sysfs for modules. Message-ID: References: <20221111152852.2837363-1-allenwebb@google.com> <20221114172214.ilnk5wj3eevpsqts@ldmartin-desk2.lan> 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 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 Tue, Nov 15, 2022 at 12:40:57PM -0600, Allen Webb wrote: > When i get the modinfo for usbhid, there are no aliases listed: > ``` > localhost ~ # modinfo usbhid > name: usbhid > filename: (builtin) > author: Andreas Gal > author: Vojtech Pavlik > author: Jiri Kosina > description: USB HID core driver > file: drivers/hid/usbhid/usbhid > license: GPL > parm: quirks:Add/modify USB HID quirks by specifying > quirks=vendorID:productID:quirks where vendorID, productID, and quirks > are all in 0x-prefixed hex (array of charp) > parm: ignoreled:Autosuspend with active leds (uint) > parm: kbpoll:Polling interval of keyboards (uint) > parm: jspoll:Polling interval of joysticks (uint) > parm: mousepoll:Polling interval of mice (uint) > ``` Hm. Interesting. Actually, alias gets into modules.builtin.modinfo: $ tr '\0' '\n' < /lib/modules/`uname -r`/modules.builtin.modinfo |grep ^crc32c_generic.alias= crc32c_generic.alias=crypto-crc32c-generic crc32c_generic.alias=crc32c-generic crc32c_generic.alias=crypto-crc32c crc32c_generic.alias=crc32c > bluetooth however has an alias listed: > ``` > localhost ~ # modinfo bluetooth > filename: > /lib/modules/5.10.154-20424-gea7532c123d8/kernel/net/bluetooth/bluetooth.ko.gz > author: Marcel Holtmann > description: Bluetooth Core ver 2.22 > version: 2.22 > license: GPL > alias: net-pf-31 > vermagic: 5.10.154-20424-gea7532c123d8 SMP preempt mod_unload > name: bluetooth > intree: Y > retpoline: Y > depends: ecdh_generic > srcversion: F8E46CD048C50B0AA1CD471 > parm: disable_esco:Disable eSCO connection creation (bool) > parm: enable_ecred:Enable enhanced credit flow control mode (bool) > parm: disable_ertm:Disable enhanced retransmission mode (bool) > ``` > > I believe the reason for this is many modules use `#define > MODULE_DEVICE_TABLE(type, name)` which is a noop for buildin modules. > I have a local patch that resolves that issue here: > See: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3840672/1/include/linux/module.h#b246 > > However, I probably ought to rework that patch to create the > MODULE_ALIAS defines instead of the buildin.alias file. > > On Tue, Nov 15, 2022 at 11:35 AM Luis Chamberlain wrote: > > > > On Tue, Nov 15, 2022 at 10:05:35AM -0600, Allen Webb wrote: > > > On Mon, Nov 14, 2022 at 11:22 AM Lucas De Marchi > > > wrote: > > > > > > > > On Mon, Nov 14, 2022 at 10:42:50AM -0600, Allen Webb wrote: > > > > >On Fri, Nov 11, 2022 at 12:29 PM Luis Chamberlain wrote: > > > > >> > > > > >> On Fri, Nov 11, 2022 at 09:28:52AM -0600, Allen Webb wrote: > > > > >> > USB devices support the authorized attribute which can be used by > > > > >> > user-space to implement trust-based systems for enabling USB devices. It > > > > >> > would be helpful when building these systems to be able to know in > > > > >> > advance which kernel drivers (or modules) are reachable from a > > > > >> > particular USB device. > > > > >> > > > > > >> > This information is readily available for external modules in > > > > >> > modules.alias. However, builtin kernel modules are not covered. This > > > > >> > patch adds a sys-fs attribute to both builtin and loaded modules > > > > >> > exposing the matching rules in the modalias format for integration > > > > >> > with tools like USBGuard. > > > > >> > > > > > >> > Signed-off-by: Allen Webb > > > > >> > > > > >> Thanks for the patch Allen! > > > > >> > > > > >> I'd rather have something generic though, and it would seem kmod [0] already > > > > >> does this, have you seen the kmod support for builtin.alias.bin > > > > >> > > > > >> Can't that be used? > > > > > > > > > >Probably, but I don't see the builtin.alias.bin in my build. Is it experimental? > > > > > > > > no. That is generated by depmod since v27 using modules.builtin.modinfo > > > > generated by the kernel build system. Highly recommend v30 though > > > > as there were fixes in v28 and v29 and some changes to speed up its > > > > generation/use in v30: See entries mentioning > > > > builtin.alias and bultin.modinfo in > > > > https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/NEWS > > > > > > > > libkmod/modprobe/modinfo also have the corresponding changes to lookup that > > > > index when resolving aliases. > > > > > > I see the file but it is largely missing the aliases I am interested > > > in, so it looks like I might need to modify my patch that creates > > > buildin.alias to add the missing alias defines in the header along > > > with the other module metadata for builtin modules. Does this sound > > > right to you? > > > > Can you clarify what is missing and why? And an RFC is welcomed if it > > helps demonstrates what you mean. > > > > Luis > -- Rgrds, legion