From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F95C77B6E for ; Thu, 6 Apr 2023 19:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240202AbjDFTBJ (ORCPT ); Thu, 6 Apr 2023 15:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239830AbjDFTBC (ORCPT ); Thu, 6 Apr 2023 15:01:02 -0400 Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B8B9012 for ; Thu, 6 Apr 2023 12:00:59 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id x5-20020a056e021ca500b00327f726c6c0so3261773ill.9 for ; Thu, 06 Apr 2023 12:00:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eGQLnr57manA7/d3sSj7CWvU90h1ejgPAAwZbA4W80Y=; b=E1XOP1CaY8koFy3ME6her9rJ9Nke8XHAoAVsqLpY3lPsNoEYGcrpUF5PF5gHdN47bK NGSiShp2xcYg0DXa0KIabY1O37FSpfutYwWTjtRVrU9oHpeB9FGTYAd99a4F1/6Y8FZn AbnD5SAV+TZ0GjZP3RdKVI6rqFp6OB//JibKTs1ZBw4TBgjK4lD7u+6bQxjHMtj/gsBd BKNR9Uz/lHv1iRy4b6qhPk1HwfMVdk/ucdXhOaul/MyfX6WSdjJGRwtYds3NlIxOeBAy hYI94iBkFDpAsYZMS2B43djCX50lmE22kkHDNV9FYiOmAE1uw+MDpJDDPPsBmoU8NICk 6/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eGQLnr57manA7/d3sSj7CWvU90h1ejgPAAwZbA4W80Y=; b=Tb1A2vTUmRZO4cTlqa7DTI1VGPq5JawS4N0OvyLtEWGQAz/ECdl1PcTeLlC2nb45xA qLPERhlAzAMqnsyGPxVRux+KQITkGcJbsbYCcOGrQeTAutb16cO6q0sd9q5LroFxP9nr p8DuY1Hc+0dq+GjvopIYC5LL0Q+ka4UAwuWloLkFvTC9AoQu23tDgs8WBQKXGfZBGTfC TCKMOF328KcjeHJlO8Bh4Vcs3K8CJRL46B6MRG/UlZlYQhG0BtiBUDcsuGXoiIrLDl+4 7U6JxbkCesKAnEy8heE4CwQCJT065NebpDLg3tahJfElQN+kpEZjHq+3T/apPbfOX2km CiBw== X-Gm-Message-State: AAQBX9fX3m9T32/1m0S7zjF8tH67qcU2f3Jy0MBggZw2Y7r7IeAVXwPU 0nTwK6aR18QR3JouyBX4GuwCDpEPgMRvXrU= X-Google-Smtp-Source: AKy350bXUyOdQnwpKnTh5pwn2Z58BJIiX3qb6NKTnyLlDlV/PWR/2NVrpWvh92/1KkRXzxoRshzXEZc+XwdEVcY= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a92:1a49:0:b0:315:8f6c:50a6 with SMTP id z9-20020a921a49000000b003158f6c50a6mr6481064ill.1.1680807658940; Thu, 06 Apr 2023 12:00:58 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:20 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-2-allenwebb@google.com> Subject: [PATCH v10 01/11] rockchip-mailbox: Remove unneeded MODULE_DEVICE_TABLE From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A one character difference in the name supplied to MODULE_DEVICE_TABLE breaks compilation for ROCKCHIP_MBOX after built-in modules can generate match-id based module aliases. Since this wasn't being used before and builtin aliases aren't needed in this case, remove it. This was not caught earlier because ROCKCHIP_MBOX can not be built as a module and MODULE_DEVICE_TABLE is a no-op for built-in modules. Fixes: f70ed3b5dc8b ("mailbox: rockchip: Add Rockchip mailbox driver") Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171140.NB93eVvI-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/mailbox/rockchip-mailbox.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-= mailbox.c index e02d3c9e3693..1f0adc283d1b 100644 --- a/drivers/mailbox/rockchip-mailbox.c +++ b/drivers/mailbox/rockchip-mailbox.c @@ -159,7 +159,6 @@ static const struct of_device_id rockchip_mbox_of_match= [] =3D { { .compatible =3D "rockchip,rk3368-mailbox", .data =3D &rk3368_drv_data}, { }, }; -MODULE_DEVICE_TABLE(of, rockchp_mbox_of_match); =20 static int rockchip_mbox_probe(struct platform_device *pdev) { --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52F25C77B6C for ; Thu, 6 Apr 2023 19:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240226AbjDFTBV (ORCPT ); Thu, 6 Apr 2023 15:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbjDFTBE (ORCPT ); Thu, 6 Apr 2023 15:01:04 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A316693C9 for ; Thu, 6 Apr 2023 12:01:00 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id 187-20020a6b15c4000000b007590817bcfbso25285965iov.12 for ; Thu, 06 Apr 2023 12:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=caRdwk2BRQJWlUMku9R1oT1hxRVhqY9kuoHjJ2qZO3g=; b=lfuUx+vimxI8w/cKWiB5+HTdLqsC/0cCYDiqUSTIeqzGMKR+TKHzvMizjJ7BBZhZW/ RlHbjNQWDsD82aYLkG3tBnPoM2YnbzzGHVTeWDzYKzOUz6Gp4MAIpw30SmY7ci/GiQjg FnQkWFZp05JjNnSEUc0m7CUrF4XEblcCLQb6VXf1kI/MJ2RGfMVdkZbWgyfUe/Uzy0vZ TzlHMoGVm/UiwgZkl59Xjma1a7g5UolZu1xB4zkh8Y9WNDbbXYOuYkXU/UZBM2iGBKig VuX4OQ9m6Ud3XYU7CvzTvyVuvzsPIGY32a7R0F0CZZQwLW00QKLFtlweUo4TM8fl9CQa qLiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=caRdwk2BRQJWlUMku9R1oT1hxRVhqY9kuoHjJ2qZO3g=; b=7vHgYVqTz/sdCtQ7dSyJ4MfG6yG9ABJWMvYX8z1ePVoI2GcqMPCp2CFa/kP4DKCO+M +DsB+3E0nBtyNsPO8iNXPiN+9/ulSggc8/MO79p9+soLhZT77iV5/ESr3Pg40E0qVDeT CHesO7PClKqFu/Xtv4C8H+gmb7ZCLSr5MqLrgR/HIbkYt4I53uZmz8/mOM9KljP2DP9d x7TQ+ljBfswDYM31RFwIqs9jpZLWMMDLVsJBRe16YQG+cySjlCMYArLP4ap2kTSNrlEL VEMQ1AL7SV8u/5jOqVjM/w68FAGCpHdOGzyqfwrBGcOTrE02bU1k5b6/838dX6L6jG53 PIuw== X-Gm-Message-State: AAQBX9cqgr0tjuXHApR86XC1Gq6RHBqSAMU+92OBIhL7R2esDV78zfMw rnoEGH5fXRJPndGK1egSEnFanp6Ulnu0gdc= X-Google-Smtp-Source: AKy350YZuifQDcAImF7FIJpdSl4uI0utqVn+lwF5XQxv4tsCuonBlHCBbuxU7Zq6L46KIXeGCiA3IUpgdFEzMO8= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:b181:0:b0:3c5:14ca:58c6 with SMTP id t1-20020a02b181000000b003c514ca58c6mr6033175jah.4.1680807659752; Thu, 06 Apr 2023 12:00:59 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:21 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-3-allenwebb@google.com> Subject: [PATCH v10 02/11] scsi/BusLogic: Always include device id table From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A future patch makes use of the device table for built-in modules, so do not ifdef out the match id table. Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171257.0oLypyYS-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/scsi/BusLogic.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index f7b7ffda1161..79fc8a24e614 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -3713,7 +3713,6 @@ static void __exit blogic_exit(void) =20 __setup("BusLogic=3D", blogic_setup); =20 -#ifdef MODULE /*static struct pci_device_id blogic_pci_tbl[] =3D { { PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, @@ -3729,7 +3728,6 @@ static const struct pci_device_id blogic_pci_tbl[] = =3D { {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, {0, }, }; -#endif MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); =20 module_init(blogic_init); --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92197C76196 for ; Thu, 6 Apr 2023 19:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240377AbjDFTBS (ORCPT ); Thu, 6 Apr 2023 15:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240336AbjDFTBG (ORCPT ); Thu, 6 Apr 2023 15:01:06 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 832E893D2 for ; Thu, 6 Apr 2023 12:01:01 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id d11-20020a056e020c0b00b00326156e3a8bso20692805ile.3 for ; Thu, 06 Apr 2023 12:01:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807661; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CIaNzDoEfkQUCUs5a1+ah5UqZ1hq5cACYGIKF90PLWA=; b=G+FTw3D1oOQIjnAKB1cpn9CiPMPKCCFM4zdri/XtQJGkhM8ftL306NfOcRuhgBJwAT +mqD0LOE5YJzkUY6ePsFoGVjZiuuVZ9E2USexjk/EUU97k0/6RzsAAanDkVOThd1NSb/ UHy8zFuNtffS3eWlDckeeAT9oCY7xDJSH2ttDYfw5Ys4YqfON7UCSPfniEHkJXIicK5X pym1+Tk0FtNI+3SFj6R7I0VHLqY1yU3s7SCpVrnruhY/CbD+oW8s5P5fV208J/K1wmOr VQqc6oZ6PtBD6O5hhHqZblnYB84HAIivUECRQzO7E8yY+rSsgFhBq+ttRv64b/8RpqGV 7E3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807661; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CIaNzDoEfkQUCUs5a1+ah5UqZ1hq5cACYGIKF90PLWA=; b=ldmf2bixK4+UUaXaCC0/MwE8VAX1JwuImwpySQxxoMuxzRpq8ECZg1CSNBaok7+4Xl 4lnPL+fcdlJ878d1GYJLTYQiBVIA0PG+ZVKpBKPX3P3/J67oAwbgLYSZ3wavXdlO6BWb JGyyzBX2jt/VAeQsgcC+f/MawebawFZsQU6j4r80PshOzrdUD2fa4YUfb05/GqIXTkTl 0XDqcFFTjXKqxjyi2KwQ2AXNMPa+nKsq8mCvrN0V881crCeW8Y4KdxacEak9SQiEzAIn OhneT8xkG5tW0lUBwaDOl0goQHSd1pCizt0OfGSwl8tiRqLLrcMRrlONjnpADIKiSXLd M5nw== X-Gm-Message-State: AAQBX9fz6BqXi8a3kmBAc0Lqv7zrDghxMi//koj6PkQi2a2tatT1qxG9 zphz9dflw3csqJzxGUb/DLh1K+YnkXgvA4g= X-Google-Smtp-Source: AKy350Z+5g/pbGkfqFeQV7zALWCzNXPo9m7bN766vJbNtaAOGFM9jzMpqoRBx0ByEqTie31Zw2uJvsgSxEzqmLQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:a10c:0:b0:405:8be:eaaa with SMTP id f12-20020a02a10c000000b0040508beeaaamr6056313jag.5.1680807660861; Thu, 06 Apr 2023 12:01:00 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:22 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-4-allenwebb@google.com> Subject: [PATCH v10 03/11] stmpe-spi: Fix MODULE_DEVICE_TABLE entries From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb , kernel test robot Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A one character difference in the name supplied to MODULE_DEVICE_TABLE breaks compilation for STMPE_SPI after built-in modules can generate match-id based module aliases. Since this wasn't being used before and builtin aliases aren't needed in this case, remove it. This was not caught earlier because STMPE_SPI can not be built as a module and MODULE_DEVICE_TABLE is a no-op for built-in modules. Fixes: e789995d5c61 ("mfd: Add support for STMPE SPI interface") Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202212171140.NB93eVvI-lkp@intel.com/ Signed-off-by: Allen Webb --- drivers/mfd/stmpe-spi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c index e9cbf33502b3..e9cb6a635472 100644 --- a/drivers/mfd/stmpe-spi.c +++ b/drivers/mfd/stmpe-spi.c @@ -129,7 +129,6 @@ static const struct spi_device_id stmpe_spi_id[] =3D { { "stmpe2403", STMPE2403 }, { } }; -MODULE_DEVICE_TABLE(spi, stmpe_id); =20 static struct spi_driver stmpe_spi_driver =3D { .driver =3D { --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AE92C76196 for ; Thu, 6 Apr 2023 19:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240164AbjDFTBP (ORCPT ); Thu, 6 Apr 2023 15:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240342AbjDFTBG (ORCPT ); Thu, 6 Apr 2023 15:01:06 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA24E4217 for ; Thu, 6 Apr 2023 12:01:02 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id s6-20020a056e02216600b003264c778ef1so13306585ilv.23 for ; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807662; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lY1ByN87FMvQLmIB6FmZa+RzwBjVh5nyLSYhKEEms/o=; b=TXJhoFceFs9wdYTRZd708YmwDXv6ZmJEZM5qsCVnFNFux6VSIy2sN485OdoLj6gH/u AQsSA/pqWjyYGM48tvaIncpfU2OLAUpCMQfGEUljMQY32VJVtir3KfI0/oLx5XXuijgt IdQDFo/dXt9qgNaakCRBJpEPF2lgHkdbMkFeyywUgZbfu/OiLuvJ3B+dRHj3/Osu3wFs Igv3FoQJ+xdCyHBUlOkjbozloyiEts0oRkMIvsUAEiq5xM+8ae/xA8FEMfg2w3bV7nHX XXgsLfahva+s2fFRR2U9HW32kdVcssWxj7eIV8JYkxojb7lCllY002RCrgMUSAo+vdRi BYJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807662; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lY1ByN87FMvQLmIB6FmZa+RzwBjVh5nyLSYhKEEms/o=; b=kRYGlyjec6IOgdNQgx/U0dAKkeOCwoVLA/hwI5e4x+AKsxRld1HcmjJSYwSjhOjF7T 00T4UPTBwZZptagQ/8PzZiweu85erJpKFS3UC1xgpWfGJiR58fAEBa6ZleeAQaxKuopc 4glkW6S0wRwFM9zoh71l3dxu+DA2BPb+bpDteBMY/8W5HaW1KUwGafAf1wSmUrb0S9eR lXZErpUN6ELuluWg/E8uwsa3bHgm5buvgy9QwuSJWAXlndsmnhZpisPzT0BRDzwAKLfc I+y2UpuvN+Hfryr6iPgFwkOC6mearMB2QnnfiWGJT7CwghG6MP29XwBd1RQLdBhVWac6 i+xA== X-Gm-Message-State: AAQBX9dRPsl6Y0XbSAVlX6vJLSaN4bptSikWuKN2E+RrHRMsGEgoUthg y67j+qWEryI9AJRYWg171NvIM4lkjDeDv1g= X-Google-Smtp-Source: AKy350Y53lWgT3pwwk/QGvquIa8pju0CYYGVAfASYtJqDKWDb552KXeL4N024JqlQO8Qz0mCpt8UDRDqw6NUjSI= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:8503:0:b0:3a9:75c9:da25 with SMTP id g3-20020a028503000000b003a975c9da25mr5548851jai.1.1680807662053; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:23 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-5-allenwebb@google.com> Subject: [PATCH v10 04/11] module.h: MODULE_DEVICE_TABLE for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Implement MODULE_DEVICE_TABLE for build-in modules to make it possible to generate a builtin.alias file to complement modules.alias. Signed-off-by: Allen Webb --- include/linux/module.h | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 4435ad9439ab..b1cb12e06996 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -237,14 +237,36 @@ extern void cleanup_module(void); /* What your module does. */ #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _descrip= tion) =20 -#ifdef MODULE -/* Creates an alias so file2alias.c can find device table. */ +/* + * Creates an alias so file2alias.c can find device table. + * + * Use this in cases where a device table is used to match devices because= it + * surfaces match-id based module aliases to userspace for: + * - Automatic module loading through modules.alias. + * - Tools like USBGuard which block devices based on policy such as whi= ch + * modules match a device. + * + * The only use-case for built-in drivers today is to enable userspace to + * prevent / allow probe for devices on certain subsystems even if the dri= ver is + * already loaded. An example is the USB subsystem with its authorized_def= ault + * sysfs attribute. For more details refer to the kernel's Documentation f= or USB + * about authorized_default. + * + * The module name is included in the alias for two reasons: + * - It avoids creating two aliases with the same name for built-in modu= les. + * Historically MODULE_DEVICE_TABLE was a no-op for built-in modules, = so + * there was nothing to stop different modules from having the same de= vice + * table name and consequently the same alias when building as a modul= e. + * - The module name is needed by files2alias.c to associate a particular + * device table with its associated module for built-in modules since + * files2alias would otherwise see the module name as `vmlinuz.o`. + */ #define MODULE_DEVICE_TABLE(type, name) \ -extern typeof(name) __mod_##type##__##name##_device_table \ - __attribute__ ((unused, alias(__stringify(name)))) -#else /* !MODULE */ -#define MODULE_DEVICE_TABLE(type, name) -#endif +extern void *CONCATENATE( \ + CONCATENATE(__mod_##type##__##name##__, \ + __KBUILD_MODNAME), \ + _device_table) \ + __attribute__ ((unused, alias(__stringify(name)))) =20 /* Version of form [:][-]. * Or for CVS/RCS ID version, everything but the number is stripped. --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2557C76196 for ; Thu, 6 Apr 2023 19:01:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240411AbjDFTB0 (ORCPT ); Thu, 6 Apr 2023 15:01:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240376AbjDFTBI (ORCPT ); Thu, 6 Apr 2023 15:01:08 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8712459F2 for ; Thu, 6 Apr 2023 12:01:03 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id w14-20020a056e0213ee00b0032827955ae6so1096699ilj.7 for ; Thu, 06 Apr 2023 12:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FEZbsR+WTyUtWxubualsRcS33WiF75x8OXTLlDIM76E=; b=D81pJQDCQ+OdL291Z2IZ2aoLcZ9JSdF//vAX5266oVAnQZPAsb2ROsi95KVjKK3wKl XbpTpcSS49IV425LJMR5r61TCIqtP2EcrXEcJYbsOu8cFWo+BVrf6iH+dJ58GpAVEbGn Ob0KC9VY5azkYE4xJEOA4ueXQijtPJP+hpJhW/YwaW4aQyUwR3vMc7NqkaFbDsODU7Nw /7C7nADEmWmY3+IZXHXTYCeVpPUBnR7rp5s6E1NNNGgXR1+Bt8XYVSPcNp7Zl8/rSVHw Qsi4OfLOzlOEZEGuq+ld/NjtkVhfX4p3akpLLAcW1NwdJOuSYjjL4pHgWvhxnmu7Be9V Pzag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FEZbsR+WTyUtWxubualsRcS33WiF75x8OXTLlDIM76E=; b=ReQxv6iDvJBVrcEvXr3968+QCk+SMPvfxvZIOQJdlYHMw0t/2IZdsYnR/xFTrbCbaV HE73Tzm+8Ac37Pha1paWkuMJ/rl83qKdvk+ZMjLCtkM6wsfh87lt7UkIMHsgyiPI1v6p LAbRzj36FPk7X5XqY/fRLpwaOTNQgrUXNacWDKt6Zv7AQUh0i4crm+stoaPuk1Q9TjN0 G658feq/+dkIhS5yu3yGv7wFmVIlKb4RLqVbgoA5cf2vYRFHbVI9SIIMvlzs3R+q+yoJ TWgJGtdhcBNIiZf8kadjmfCU126yEl36kw6n0pmCEJXCxcKTV/C76nK2/X9BxpTwoWyQ gR4w== X-Gm-Message-State: AAQBX9crTph0HvITb2PdcoA7VH0rLXdGHCchhYSumop+qybkZwudS1WG 3hhdWP8vGe1gFyfrmIk8dr20tO8mRqIW5Hs= X-Google-Smtp-Source: AKy350bmElFuE1Xid/gxRe2zw6r7kNsu5GgybFoCIrVluA8w6qJgsdQVeebMx1wlwhideMS0TE7hnev66x532k0= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:2a45:0:b0:406:c43f:6320 with SMTP id w66-20020a022a45000000b00406c43f6320mr4089761jaw.0.1680807662877; Thu, 06 Apr 2023 12:01:02 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:24 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-6-allenwebb@google.com> Subject: [PATCH v10 05/11] modpost: Track module name for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Keep track of the module name when processing match table symbols. Signed-off-by: Allen Webb --- scripts/mod/file2alias.c | 39 +++++++++++++++++++++++++++++++++++---- scripts/mod/modpost.h | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 91c2e7ba5e52..b392d51c3b06 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -28,6 +28,7 @@ typedef Elf64_Addr kernel_ulong_t; #include #endif =20 +#include #include #include =20 @@ -1540,9 +1541,9 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, Elf_Sym *sym, const char *symname) { void *symval; - char *zeros =3D NULL; - const char *name, *identifier; - unsigned int namelen; + char *zeros =3D NULL, *modname_str =3D NULL; + const char *name, *identifier, *modname; + unsigned int namelen, modnamelen; =20 /* We're looking for a section relative symbol */ if (!sym->st_shndx || get_secindex(info, sym) >=3D info->num_sections) @@ -1552,7 +1553,12 @@ void handle_moddevtable(struct module *mod, struct e= lf_info *info, if (ELF_ST_TYPE(sym->st_info) !=3D STT_OBJECT) return; =20 - /* All our symbols are of form __mod____device_table. */ + /* + * All our symbols are either of form + * __mod____device_table + * or + * __mod_____kmod__device_table + */ if (strncmp(symname, "__mod_", strlen("__mod_"))) return; name =3D symname + strlen("__mod_"); @@ -1564,8 +1570,30 @@ void handle_moddevtable(struct module *mod, struct e= lf_info *info, identifier =3D strstr(name, "__"); if (!identifier) return; + modnamelen =3D namelen; namelen =3D identifier - name; =20 + /* + * In the vmlinuz.o case we want to handle __kmod_ so aliases from + * builtin modules are attributed correctly. + */ + modname =3D strstr(identifier + 2, "__kmod_"); + if (modname) { + modname +=3D strlen("__kmod_"); + modnamelen -=3D (modname - name) + strlen("_device_table"); + modname_str =3D malloc(modnamelen + 1); + /* We don't want to continue if the allocation fails. */ + assert(modname_str); + memcpy(modname_str, modname, modnamelen); + modname_str[modnamelen] =3D '\0'; + } + + if (modname_str) + modname =3D modname_str; + else + modname =3D mod->name; + mod->builtin_name =3D modname; + /* Handle all-NULL symbols allocated into .bss */ if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { zeros =3D calloc(1, sym->st_size); @@ -1597,6 +1625,9 @@ void handle_moddevtable(struct module *mod, struct el= f_info *info, } } free(zeros); + mod->builtin_name =3D NULL; + if (modname_str) + free(modname_str); } =20 /* Now add out buffered information to the generated C source */ diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 1178f40a73f3..34fe5fc0b02c 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -128,6 +128,7 @@ struct module { struct list_head missing_namespaces; // Actual imported namespaces struct list_head imported_namespaces; + const char *builtin_name; char name[]; }; =20 --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45082C77B6C for ; Thu, 6 Apr 2023 19:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240499AbjDFTBj (ORCPT ); Thu, 6 Apr 2023 15:01:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240401AbjDFTBX (ORCPT ); Thu, 6 Apr 2023 15:01:23 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2BB186A5 for ; Thu, 6 Apr 2023 12:01:04 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id b12-20020a6bb20c000000b007585c93862aso24919213iof.4 for ; Thu, 06 Apr 2023 12:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lPtoJrKBH3N2nk7pm0WBiOte1w3zyXs+2rCz5/qKsmI=; b=hUyI2+lLsq229AiQVyYaVj59ugHM5SqIn1EqV+za7saQ4CQrQuFyLKiSrN7COMM2wq 2hzLDZ2jSzvMQhrePCF1mFnp6bOK6gTDVT0Sdcs2Gt7pFRXg2/Y0D2mRwnmeW1c2HRrt tHx/vzeR2O6es87fnmCvObeGTqohq0bevkCC/52BlAmGKwhn06UDwDJWkrQCFxeG/cO5 k8LwrAhU2HIGN0M4vWvREdfDV5qSrHzRBdVCMLi/4Cg+v91i8FqB/AbFr/DlchYSeU10 AEHuG4UVpMbPj6YBUDNyGrUXQYIVmo4729n+mECFyhng3QYE5BBZHs5IX6caMnqNoXWo cAXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807663; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lPtoJrKBH3N2nk7pm0WBiOte1w3zyXs+2rCz5/qKsmI=; b=mK/5F/8zDl+mU5NkbjOHhBYPYRnQ4pHCk0rnTlJXNMxXviJYrjksUzAKBuLf6zs/GX RsrVsuOobuzlpv9phoGH8Ayf1M1traGKovXdcKySQ3rqfI6MnOK47kwe3Uhmyqw7H6Wi M8KSYYbFNxMFSmh/tGrRWfcTEI4DQ5rExVnCXeGxfP+lTKrhJVlcjEXSD5ujGbPOtbll mqnhHsqWTl4EP9x/jpwTR3xRWxEvds6ZGRXYVIacWAbM9XmmG+BTer3qVmXsUTRCgyXH CWvlwkoa5IeFZt/bYo5RPZNveDXsxIsTUWT232mI5ovfuoF5y4c3dsGKc7z89GuorquS kgpA== X-Gm-Message-State: AAQBX9eVaZgeR/XdTJ+rhX8iU+6E3+cNQHmFD+5gpRKRzH3NsZQRltyF iQt5Y8xQeBLJU+VkpHG6bynBM2Bvt77hp04= X-Google-Smtp-Source: AKy350b3ywgYGOuNRaHCfri+YC25Y0XY6ETeOx4MfHOdbQbf18wi5MjpLqXr6pg04A8qD1H12AIVIIUEY6rzGOQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:85ae:0:b0:3ec:dc1f:12dd with SMTP id d43-20020a0285ae000000b003ecdc1f12ddmr6262286jai.6.1680807663728; Thu, 06 Apr 2023 12:01:03 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:25 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-7-allenwebb@google.com> Subject: [PATCH v10 06/11] modpost: Add -b option for emitting built-in aliases From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds a command line option for writing the match-id based built-in aliases to a file. A future patch extends file2alias.c to support this command. The -b option accepts the output path as a parameter and requires vmlinuz.o to be one of the input files for the aliases to be found. Signed-off-by: Allen Webb --- scripts/mod/modpost.c | 30 ++++++++++++++++++++++++++++-- scripts/mod/modpost.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index efff8078e395..2e452aec0fc6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2173,6 +2173,19 @@ static void write_if_changed(struct buffer *b, const= char *fname) write_buf(b, fname); } =20 +/* Write the builtin aliases to the specified file. */ +static void write_builtin(const char *fname) +{ + struct buffer buf =3D { }; + struct module *mod; + + list_for_each_entry(mod, &modules, list) + buf_write(&buf, mod->modalias_buf.p, mod->modalias_buf.pos); + + write_if_changed(&buf, fname); + free(buf.p); +} + static void write_vmlinux_export_c_file(struct module *mod) { struct buffer buf =3D { }; @@ -2329,13 +2342,23 @@ int main(int argc, char **argv) { struct module *mod; char *missing_namespace_deps =3D NULL; - char *dump_write =3D NULL, *files_source =3D NULL; + char *builtin_write =3D NULL, *dump_write =3D NULL, *files_source =3D NUL= L; int opt; LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; =20 - while ((opt =3D getopt(argc, argv, "ei:mnT:o:awENd:")) !=3D -1) { + while ((opt =3D getopt(argc, argv, "b:ei:mnT:o:awENd:")) !=3D -1) { switch (opt) { + case 'b': + /* + * Writes the match-id based built-in module aliases to + * the specified path. + * + * vmlinuz.o needs to be one of the input files for the + * aliases to be found. + */ + builtin_write =3D optarg; + break; case 'e': external_module =3D true; break; @@ -2398,6 +2421,9 @@ int main(int argc, char **argv) write_mod_c_file(mod); } =20 + if (builtin_write) + write_builtin(builtin_write); + if (missing_namespace_deps) write_namespace_deps_files(missing_namespace_deps); =20 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 34fe5fc0b02c..c55a6aeb46bf 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -123,6 +123,7 @@ struct module { bool has_init; bool has_cleanup; struct buffer dev_table_buf; + struct buffer modalias_buf; char srcversion[25]; // Missing namespace dependencies struct list_head missing_namespaces; --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C1FDC7618D for ; Thu, 6 Apr 2023 19:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240503AbjDFTBs (ORCPT ); Thu, 6 Apr 2023 15:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240415AbjDFTB2 (ORCPT ); Thu, 6 Apr 2023 15:01:28 -0400 Received: from mail-io1-xd49.google.com (mail-io1-xd49.google.com [IPv6:2607:f8b0:4864:20::d49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0D069EE1 for ; Thu, 6 Apr 2023 12:01:05 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id c5-20020a6b4e05000000b007601d480935so5655456iob.10 for ; Thu, 06 Apr 2023 12:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Bt77I86eFgSbNaHK2t0i9/m/bTrUBRuYsHv7CbhjIr4=; b=gGaKPKflAxPJskJy8MYWIZ1zGy8JetUF3tcjeHXdaxT9RttPBdGV08CwKIrPIo+1+v GdrlN+UenxsaTd6j37BEg+IeE8RAXAb1nZvuujxF1SDejaQ6L5VlOT1mPFNxmzdShJ42 jWDSXooi1wn60L0/ZPaJqCSHCabEVM5k2IuBzu+3e1Bjl45I1n69jie8qj9ZKPhH3FAv 6nUSYGmVucJp1xtsyijza3z9sodintasi2zjYpdAdjOZjD04JaBOCzqMbvksTqMA21+e HsOsDewz6OvWSPAX4YEGOl6qFQS4nhG23kRhNad8SEYLTI9+httLSlZo5osesgMiNws/ 7fhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bt77I86eFgSbNaHK2t0i9/m/bTrUBRuYsHv7CbhjIr4=; b=hgmD8GFY8/8qgXgq2uZ0bWThU2kOVgnKNwi+SFEc/mUJ9g21wSx/wUxSEv3BwxPGGZ TLWFiVbssm5/9TxY3lSKurGu7nVnVINZncUGWYqRa5jCoRLMP8IbId7GptuHuQNggFIH phgLH7XIV4PK3YqJh/o6I3I9fsApVOUz+pGF6BaYZ9w26dsT3/AdnVPoO0kdmZLviQDi dBF21Fe4P59blGnScqRVxhwP8GaxEHEvr6kptfIWSvXkXEV/u0WabPM2Xsccx4U2Fz+0 KLL1Txmz7c+a6Oyj/+1QV47WyDLPQdDHBKp+xvzDs+fYLpXntdBkg9aEci0m8jqWZ/Tt tNEg== X-Gm-Message-State: AAQBX9e0jTAocf8s1bRfQ2hKBgg5E821rGZh7t6PnhZhGQInFDR+MHqt qG/4Nx2bggNX872W0syhb1PJ0VonN88B0Lc= X-Google-Smtp-Source: AKy350YvGrGN4n61kxqDKxiBKleyueyiQrPvC6O+CnLmm0EGLHXB3+GJdstqxviJ7IrnooMhhcchZlrK/+eB4BI= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:848e:0:b0:408:f9aa:a54d with SMTP id f14-20020a02848e000000b00408f9aaa54dmr5772053jai.6.1680807664892; Thu, 06 Apr 2023 12:01:04 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:26 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-8-allenwebb@google.com> Subject: [PATCH v10 07/11] file2alias.c: Implement builtin.alias generation From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This populates the mod->modalias_buf with aliases for built-in modules when modpost is run against vmlinuz.o. Signed-off-by: Allen Webb --- scripts/mod/file2alias.c | 61 ++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 21 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b392d51c3b06..3793d4632b94 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -233,6 +233,8 @@ static void do_usb_entry(void *symval, add_wildcard(alias); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name= ); } =20 /* Handles increment/decrement of BCD formatted integers */ @@ -377,9 +379,13 @@ static void do_of_entry_multi(void *symval, struct mod= ule *mod) *tmp =3D '_'; =20 buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name= ); strcat(alias, "C"); add_wildcard(alias); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, mod->builtin_name= ); } =20 static void do_of_table(void *symval, unsigned long size, @@ -611,12 +617,18 @@ static void do_pnp_device_entry(void *symval, unsigne= d long size, =20 buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"pnp:d%s*\");\n", *id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", + *id, mod->builtin_name); =20 /* fix broken pnp bus lowercasing */ for (j =3D 0; j < sizeof(acpi_id); j++) acpi_id[j] =3D toupper((*id)[j]); buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", + acpi_id, mod->builtin_name); } } =20 @@ -638,6 +650,8 @@ static void do_pnp_card_entries(void *symval, unsigned = long size, const char *id =3D (char *)(*devs)[j].id; int i2, j2; int dup =3D 0; + char acpi_id[PNP_ID_LEN]; + int k; =20 if (!id[0]) break; @@ -663,19 +677,23 @@ static void do_pnp_card_entries(void *symval, unsigne= d long size, } =20 /* add an individual alias for every device entry */ - if (!dup) { - char acpi_id[PNP_ID_LEN]; - int k; - - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"pnp:d%s*\");\n", id); - - /* fix broken pnp bus lowercasing */ - for (k =3D 0; k < sizeof(acpi_id); k++) - acpi_id[k] =3D toupper(id[k]); - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); - } + if (dup) + continue; + + buf_printf(&mod->dev_table_buf, + "MODULE_ALIAS(\"pnp:d%s*\");\n", id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias pnp:d%s* %s\n", + id, mod->builtin_name); + + /* fix broken pnp bus lowercasing */ + for (k =3D 0; k < sizeof(acpi_id); k++) + acpi_id[k] =3D toupper(id[k]); + buf_printf(&mod->dev_table_buf, + "MODULE_ALIAS(\"acpi*:%s:*\");\n", acpi_id); + if (mod->builtin_name) + buf_printf(&mod->modalias_buf, "alias acpi*:%s:* %s\n", + acpi_id, mod->builtin_name); } } } @@ -1476,10 +1494,13 @@ static void do_table(void *symval, unsigned long si= ze, size -=3D id_size; =20 for (i =3D 0; i < size; i +=3D id_size) { - if (do_entry(mod->name, symval+i, alias)) { - buf_printf(&mod->dev_table_buf, - "MODULE_ALIAS(\"%s\");\n", alias); - } + if (!do_entry(mod->name, symval + i, alias)) + continue; + buf_printf(&mod->dev_table_buf, "MODULE_ALIAS(\"%s\");\n", alias); + if (!mod->builtin_name) + continue; + buf_printf(&mod->modalias_buf, "alias %s %s\n", alias, + mod->builtin_name); } } =20 @@ -1554,10 +1575,8 @@ void handle_moddevtable(struct module *mod, struct e= lf_info *info, return; =20 /* - * All our symbols are either of form - * __mod____device_table - * or - * __mod_____kmod__device_table + * All our symbols are of form + * __mod_____kmod__device_table */ if (strncmp(symname, "__mod_", strlen("__mod_"))) return; --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04A54C7618D for ; Thu, 6 Apr 2023 19:01:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240520AbjDFTBw (ORCPT ); Thu, 6 Apr 2023 15:01:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240422AbjDFTBa (ORCPT ); Thu, 6 Apr 2023 15:01:30 -0400 Received: from mail-il1-x14a.google.com (mail-il1-x14a.google.com [IPv6:2607:f8b0:4864:20::14a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 599929039 for ; Thu, 6 Apr 2023 12:01:06 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id s1-20020a92ae01000000b0032637be81d1so15770465ilh.4 for ; Thu, 06 Apr 2023 12:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=EIFZuvNlh3Q7f5viDBmDdFqHrpvMkDaR3sC9sXOJCEg=; b=r6Dgw36L4ye+f7TRQYGeV5tzr0btpwq3zzgs/UuXhg7VhxHkEGdn4IEj/h2PQMM8C7 9XrmV58b2OYGBa/Itz+04VD1lyNfP8oKVgBL+a+JqxD9bgvLCoGGT9xlOS7M7FSZhlrL dgPrDoQF1NMokITcEqaqE16eLq+/TyrGqoh7gwe5XUJYnNmAwK+1UyWGWYmy5FrIUyET RBrF9++/dM7QoNSpDAic5FyiBVC0USYGzK5MLgC687r/qXuqx0qG4J/VlJlQEiwErT5K pXhpKWhcW9txjXhgoS8Wh4mQInW++2qbyZT76CeylXl4fLCs7gG2hexuiYdjLRP04I53 0URw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807665; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EIFZuvNlh3Q7f5viDBmDdFqHrpvMkDaR3sC9sXOJCEg=; b=SIqAvB+EmJyYJoLNVPMPNxJPrrHfnKMVo8oGjfaYR7ltMdpzbRjmYO3JyDhyTe4ykZ B7bGSavjJEtTrO+exY0Min4yuf0M/0Cca5Kw6G6u+/TFmDZo1lEFa+zguMKkg3PExBnY IytFY/6nd6CxiLjnh3lOwP0dC+5gEC3vjgxm619AYUZU61+1DRUROUC/M95X5IcQyHE7 oXtty7gcjZ0xWVpDurAmYtIT+SRjUPALtQvb4O3UBjhBCapax9cg/fhY6kpoamhnVApO l4qvFYQ9kq7S+rItJ7mFSmJtfc5n30gmJBnkmir/mzk7QPKy/8l5hi/IZ80e6k+mgw4+ eHiA== X-Gm-Message-State: AAQBX9cvLjgjgLT39Bcwtezk0LAPwuvokdUS3IdCAQFrcU8CPCzJe97y M2Z23DwFMYJgqEIIopTeSrQ2rftD+GHVcKo= X-Google-Smtp-Source: AKy350YazP6AHiQUBJHLnELBlt24GFwGrksJ3FmwYx1omjP2DXfHXKkoCpwyla4mFW8rQJlG/AJrwns8MJ8tans= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a05:6e02:f44:b0:310:9afc:aa6 with SMTP id y4-20020a056e020f4400b003109afc0aa6mr6249545ilj.0.1680807665734; Thu, 06 Apr 2023 12:01:05 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:27 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-9-allenwebb@google.com> Subject: [PATCH v10 08/11] build: Add modules.builtin.alias From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Generate modules.builtin.alias using modpost and install it with the modules. Signed-off-by: Allen Webb --- .gitignore | 1 + Makefile | 1 + scripts/Makefile.modpost | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 13a7f08a3d73..ddaa622bddac 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ modules.order /System.map /Module.markers /modules.builtin +/modules.builtin.alias /modules.builtin.modinfo /modules.nsdeps =20 diff --git a/Makefile b/Makefile index a2c310df2145..43dcc1ea5fcf 100644 --- a/Makefile +++ b/Makefile @@ -1578,6 +1578,7 @@ __modinst_pre: fi @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.ord= er @cp -f modules.builtin $(MODLIB)/ + @cp -f modules.builtin.alias $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ =20 endif # CONFIG_MODULES diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 0980c58d8afc..e3ecc17a7a19 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -15,6 +15,7 @@ # 2) modpost is then used to # 3) create one .mod.c file per module # 4) create one Module.symvers file with CRC for all exported symbols +# 5) create modules.builtin.alias the aliases for built-in modules =20 # Step 3 is used to place certain information in the module's ELF # section, including information such as: @@ -63,6 +64,20 @@ modpost-args +=3D -T $(MODORDER) modpost-deps +=3D $(MODORDER) endif =20 +ifneq ($(wildcard vmlinux.o),) +output-builtin.alias :=3D modules.builtin.alias +modpost-args +=3D -b .modules.builtin.alias.in +.modules.builtin.alias.in: $(output-symdump) + @# Building $(output-symdump) generates .modules.builtin.alias.in as a + @# side effect. + @[ -e $@ ] || $(MODPOST) -b .modules.builtin.alias.in vmlinux.o + +$(output-builtin.alias): .modules.builtin.alias.in + sort -o $@ $^ + +__modpost: $(output-builtin.alias) +endif + ifeq ($(KBUILD_EXTMOD),) =20 # Generate the list of in-tree objects in vmlinux --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB8C0C77B6E for ; Thu, 6 Apr 2023 19:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240541AbjDFTBz (ORCPT ); Thu, 6 Apr 2023 15:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240424AbjDFTBb (ORCPT ); Thu, 6 Apr 2023 15:01:31 -0400 Received: from mail-io1-xd4a.google.com (mail-io1-xd4a.google.com [IPv6:2607:f8b0:4864:20::d4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29EF8A5C9 for ; Thu, 6 Apr 2023 12:01:07 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id g7-20020a056602242700b00758e7dbd0dbso25414962iob.16 for ; Thu, 06 Apr 2023 12:01:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Ei4XEWjw7tArTwCoMKhp2ugctsL7jq49nRaYDRBL1Mc=; b=fbhRqzlGZlbPiWZ5IBGIy4z7rckgpL+76StH6hDf38wyBwByXbCIsFAmlVE0cVG5TK HqsTdsJmsOQJn26fMUBbDBhi697JYKpNT9cxQeU2fDWUSLG/eByrdUnKIe23vrDVZxqf ZBP1v4gu3dj1CHb/wtHjIhqoU1bMKJKU3wrEELXyN2gGsZyVLOip7UnrYagQr/ev81xN b3Bd3vKO5r1GVoi09bRFAB8/a7Y+D6JuDR595SthHnsolBMZsbGW92HOBuSfhM/J8OsN ba5cd5hdIpxcz5JXh8vvJQADy3Ad8PB/eaqfwUiX7uO/j4zE7x5OlmQhexuRZ9/HWi41 5dOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807666; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ei4XEWjw7tArTwCoMKhp2ugctsL7jq49nRaYDRBL1Mc=; b=CL0EC7BaelCRxESnylAzxu3K1VciIDWC1YF7OF+waL52iqhD3hO65vIW7oLDPTnSof SxsKbVLMNyRjjPBhTUYzjGkQG+CxqF8Ootd3WcNJF+CetmAo+9QA0trFEGvgdX++TWXt 5D0jrCh9xjh8r+kk0lFSs0LS4GTqeOvF00SBBAnQPGhknk1vflSPURZj8aF9FiP3XeoZ jwJKvX54j0aHOVl8LBSrI0rR7qSCgvSVU367sSiyAeSU1hMOvSzxA4lfPhdZvZkESKCE urrdJliAIWrnLL7Ft+GVats2CnHIEImEpFkyjle7o8K9bZnxowFM9AV7bLVvwBNgqXtA iddA== X-Gm-Message-State: AAQBX9fwjzCV4EBwGg4wRxqfpEttKaDlcxcuNF4N3FQ9pLjuH3qeSjtf qd3w8pW0FatRhtigL3R88+lUjgRTG593J7k= X-Google-Smtp-Source: AKy350ZZbJ29Gs9P2JWFiLO/pUBF8z9KEDzLtRKohDDgzI4f5p+saGHIi3qNgDRvjyVBK16Y4yqOOCNY933bmd4= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a02:2a45:0:b0:406:c43f:6320 with SMTP id w66-20020a022a45000000b00406c43f6320mr4089875jaw.0.1680807666582; Thu, 06 Apr 2023 12:01:06 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:28 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-10-allenwebb@google.com> Subject: [PATCH v10 09/11] Documentation: Include modules.builtin.alias From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update the documentation to include the presense and use case of modules.builtin.alias. Reviewed-by: Luis Chamberlain Signed-off-by: Allen Webb --- Documentation/kbuild/kbuild.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.= rst index 5202186728b4..b27c66c3ca9e 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -17,6 +17,13 @@ modules.builtin This file lists all modules that are built into the kernel. This is used by modprobe to not fail when trying to load something builtin. =20 +modules.builtin.alias +--------------------- +This file lists all match-id based aliases for modules built into the kern= el. +An example usage of the built-in aliases is to enable software such as +USBGuard to allow or block devices outside of just the vendor, product, and +device ID. This enables more flexible security policies in userspace. + modules.builtin.modinfo ----------------------- This file contains modinfo from all modules that are built into the kernel. --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 412F0C77B70 for ; Thu, 6 Apr 2023 19:01:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240545AbjDFTB5 (ORCPT ); Thu, 6 Apr 2023 15:01:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240386AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86BE8AD08 for ; Thu, 6 Apr 2023 12:01:08 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54bfc4e0330so48451257b3.3 for ; Thu, 06 Apr 2023 12:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807667; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M+j5aQ/96ezpNDW1vgfpLxhNNS1dVHH3UOwyvtk8Itw=; b=HgrdJsMEOQPONPSR/Gb7+Is6FMUn6IWRnMnV/yUeEnh9uu0LZ2hdI58AZun+fEfq85 56LiwK9S6fceIM6v9s3vEBVF57PerYY32kMf0s7egW/xPmg3O7NCHUhLURdTFjIkJHar fx19aLOd1cqYDPTWFpT0o7ic73WoYVXPvWcbBo6hmuKyL9rrkGVMofD+uh8lAPLyI8Rk 1xUS5G9H9IddFzzrRVUOTB7GlRX0gqwpxniORH5FrVG7jlZpVZkr7+GGgGje7u2PJxEf 9iiL8N4eQBlRopxXgJVrHAB/6K8INKutqicQk1VMw/ljc89khh1DhFrL2L+vVFKvojZk EYiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807667; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=M+j5aQ/96ezpNDW1vgfpLxhNNS1dVHH3UOwyvtk8Itw=; b=kNZ+ICaXVoM0yeicTjGGz1bzdVoq5j/hZE4nr4YEF+YbA+t0xdd+94zle5yNOYKN+V SKH2GYK0X/4o/jXRMGQtyCK/d7mc5+fT2TUo4rFaz/q99eGW6O7G5pz2EE0DBJd4eF1E MRZJ8hZL82vlKTjNHwTGZeqgtDRH6LvCEzvEDeYRV14BVuomSbGBRrRUpVc7gchFCyd4 oFJ3Um3+547HXFiSd3+Nzw+O7/SmcCnByhuNmrI/IL4chfVCBdFwNty0MMeXgAY+S7cB n2umPPIZ2NjPlHzxC86ZQacFIP3rIzwyV74ZjeNVe8skAwdcX3WCDDl9vd3Vs8VK6b53 qwHA== X-Gm-Message-State: AAQBX9dB1zZ8/kgsRHQo4t2O/wpAc6xf+gp5zs2LpzTIOMraJiLS1Ybh DWghkEPoiKPWJhhza1F+h31RUiuuieOopRo= X-Google-Smtp-Source: AKy350ZPBPvYArlTUHfBAIsSIdCLRqDyqZwRoWsoQhyrepd+MVYiDIkO59WJizadi3iwpqKF3i7yQRnRE3QGOEQ= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a25:76c6:0:b0:b8b:ee74:c9d4 with SMTP id r189-20020a2576c6000000b00b8bee74c9d4mr251123ybc.12.1680807667734; Thu, 06 Apr 2023 12:01:07 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:29 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-11-allenwebb@google.com> Subject: [PATCH v10 10/11] Documentation: Update writing_usb_driver for built-in modules From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Built-in modules that set id_table need to set MODULE_DEVICE_TABLE so update the documentation accordingly. Signed-off-by: Allen Webb --- Documentation/driver-api/usb/writing_usb_driver.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Document= ation/driver-api/usb/writing_usb_driver.rst index 95c4f5d14052..5f38e3bd469a 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -128,6 +128,9 @@ single device with a specific vendor and product ID:: }; MODULE_DEVICE_TABLE (usb, skel_table); =20 +The ``MODULE_DEVICE_TABLE`` should also be set for built-in USB drivers +that provide an id_table, so that tools like USBGuard can properly +associate devices with your driver. =20 There are other macros that can be used in describing a struct :c:type:`usb_device_id` for drivers that support a whole class of USB --=20 2.39.2 From nobody Wed Sep 17 11:26:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A417C76196 for ; Thu, 6 Apr 2023 19:02:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240402AbjDFTCD (ORCPT ); Thu, 6 Apr 2023 15:02:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240450AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -0400 Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B981AD3A for ; Thu, 6 Apr 2023 12:01:09 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id a3-20020a92c543000000b0032651795968so12366753ilj.19 for ; Thu, 06 Apr 2023 12:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lXaHngygoOShOtLfr1dWwTlpzanuSNfDsA9/IVCyMM4=; b=A1qC/ZvuARpF4aifJXh0p0le494sYKU2NUrJtNd2o8ZvihCjDaf3+R7KzU/ysrpbl6 l4vRFYVToK0UOMs0pZfZJ7KBI+Rl41ceZohihh9yw628OH8pKSweYgOGEyjX53rN+MH3 u2r5VzZepyIuhRLZEHGDRHYR4Yryg2rfMG46aAd7Jca5I7jedUgP1ewH8NgnLcVyakEp F4H5kVYuwj8RvLh0MhgIVykT7rtStfd74mo/DgYwCZTwVY2UqPmjoOLrZ57Eg7pCyh03 BpB549iKmEZJpj+E0ENtaR6aAv1+3vU3S/3z9qiLV4svNL23ganVPoSrhWkMrbQjfGbE QLFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680807668; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lXaHngygoOShOtLfr1dWwTlpzanuSNfDsA9/IVCyMM4=; b=RuTkQC1Sc9/U/wg/sCXeJfJ2Px/12rO/x7KVnWZ1mUVuT143Gv36s5wqYEiJ4PPdWx WRSk1eEZ1lStfCXqD0bgCXuwdIN2/IwEQEZiHJbubitOTUIeKlUSTMRmR5614jhU2xAO Ucv72cIlfyFDduD6rintuguCXjFgQYDfUbNHbuzetL8Ly8kiK6n5zQoYXrqI/IIey+N9 7V2VyoPAjlBGRmmOfZ90vxSWdhr9ytTqqCdR/BgbhClzopIxp5PWEKCMxKB1mnyNLaaV g62g9F1FmZBNSqUrD0KIR9XuCg2BMKhYJHIWwhLqK61bgBLL6Zr/UTJBmBmIyliB6QVZ VKJA== X-Gm-Message-State: AAQBX9fpZOGP0ZllxcLzb3YZfZS8fjJpFRd+anOoDMc4BIBmXEH1FnTc FLuT5QZl/gec3CsjyA7DEBGxubiS4SclE6U= X-Google-Smtp-Source: AKy350Y3vePEPTjTofpsZaUJlnNunFT2KZcMeGuMTuCI/IqR0X3Td2aohNhIvplwI6YzX9YZIveMg5tfNSLS/1k= X-Received: from allenwebb.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:12e8]) (user=allenwebb job=sendgmr) by 2002:a05:6e02:d44:b0:326:315:f3d with SMTP id h4-20020a056e020d4400b0032603150f3dmr6023365ilj.1.1680807668678; Thu, 06 Apr 2023 12:01:08 -0700 (PDT) Date: Thu, 6 Apr 2023 14:00:30 -0500 In-Reply-To: <20230406190030.968972-1-allenwebb@google.com> Mime-Version: 1.0 References: <20221219204619.2205248-1-allenwebb@google.com> <20230406190030.968972-1-allenwebb@google.com> X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230406190030.968972-12-allenwebb@google.com> Subject: [PATCH v10 11/11] Documentation: add USB authorization document to driver-api From: Allen Webb To: "linux-modules@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: gregkh@linuxfoundation.org, mcgrof@kernel.org, christophe.leroy@csgroup.eu, nick.alcock@oracle.com, Allen Webb Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a user-facing USB authorization document, but it is midding details a driver should have developer, so add them in a new document. Signed-off-by: Allen Webb --- .../driver-api/usb/authorization.rst | 71 +++++++++++++++++++ Documentation/driver-api/usb/index.rst | 1 + 2 files changed, 72 insertions(+) create mode 100644 Documentation/driver-api/usb/authorization.rst diff --git a/Documentation/driver-api/usb/authorization.rst b/Documentation= /driver-api/usb/authorization.rst new file mode 100644 index 000000000000..383dcc037a15 --- /dev/null +++ b/Documentation/driver-api/usb/authorization.rst @@ -0,0 +1,71 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Device Authorization +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This document is intended for driver developers. See +Documentation/usb/authorization.rst if you are looking for how to use +USB authorization. + +Authorization provides userspace a way to allow or block configuring +devices early during enumeration before any modules are probed for the +device. While it is possible to block a device by not loading the +required modules, this also prevents other devices from using the +module as well. For example someone might have an unattended computer +downloading installation media to a USB drive. Presumably this computer +would be locked to make it more difficult for a bad actor to access the +computer. Since USB storage devices are not needed to interact with the +lock screen, the authorized_default sysfs attribute can be set to not +authorize new USB devices by default. A userspace tool like USBGuard +can then vet the devices. Mice, keyboards, etc can be allowed by +writing to their authorized sysfs attribute so that the lock screen can +still be used (this important in cases like suspend+resume or docks) +while other devices can be blocked as long as the lock screen is shown. + +Sysfs Attributes +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Userspace can control USB device authorization through the +authorized_default and authorized sysfs attributes. + +authorized_default +------------------ + +Defined in ``drivers/usb/core/hcd.c`` + +The authorized_default sysfs attribute is only present for host +controllers. It determines the initial state of the authorized sysfs +attribute of USB devices newly connected to the corresponding host +controller. It can take on the following values: + ++---------------------------------------------------+ +| Value | Behavior | ++=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D+ +| -1 | Authorize all devices except wireless USB | ++-------+-------------------------------------------+ +| 0 | Do not authorize new devices | ++-------+-------------------------------------------+ +| 1 | Authorize new devices | ++-------+-------------------------------------------+ +| 2 | Authorize new internal devices only | ++---------------------------------------------------+ + +Note that firmware platform code determines if a device is internal or +not and this is reported as the connect_type sysfs attribute of the USB +port. This is currently supported by ACPI, but device tree still needs +an implementation. Authorizing new internal devices only can be useful +to work around issues with devices that misbehave if there are delays +in probing their module. + +authorized +---------- + +Defined in ``drivers/usb/core/sysfs.c`` + +Every USB device has an authorized sysfs attribute which can take the +values 0 and 1. When authorized is 0, the device still is present in +sysfs, but none of its interfaces can be associated with drivers and +modules will not be probed. When authorized is 1 (or set to one) a +configuration is chosen for the device and its interfaces are +registered allowing drivers to bind to them. diff --git a/Documentation/driver-api/usb/index.rst b/Documentation/driver-= api/usb/index.rst index cfa8797ea614..ffe37916f99f 100644 --- a/Documentation/driver-api/usb/index.rst +++ b/Documentation/driver-api/usb/index.rst @@ -7,6 +7,7 @@ Linux USB API usb gadget anchors + authorization bulk-streams callbacks dma --=20 2.39.2