Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7357387rwb; Tue, 15 Nov 2022 11:02:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7MwQ5shz/hx/mXHIMClp+0HrajWYNo82utdftu/wwue9JguN3/P6anNIMIkAx2/bE56xew X-Received: by 2002:a63:571b:0:b0:46f:1085:eeb6 with SMTP id l27-20020a63571b000000b0046f1085eeb6mr17193450pgb.266.1668538921198; Tue, 15 Nov 2022 11:02:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668538921; cv=none; d=google.com; s=arc-20160816; b=ce1IIEFGXfefokTZbzUVCHmNU4Rw72kWMJw619IqRbhcXSdWa10kyFHDAKFExoLdXB bxy+7M9gzhyNetuKqMUX1Og7sRa9D8uA07jUTLf8B+4TlaQqV6Y3ODF8rNyxJhI+n1DC 0Toa2++3nyJ8Am/GxpEsV1FZEu9LvnIFA8z2ZNnO9vdF03LKlOAuB9AL0Dev7bJF/Uwq A1PPJ6LF+fHZPdljW1Dg4rbOODEaI/M2Qd7cf7nuiW0+NPjE6eeGSm5FuYYrUzRJ9xzi bWV0pvZQqd0Jcat4wujE7uaPpNQ1UHzaa7j/oLh0rrjcqkep9U6ISLhdtKcO1mIcNtYY cWKw== 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=Ew/kS0ApPSoUAdYuL8W2b5WTrzKo/qT7BVDW6jleAnI=; b=tx31ENSZZWgJkYaEJMx4+n57TmTSJ1iTefXxeFm9zZEEno+mjTgDzqiFNVvsjk4O1i MMLycC9j1OMJGQ3XYVGyOdKCtaireAz7wYNoRxS19BMPum9dBeryoPV5R+IqsOtOKAcb OY5da5yRRJOugFO4OawFPX1O5w0fP9JXSsmXlmQG0nR6Nmq3cbeWs+GSNBbbtEZEUOOq dP2ELXq+FKSMZapsxDzGmEyG9JWq3lNyVTnXGsziR1w9J93jAkhNFjnGMHGTCnNwMpbf Z4qfOCNTbpoUr919xXsdfBfoqcB5rkw+rNiYBiT4MA3qSaGNvJJnjhjDCw9f1W+Sya59 Sbtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OvwABNQg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u26-20020a63141a000000b00476a84ecadesi3346381pgl.444.2022.11.15.11.01.38; Tue, 15 Nov 2022 11:02:01 -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=@google.com header.s=20210112 header.b=OvwABNQg; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbiKOSlN (ORCPT + 90 others); Tue, 15 Nov 2022 13:41:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230345AbiKOSlL (ORCPT ); Tue, 15 Nov 2022 13:41:11 -0500 Received: from mail-vk1-xa2a.google.com (mail-vk1-xa2a.google.com [IPv6:2607:f8b0:4864:20::a2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1D942CE2A for ; Tue, 15 Nov 2022 10:41:09 -0800 (PST) Received: by mail-vk1-xa2a.google.com with SMTP id g26so7037702vkm.12 for ; Tue, 15 Nov 2022 10:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Ew/kS0ApPSoUAdYuL8W2b5WTrzKo/qT7BVDW6jleAnI=; b=OvwABNQgofnJmpgMRxGIvnO/BdcZq8Nn4cFLo+dG2qUVcyiYxEqNadXTeoO7tmXWTy 52goVdGBhCske78LH8RKeSx3u2zD83RGvEx0gEmYicFf+V4dwr5mZYVRWnh6ZMFd7tbr u3hN6yBI5h18Y55Ox7s4R0vTHAuzkKFrjzr+Ytw96R62tmDEZuAuFnZm6Islh93FN5Ho SITC8VfJuOUd0igtsQgZ6tt58wK6cWMFiNVB0f+tmbKXHPeXTMZmeTCXPruAV/A7gJRM GK58AtbCxYTvupjRf0ei9Sh9UoTtigie2esuDHW/hFbTn+zLT8YR5x30g9qEf0HojmCd R+Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ew/kS0ApPSoUAdYuL8W2b5WTrzKo/qT7BVDW6jleAnI=; b=MxdvqQM8dHmRABj76JhCE80t5WVj00cR124SXWy/lTFuo3wTC8mz6SvI/6lBWzasnW dc7BuUAvTLreuk/9Y95pMjFbGz5aI80bkr/ELKzdk2BCy5TgXkvbH9RN4m3MJdQLJ3ry gCRdpvwrN1nkAM9uyACm0FJIjCZa3kzIHUx/kNBtnGeu3rbni+P6asqh3OpHIYp7yrX3 PK0nmuP3ENThhl3eYGRdKM1JMF9Z+VBEeIZ1ft0KZd17QssmMMkjBQWxbeiOX38duFU6 kyNcH5CVgq25cXiv6KZ7M7NM8BurHAsTHJHZMeKHO+H8th4guJHaXPR9AyePxNpMCDrw kzvQ== X-Gm-Message-State: ANoB5pk+F2e+egIgW77SyAO3H3pnj72nVO54xJQ4whPwz08VzYCbwpAm jtt0qxZUVuPgqZYIz8QEJJvZ+diSK2xXKUZqLdfVrg== X-Received: by 2002:a05:6122:1989:b0:3b8:1bb4:b750 with SMTP id bv9-20020a056122198900b003b81bb4b750mr10368533vkb.20.1668537668924; Tue, 15 Nov 2022 10:41:08 -0800 (PST) MIME-Version: 1.0 References: <20221111152852.2837363-1-allenwebb@google.com> <20221114172214.ilnk5wj3eevpsqts@ldmartin-desk2.lan> In-Reply-To: From: Allen Webb Date: Tue, 15 Nov 2022 12:40:57 -0600 Message-ID: Subject: Re: [PATCH] modules: add modalias file to sysfs for modules. To: Luis Chamberlain Cc: Lucas De Marchi , Alexey Gladkov , Christophe Leroy , Greg Kroah-Hartman , "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "Rafael J. Wysocki" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 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) ``` 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