Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp3447158pxb; Sun, 20 Feb 2022 20:34:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJx861KVIUt+7hIIWlqmE2iy1W7O2GvDLx/2vHib2ngf6J6Ouz/LkwsNpkXZgKqRRpghPR8c X-Received: by 2002:a17:902:d892:b0:14e:e074:7ff7 with SMTP id b18-20020a170902d89200b0014ee0747ff7mr17363376plz.29.1645418085347; Sun, 20 Feb 2022 20:34:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645418085; cv=none; d=google.com; s=arc-20160816; b=Tlw+X06CM2mYh3zv1RCLUzzQUVxHwwj3oml2yPZb3x8hYj+VDfUfbkDSM+mM4LHRy0 TZlmS8SC4yk87HBuy7qD9DjWCTonwkF3y9lOZKT8hAEB1GzrUxMo5jq5ZVu984nyI/kh iwgdFxKL8MwbndvlC3y1e44AOJ2/DTnYSNldOPn6osfJ2F7JkftqUBOIyu8aB+6Z5ubf Gc2aSdr5Gpf+9oMgX08eKA9o5W6P3KQxhXD1majVjHrXfl8taZPq/zM4ureSpr0Z437t /LlgA71s2bYKALAQ7vuG3i/IfcHzwel0N0iISJ5czMGF7KZAscmt2oFOv5C6hFwvsPX2 Okug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=F5f/kL+0aMhHz+Nq+RRy43kIzhdiGXtGw0H4LTGmRQU=; b=wnzkPZ55c6iMDDeSwf/IMvMy9n9YF6YqypnN/ruTVSOXZl5uBP71uzt/DSBrx9nbPf h+MjMWuVTFB6XJqfILTuL/P3PZLoP+BQKGDBJ5tLv4ecPGwaeQ1PlNUgO1uqerFWEsbU 6JcV6KvKHplRXrWC2W8Zor23EEasXM5cCXSqf41Fi2Hxxtijlp0EJv18Vxh/TPvUk446 oiMXRPVdi9eCb8DX1bij2ix+jnDdfJFc7B04B697BUeiaaW7WUhnoDoKdUSomt5jPt1B 8UniAOOX7SIH7HUo9z8Yrw/iobHT1to+iazEHA5n9mDL/LwjxzPzHRono0JO0z2C+NNK cEOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3si2434840pgj.349.2022.02.20.20.34.29; Sun, 20 Feb 2022 20:34:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbiBTGBQ (ORCPT + 99 others); Sun, 20 Feb 2022 01:01:16 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235791AbiBTGBO (ORCPT ); Sun, 20 Feb 2022 01:01:14 -0500 Received: from smtpproxy21.qq.com (smtpbg702.qq.com [203.205.195.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C7224E3AC for ; Sat, 19 Feb 2022 22:00:52 -0800 (PST) X-QQ-mid: bizesmtp65t1645336839trr4rl57 Received: from localhost.localdomain (unknown [180.102.102.45]) by bizesmtp.qq.com (ESMTP) with id ; Sun, 20 Feb 2022 14:00:32 +0800 (CST) X-QQ-SSF: 01400000002000B0F000B00A0000000 X-QQ-FEAT: g3JGK9LspAkdPLuIKUMkLU2nZN/IgIz7rigkD/y4wwHIiZcWPMTYYVxSLLGxT m2KkDvONxPdWZaRrkdzg8vD18jKhE9xShvpP+19sfwC7zrjVXg9o+NYfqei3hpDHKmAq1X2 juzQFknEnVgHMIb34gDebgeuR6TKaygU04SwpM7wv9C1ChyJVuouxnvOwNCIIQWmPojOPGy uhbgMAGz0ceHlux5K39rjlXEMeOpJ+oCUMzIS8UpXGM2qggLnH4M0VPX1RXaTH6vxwlHt9O FEGctFFE0YYB9TRjemd9zwYMNIPO+u7vrje3TZxF4agTTy0DwaVJxlLnMTlEFGBXpOlgfUq ShZbQufJH4gavj5Hc2XHYF2Za1mcg== X-QQ-GoodBg: 2 From: tangmeng To: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com, tangmeng Subject: [PATCH 03/11] kernel/kmod: move modprobe sysctl to its own file Date: Sun, 20 Feb 2022 14:00:29 +0800 Message-Id: <20220220060029.13434-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kernel/sysctl.c is a kitchen sink where everyone leaves their dirty dishes, this makes it very difficult to maintain. To help with this maintenance let's start by moving sysctls to places where they actually belong. The proc sysctl maintainers do not want to know what sysctl knobs you wish to add for your own piece of code, we just care about the core logic. All filesystem syctls now get reviewed by fs folks. This commit follows the commit of fs, move the modprobe sysctl to its own file, kernel/kmod.c. Signed-off-by: tangmeng --- include/linux/kmod.h | 3 --- kernel/kmod.c | 23 ++++++++++++++++++++++- kernel/sysctl.c | 7 ------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 68f69362d427..9a07c3215389 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h @@ -14,10 +14,7 @@ #include #include -#define KMOD_PATH_LEN 256 - #ifdef CONFIG_MODULES -extern char modprobe_path[]; /* for sysctl */ /* modprobe exit status on success, -ve on error. Return value * usually useless though. */ extern __printf(2, 3) diff --git a/kernel/kmod.c b/kernel/kmod.c index b717134ebe17..54df92abb8dd 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -55,10 +55,31 @@ static DECLARE_WAIT_QUEUE_HEAD(kmod_wq); */ #define MAX_KMOD_ALL_BUSY_TIMEOUT 5 +#define KMOD_PATH_LEN 256 /* modprobe_path is set via /proc/sys. */ -char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH; +static char modprobe_path[KMOD_PATH_LEN] = CONFIG_MODPROBE_PATH; + +#ifdef CONFIG_SYSCTL +static struct ctl_table kern_modprobe_table[] = { + { + .procname = "modprobe", + .data = &modprobe_path, + .maxlen = KMOD_PATH_LEN, + .mode = 0644, + .proc_handler = proc_dostring, + }, + { } +}; + +static __init int kernel_modprobe_sysctls_init(void) +{ + register_sysctl_init("kernel", kern_modprobe_table); + return 0; +} +late_initcall(kernel_modprobe_sysctls_init); +#endif /* CONFIG_SYSCTL */ static void free_modprobe_argv(struct subprocess_info *info) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b41138d64e5e..126d47e8224d 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1791,13 +1791,6 @@ static struct ctl_table kern_table[] = { }, #endif #ifdef CONFIG_MODULES - { - .procname = "modprobe", - .data = &modprobe_path, - .maxlen = KMOD_PATH_LEN, - .mode = 0644, - .proc_handler = proc_dostring, - }, { .procname = "modules_disabled", .data = &modules_disabled, -- 2.20.1