From patchwork Sun Dec 31 04:14:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: nathan X-Patchwork-Id: 58231 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1534027BBEA; Sun, 31 Dec 2023 04:20:27 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1F69627BBE9 for ; Sun, 31 Dec 2023 04:20:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJnIx-0006Ro-QI; Sat, 30 Dec 2023 23:20:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJnIw-0006Re-9Z for guix-patches@gnu.org; Sat, 30 Dec 2023 23:20:02 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rJnIw-0003Pc-01 for guix-patches@gnu.org; Sat, 30 Dec 2023 23:20:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rJnIw-0008NK-Do for guix-patches@gnu.org; Sat, 30 Dec 2023 23:20:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68162] [PATCH] initrd: Parse kernel command line and pass module parameters Resent-From: nathan Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 31 Dec 2023 04:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68162 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68162@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170399637732150 (code B ref -1); Sun, 31 Dec 2023 04:20:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 Dec 2023 04:19:37 +0000 Received: from localhost ([127.0.0.1]:45444 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJnIW-0008MT-Ge for submit@debbugs.gnu.org; Sat, 30 Dec 2023 23:19:37 -0500 Received: from lists.gnu.org ([2001:470:142::17]:50804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rJnIS-0008MD-P7 for submit@debbugs.gnu.org; Sat, 30 Dec 2023 23:19:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJnIM-0006Pw-Ae for guix-patches@gnu.org; Sat, 30 Dec 2023 23:19:26 -0500 Received: from mail.nborghese.com ([207.148.28.48]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rJnIJ-0003Ni-M9 for guix-patches@gnu.org; Sat, 30 Dec 2023 23:19:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=062122; bh=lpJhD8Cs+aG+X 7vMPHk5exYrp+PbDHMIxm+720PsnCg=; h=date:subject:to:from; d=nborghese.com; b=cQUoDiSUia/lk+fc6Mg8WjmkE3fueyQ+Ixpwx+hFnSwDwFVsj0N /imqLj9ayBo0LTQgqoyFU+d8boJG1MY024O7URpNU7m8Xqzqh4cSjCQCBIonevCQVCsLd9 esBIcp84xFtAKcx/02cD6hF1056VBhpmCgwaZ0HGJoS+TUm0rA= Received: by nborghese.com (OpenSMTPD) with ESMTPSA id 28837c8c (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Sun, 31 Dec 2023 04:18:51 +0000 (UTC) Date: Sat, 30 Dec 2023 23:14:10 -0500 Message-ID: <87edf3qa0v.fsf@nborghese.com> MIME-Version: 1.0 Received-SPF: pass client-ip=207.148.28.48; envelope-from=nathan_mail@nborghese.com; helo=mail.nborghese.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: nathan X-ACL-Warn: , nathan via Guix-patches X-Patchwork-Original-From: nathan via Guix-patches via From: nathan Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches GUIX's initrd code ignores the kernel command line and always passes no parameters to the modules it loads. This fixes it with command line parsing code that is accurate to what modprobe does. The user's module options, like somemodule.param=val, are properly passed now. It also allows the modprobe.blacklist option to optionally be quoted and normalizes the module names given in the blacklist. modprobe.blacklist="module1,mod-ule2" -> '("module1" "mod_ule2") I tested passing module options with the command line in a VM and on my real system. Tested blacklist code in a VM. I've also attached my code I used to test the commandline parsing function manually. fix bug#55907 https://lists.gnu.org/archive/html/bug-guix/2022-06/msg00157.html From 0cd4f6fb19c96a6be4a0d0851e1cf6dfd7046a27 Mon Sep 17 00:00:00 2001 Message-ID: <0cd4f6fb19c96a6be4a0d0851e1cf6dfd7046a27.1703992381.git.nathan_mail@nborghese.com> In-Reply-To: <626930cbad11e7f5546589fc290b2c95fee97b80.1703992381.git.nathan_mail@nborghese.com> References: <626930cbad11e7f5546589fc290b2c95fee97b80.1703992381.git.nathan_mail@nborghese.com> From: nathan Date: Sat, 30 Dec 2023 22:12:19 -0500 Subject: [PATCH 3/3] linux-modules: Rewrite module-black-list with parse-kernel-cmdline * gnu/build/linux-modules.scm (module-black-list): Use parse-kernel-cmdline. Strip quotes from module names. Normalize module names so they can be properly compared with strings from file-name->module-name. Change-Id: I318006f98844593863246fc89ed1703767794702 --- gnu/build/linux-modules.scm | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/gnu/build/linux-modules.scm b/gnu/build/linux-modules.scm index a54616b2d4..cbce3394e2 100644 --- a/gnu/build/linux-modules.scm +++ b/gnu/build/linux-modules.scm @@ -397,18 +397,25 @@ (define (module-black-list) is specified using 'modprobe.blacklist=MODULE1,MODULE2,...' on the kernel command line; it is honored by libkmod for users that pass 'KMOD_PROBE_APPLY_BLACKLIST', which includes 'modprobe --use-blacklist' and -udev." - (define parameter - "modprobe.blacklist=") - - (let ((command (call-with-input-file "/proc/cmdline" - get-string-all))) - (append-map (lambda (arg) - (if (string-prefix? parameter arg) - (string-tokenize (string-drop arg (string-length parameter)) - %not-comma) - '())) - (string-tokenize command)))) +udev. The names in the returned list are normalized with `normalize-module-name'." + (define target-parameter "blacklist=") + + (let* ((cmdline (parse-kernel-cmdline (call-with-input-file "/proc/cmdline" + get-string-all))) + (modprobe-pair (vhash-assoc "modprobe" cmdline))) + (if modprobe-pair + (map normalize-module-name + (append-map + (lambda (param) + (if (string-prefix? target-parameter param) + (string-tokenize + (string-delete + #\" + (string-drop param (string-length target-parameter))) + %not-comma) + '())) + (cdr modprobe-pair))) + '()))) (define (module-loaded? module) "Return #t if MODULE is already loaded. MODULE must be a Linux module name, -- 2.41.0