From patchwork Thu Apr 6 19:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203864 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 2D0CBC77B6F for ; Thu, 6 Apr 2023 19:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240354AbjDFTBF (ORCPT ); Thu, 6 Apr 2023 15:01:05 -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 S240337AbjDFTBC (ORCPT ); Thu, 6 Apr 2023 15:01:02 -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 95F4359F2 for ; Thu, 6 Apr 2023 12:00:59 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id l7-20020a0566022dc700b0074cc9aba965so24575551iow.11 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=tB9/KGeA+z9eF9wHvdDOvDRA4oBjPNXiiYItyo6kfVwOl306z//e3CfyWpoCMMA0Ai ioHdnT8Qn8uhj8n8Qe6BiuSYv6a7lRM49pRsa7NFrxlTPwGMDUYaU50NKDvKPX0w6Ax1 9w3PDLVIKH5jYK4qxWwUmnISpYhTEm8qxA7D14IXuL8Gb2QCs1D+OMPEWSn/ZtuBDBaP qZTpKJoMuHNTPOmT/uuipzj2Um8yO/1OTjapTgsy21QgBMJ1OjX3/7a7lqz27KkTRmuW CRuT4R3NnwKTu3Huv5BgqBy9vtdzqq1y3wNw1iuA/pcneFvnd7inQhaK9UWd2gsy19NG XyAQ== X-Gm-Message-State: AAQBX9cZ8dqZ1gowMSfRItfIfZzFBosGSs7UasFkQ9ETfeORWhovlWs4 cQACVmjXlcpRv0qh0q7eR2FeSwpv+o320lQ= 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-usb@vger.kernel.org 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[] = { { .compatible = "rockchip,rk3368-mailbox", .data = &rk3368_drv_data}, { }, }; -MODULE_DEVICE_TABLE(of, rockchp_mbox_of_match); static int rockchip_mbox_probe(struct platform_device *pdev) { From patchwork Thu Apr 6 19:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203865 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 C9167C7618D for ; Thu, 6 Apr 2023 19:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240361AbjDFTBH (ORCPT ); Thu, 6 Apr 2023 15:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239868AbjDFTBE (ORCPT ); Thu, 6 Apr 2023 15:01:04 -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 A2DE59019 for ; Thu, 6 Apr 2023 12:01:00 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id b3-20020a056602274300b007603d89cdc9so2636971ioe.2 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=jJzbn8zeufhzMmfPhbpcnuce7qSClVrZAwRO5yvYAEy9IW1RtP201DbtFIzE6N8Pdu UteOmHUNWrQwpe095mt4Z3vJBHEIH6/XZnj+3y02c7r8Iz9U/Nv/GbR8crW9F/r6S06p upJPiub1j/JrksjU75pB8NQc34xZO7mVE/XI3CZU0aMaZi/A0PmbeE+8KMQWlHVwtYo4 yNJmWEYIkNfzlj7cqato3ETKBfqmx5//+U9UuLgii3HPqhZzIPx/PHa98hJINgaPlgnf O7rzwDotQR+6ubq1YUHOP+sYJk+I/G/WxyUqYq1j0jdlTJzBHZtPIfl/i95CuiIlhfEQ sI7w== X-Gm-Message-State: AAQBX9cIY21pTI4xtyqDxRq5iRtYNWKXDhlUU600DMXWlOnUU7sMc6zv rsjZ+pBzI+UzlCDv0qXJ8coolHakELh4MuM= 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-usb@vger.kernel.org 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) __setup("BusLogic=", blogic_setup); -#ifdef MODULE /*static struct pci_device_id blogic_pci_tbl[] = { { 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[] = { {PCI_DEVICE(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT)}, {0, }, }; -#endif MODULE_DEVICE_TABLE(pci, blogic_pci_tbl); module_init(blogic_init); From patchwork Thu Apr 6 19:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203866 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 F173DC77B6C for ; Thu, 6 Apr 2023 19:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240333AbjDFTBK (ORCPT ); Thu, 6 Apr 2023 15:01:10 -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 S239846AbjDFTBF (ORCPT ); Thu, 6 Apr 2023 15:01:05 -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 774FD93CD for ; Thu, 6 Apr 2023 12:01:01 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id s6-20020a056e02216600b003264c778ef1so13306515ilv.23 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=DIWCPqIplZsfirKbw6e2zpf4a7iIU6/4twf1+wHH/tfKXbeiJ4LqDQez3KqIXKpSOM H2UaoO9yekNWHZwh64ECL/ws1ZAj65gdK44YXSYVFIL0hHQNEl+Oylm5Gc1a70bH+mq1 qeXYWkLb0Z82nBHaS2lSFaN+r6lmqnXE8sAuKuWRWMgnUCteSsFreS289G93wThpTcqR VKq2f/LXPrYaJ0BUV2eGZNYGJ2UpMOwASeMGXBrxScTgw5orjhCW1pdm8V5RTRlP1BxT 0UFCfR/J1TB45B4vGo01tS3SRUdCbRNowAdWSWRKUPMXAydFS2ip9mGagzoT0BFPZiLK lw7A== X-Gm-Message-State: AAQBX9dC1OqHmwR7eCPuKZPJTesUn25FePnYSpRTE1Q/UJS8EBmez9TZ 8lL1qM/xYXSf6qNtNG+Re7Jg0rO22lqvMAA= 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-usb@vger.kernel.org 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[] = { { "stmpe2403", STMPE2403 }, { } }; -MODULE_DEVICE_TABLE(spi, stmpe_id); static struct spi_driver stmpe_spi_driver = { .driver = { From patchwork Thu Apr 6 19:00:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203867 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 86BA0C7618D for ; Thu, 6 Apr 2023 19:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238941AbjDFTBM (ORCPT ); Thu, 6 Apr 2023 15:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240362AbjDFTBH (ORCPT ); Thu, 6 Apr 2023 15:01:07 -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 E0A465FE8 for ; Thu, 6 Apr 2023 12:01:02 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id n17-20020a056e02141100b003259a56715bso25954246ilo.15 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=JCDMqdKTt8Kw7QuOaZoXU93scKd8UHlxcz6j/FmJQxsW/csPnjIX0cBQhpT+qmEdT8 STDU1RO6MY13DkbPWZSaGbFSf9wNTr2xluprbbPz0Gu42VPIq2Zm3MPQZdTCzwXK+ywT a7JIAPq5xVt8WyxkxONnS4K/Ve1J8WygwX/cNYIUwQOInep4S1VfCBOvlIFRlCNFlp4l 8BHi1nBx6SupOONHj4ONahwUA4Lm3PiDONhvz0WYEWZXkGKtCgVztKZgp4gTGIUTXLEw f8BOI1wgaUH9ZplAwaodTz8XFXx6abmqmINUysgAvyuT9H23V/+RI9xBsGmxYj4fajqB 2WZQ== X-Gm-Message-State: AAQBX9eTQor2Bv/r1yHOY97meLN4pXmIH3qOUt8n6M/B/dBoMCALvmQq Znl3eM0QSesFb+Vm6h4KgBalCXKmXyimYSI= 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-usb@vger.kernel.org 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, _description) -#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 which + * 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 driver is + * already loaded. An example is the USB subsystem with its authorized_default + * sysfs attribute. For more details refer to the kernel's Documentation for 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 modules. + * Historically MODULE_DEVICE_TABLE was a no-op for built-in modules, so + * there was nothing to stop different modules from having the same device + * table name and consequently the same alias when building as a module. + * - 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)))) /* Version of form [:][-]. * Or for CVS/RCS ID version, everything but the number is stripped. From patchwork Thu Apr 6 19:00:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203868 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 19A5EC76196 for ; Thu, 6 Apr 2023 19:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240417AbjDFTBa (ORCPT ); Thu, 6 Apr 2023 15:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240351AbjDFTBM (ORCPT ); Thu, 6 Apr 2023 15:01:12 -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 AD5D1975D for ; Thu, 6 Apr 2023 12:01:03 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id s6-20020a056e02216600b003264c778ef1so13306622ilv.23 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=P2lwaaxV/0FytQh9KX4Tr8Kv6DoA9E2UcgmnCDybgereiYqJMX7wJs4vU9gpDGVNSO TUL0KcVNtr0oRyhH2HspglswHsg6MlO2Tz41o7GNBer2CJtqFk5aQf4ZIJzk1qN4RkTl ioFYUTT0omheQd/jGxA151ZytYuty8ZvcDdeeP2RQa9YMFy13xvUqi2/eb16V6xE+vAU m1jW9SBjnQr8FfuszKdOPaIA6iq7bZqt69dFg1ulhqKqdOrf/iz2YNN9HP5jasmb9fFP vd1DEP/iCOA5QTNNwXbUAQW0qxS7qXXvIZWT8SulJ9yFUiEyv/z8F6YM9BJZp+HEIYlu aoDQ== X-Gm-Message-State: AAQBX9e/jnnq5jJhLGAzUxdqM8L63h/tAtCbJiYWCmRMEnogFIQd+UEv MXCuU3cklO+427tYsTpeG5TxHeeHaDA2UnY= 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-usb@vger.kernel.org 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 +#include #include #include @@ -1540,9 +1541,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) { void *symval; - char *zeros = NULL; - const char *name, *identifier; - unsigned int namelen; + char *zeros = NULL, *modname_str = NULL; + const char *name, *identifier, *modname; + unsigned int namelen, modnamelen; /* We're looking for a section relative symbol */ if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) @@ -1552,7 +1553,12 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* 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 = symname + strlen("__mod_"); @@ -1564,8 +1570,30 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, identifier = strstr(name, "__"); if (!identifier) return; + modnamelen = namelen; namelen = identifier - name; + /* + * In the vmlinuz.o case we want to handle __kmod_ so aliases from + * builtin modules are attributed correctly. + */ + modname = strstr(identifier + 2, "__kmod_"); + if (modname) { + modname += strlen("__kmod_"); + modnamelen -= (modname - name) + strlen("_device_table"); + modname_str = malloc(modnamelen + 1); + /* We don't want to continue if the allocation fails. */ + assert(modname_str); + memcpy(modname_str, modname, modnamelen); + modname_str[modnamelen] = '\0'; + } + + if (modname_str) + modname = modname_str; + else + modname = mod->name; + mod->builtin_name = modname; + /* Handle all-NULL symbols allocated into .bss */ if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { zeros = calloc(1, sym->st_size); @@ -1597,6 +1625,9 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, } } free(zeros); + mod->builtin_name = NULL; + if (modname_str) + free(modname_str); } /* 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[]; }; From patchwork Thu Apr 6 19:00:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203869 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 AFBE4C77B6E for ; Thu, 6 Apr 2023 19:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240389AbjDFTBe (ORCPT ); Thu, 6 Apr 2023 15:01:34 -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 S240368AbjDFTBX (ORCPT ); Thu, 6 Apr 2023 15:01:23 -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 BF14783FF for ; Thu, 6 Apr 2023 12:01:04 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id s1-20020a92ae01000000b0032637be81d1so15770374ilh.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=DTIAexqpKWM8KYeqYzmKvc2cixvCRl79Zw4ty7q0co1yw3Cji+o0X4MFcJSoCQhFuk ZcgWKk845/1tCLFke1xIqrrdEwG4GfTO2jaKEiVkObKMmDZC/f7QVt7Iucn/s3ZQAPeM 9QbQSC2rKg4Mybcjs9lhoWRSIaYm0CL9+l377PZrcDWYkpoJSJ89vyytSMr3MxDETygf /daaNbYfCHWJbRfTjDnj86j8cCOjFhKTSZ+WesnzOMeLL1HBL+O8jgCN2CvjobyUKJpq D6p41DdSlU+PZaAWqmtPpSU8Bikn9K4lOPmAyBsUP5HcPecuHigv6O3g3H0l88w+kIG+ 9iMQ== X-Gm-Message-State: AAQBX9fcU02PH7fkLtsJdomh8hlcQYx5m/UbjTA7Qa18heJXDyfb179X MfWvNONh020ROAOyvD4m/zeDh4YUKozIVDs= 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-usb@vger.kernel.org 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); } +/* Write the builtin aliases to the specified file. */ +static void write_builtin(const char *fname) +{ + struct buffer buf = { }; + 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 = { }; @@ -2329,13 +2342,23 @@ int main(int argc, char **argv) { struct module *mod; char *missing_namespace_deps = NULL; - char *dump_write = NULL, *files_source = NULL; + char *builtin_write = NULL, *dump_write = NULL, *files_source = NULL; int opt; LIST_HEAD(dump_lists); struct dump_list *dl, *dl2; - while ((opt = getopt(argc, argv, "ei:mnT:o:awENd:")) != -1) { + while ((opt = getopt(argc, argv, "b:ei:mnT:o:awENd:")) != -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 = optarg; + break; case 'e': external_module = true; break; @@ -2398,6 +2421,9 @@ int main(int argc, char **argv) write_mod_c_file(mod); } + if (builtin_write) + write_builtin(builtin_write); + if (missing_namespace_deps) write_namespace_deps_files(missing_namespace_deps); 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; From patchwork Thu Apr 6 19:00:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203871 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 6A091C76196 for ; Thu, 6 Apr 2023 19:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240480AbjDFTBh (ORCPT ); Thu, 6 Apr 2023 15:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240048AbjDFTB2 (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 C07449EE0 for ; Thu, 6 Apr 2023 12:01:05 -0700 (PDT) Received: by mail-io1-xd49.google.com with SMTP id d204-20020a6bb4d5000000b00758cfdd36c3so24633499iof.0 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=ZaN35oy9Wsiq3hoMNW4lAqduOobOdcj40DHIS2Df0mLYCIvHnNAJDcopL1xctRpNjY QCEAvwRcsT2bzaMqcUuMb+Ko7cLIvFv94eSPI0kKky0vWWKJWjbDm63c6iCXKh9+QYeM tJz3pCCol4+Fj7veeIxV2f3tSBC6L30wXXU4phb9N4yg+S9qShJ9tnDbExxnJ3i+iXiE nGaaCBrEIV+5L00ytn76DQFz62jXBTaCwAwzXIS1RrzQDu5G5RneFs/b2HmbMP3i2AbD HSbjVYENFXdHi8uM0cSWvmtU43+UALvAtGMAmc1BwAX/3UPhQKrqv9Ju2gxH/MCbo/mn 1z5Q== X-Gm-Message-State: AAQBX9f6LZVpg+D/ifJwuSeHXnX+RB2eD/9pTZSjQ9PvQXnNttoApG14 kDuiE15nw6iJjO/DjBELk842CW2ZQqh63VM= 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-usb@vger.kernel.org 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); } /* Handles increment/decrement of BCD formatted integers */ @@ -377,9 +379,13 @@ static void do_of_entry_multi(void *symval, struct module *mod) *tmp = '_'; 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); } static void do_of_table(void *symval, unsigned long size, @@ -611,12 +617,18 @@ static void do_pnp_device_entry(void *symval, unsigned long size, 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 (j = 0; j < sizeof(acpi_id); j++) acpi_id[j] = 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); } } @@ -638,6 +650,8 @@ static void do_pnp_card_entries(void *symval, unsigned long size, const char *id = (char *)(*devs)[j].id; int i2, j2; int dup = 0; + char acpi_id[PNP_ID_LEN]; + int k; if (!id[0]) break; @@ -663,19 +677,23 @@ static void do_pnp_card_entries(void *symval, unsigned long size, } /* 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 = 0; k < sizeof(acpi_id); k++) - acpi_id[k] = 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 = 0; k < sizeof(acpi_id); k++) + acpi_id[k] = 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 size, size -= id_size; for (i = 0; i < size; i += 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); } } @@ -1554,10 +1575,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, return; /* - * 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; From patchwork Thu Apr 6 19:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203870 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 C2204C77B70 for ; Thu, 6 Apr 2023 19:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229825AbjDFTBg (ORCPT ); Thu, 6 Apr 2023 15:01:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240047AbjDFTBb (ORCPT ); Thu, 6 Apr 2023 15:01:31 -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 5BB34A260 for ; Thu, 6 Apr 2023 12:01:06 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id i17-20020a056e020d9100b00325a80f683cso27159428ilj.22 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=k9Xdm31eqr1VPjE1SSTBgdNCGX5JtBvfM2OMb4cjJJ3ZdsPWZN3zw2I/7FzLHBDiP3 uU8IWb2bkoYSDMsnYwyoElli0j+GanPU0VzeMBWI9ndEh16j8BjAdO3/oMUyANr7Bjad /wmDD3zl/5LyiuvQy0P7+bE+peXCsKfDUsLNEeXhMiMhVU6zAOnONXjrpHASOd+W26Ks 4Ts0rX0x5D5vw0hmcbHH6eSKrj/nXVyelSnth9qLIsG/rv0fKo3KkogRp5ZasOP/VGsN MAAScbea7duyW1gWnmEn0LxGTiJpHL4ahGRhUl1bFgLv37uaTd5394CfINnKGoZClT/G tH1w== X-Gm-Message-State: AAQBX9cy/LQZhVMBdrakTOvkgoOSMnFba00jUno464MU43rlfE4CcbJD oDwJb1s/rGMzHBXA+zrlyca1sRIb4z9z8R8= 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-usb@vger.kernel.org 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 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.order @cp -f modules.builtin $(MODLIB)/ + @cp -f modules.builtin.alias $(MODLIB)/ @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/ 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 # Step 3 is used to place certain information in the module's ELF # section, including information such as: @@ -63,6 +64,20 @@ modpost-args += -T $(MODORDER) modpost-deps += $(MODORDER) endif +ifneq ($(wildcard vmlinux.o),) +output-builtin.alias := modules.builtin.alias +modpost-args += -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),) # Generate the list of in-tree objects in vmlinux From patchwork Thu Apr 6 19:00:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203872 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 1A26EC76196 for ; Thu, 6 Apr 2023 19:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239593AbjDFTBl (ORCPT ); Thu, 6 Apr 2023 15:01:41 -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 S240351AbjDFTBb (ORCPT ); Thu, 6 Apr 2023 15:01:31 -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 2C006A5CB for ; Thu, 6 Apr 2023 12:01:07 -0700 (PDT) Received: by mail-il1-x14a.google.com with SMTP id d12-20020a056e020bec00b00325e125fbe5so26335782ilu.12 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=oBH8wMOgM6LyRhZfjeR3N2S2RXDJLPH8C59D/AMA2hViQTL7vfrT9G8vNoAGiZBRna ZUb5vvUgVvNznYUwtf97oHkb6x/OMDYq2aZV0fhqNf43QD7IJi8trwbsDb2WOugS1Dlu YPKYaX6JPA7z2RwO/6Ro80/yErPtTSPb08M2CLkVDH6JpTEIqr2a+FhnUQQy67wMLrYk 3jA58sfnYe6l5VkziMpjRk1IpgZGELmrUjpCcLyQgSsFSXr3+UXUqD1B9aAEoKemc3Ra GtunOmjKLQ1KlEKD189IYHUV5TpWNba3GjnXSnKIh5He58n629cO7hCg9FmAWRwQF25/ wJvA== X-Gm-Message-State: AAQBX9dt619+s2KDXPEPopfxbgmgRY9FKbxY3xdEAG1oTkMtJvmCwtbJ HXesoTTi+n8TDViaJ5ssfZn73QHnB6GcG5A= 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-usb@vger.kernel.org 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. +modules.builtin.alias +--------------------- +This file lists all match-id based aliases for modules built into the kernel. +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. From patchwork Thu Apr 6 19:00:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203873 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 6586FC77B6C for ; Thu, 6 Apr 2023 19:01:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240542AbjDFTBz (ORCPT ); Thu, 6 Apr 2023 15:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240436AbjDFTBc (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 8774FAD0F for ; Thu, 6 Apr 2023 12:01:08 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-54c17fb245dso19868477b3.21 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=LNu5wK9DxeuOGoWlicDEZQ8LhgatUkIpiexBkROXNXdx2l9XG43urKaesyo/lahibD RenBl/HQB/PF9PZngBqKiv2yOYHddkWaMj7P4g3NaSL/2Czjdvuiz6A4V62T1Sbe6UBq g0taIppVInoDcyM76//ncwT+owWxUmp7cxUjLbe8ppy9kbuoeWTakTBb+0ZdNkgOr8tm rMra6KBnKsnSuhte19/rB/QEwRkWcLcaGxnDj1PqHUyiZ45PN4nfFrk7270HfFcZbpAR hjPmg12IhyazOg5AI+QN15HWNS9nngt1H6Ez4Ny+gmVTO4E/TR+LXdlvJ1NRcweJNYmy kS1g== X-Gm-Message-State: AAQBX9fdckgzNHkimAEMiD687RGP7GSBucQ+P5TTtjPC6WqmxgeLDu+y Ca0J7WX398VBsPX7/EqjyiwI55w9phRUe3o= 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-usb@vger.kernel.org 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/Documentation/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); +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. 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 From patchwork Thu Apr 6 19:00:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Allen Webb X-Patchwork-Id: 13203874 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 7F74FC7618D for ; Thu, 6 Apr 2023 19:02:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240546AbjDFTCA (ORCPT ); Thu, 6 Apr 2023 15:02:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240447AbjDFTBc (ORCPT ); Thu, 6 Apr 2023 15:01:32 -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 8BABAAD3C for ; Thu, 6 Apr 2023 12:01:09 -0700 (PDT) Received: by mail-io1-xd4a.google.com with SMTP id c2-20020a6bcc02000000b0075c4c68b5d3so20460284iog.3 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=rTqv1NCg7BFZLUCOufp+6/n9JI91LvmFs9jRSg/DmsGRj0jfWCywRxiENoH0yjwAYe 7mf7jCtLcG6r4sIGIiWgguZhPh2gERihKV5AGAS1z7AhZzLPWm+8fOggvOCUonlvB1/P HTXKj7VbBXPWcURZpbrvvPaQuY7WRm1151/RXU4gYCRpS+BNUZWYThE9D/uW51MnAUSU TKah3Vm5KRV59nXQ27XB/EwnOIUpPLhbDBHny32Y7sW6o2nYc4v0RPZ+RnZny2BotmeO C7rdKmOahwypAmfRuBQ2QnW4gU82sNQJ44xmM+j6WcHN2MR92Lu//TSnIcCJVEqjCfJC Lpsw== X-Gm-Message-State: AAQBX9doSWeB8uK95B1aGTDHv8m+qNX20lBDxXL07IV/mLGqFIuPpI6B C5T2UUHnQz3U9LJE6paUpVWOrORLteNfinI= 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-usb@vger.kernel.org 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 + +==================== +Device Authorization +==================== + +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 +================ + +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 | ++=======+===========================================+ +| -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