From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36D2427CCF6 for ; Thu, 15 May 2025 08:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747296315; cv=none; b=H+MrkkG4yom8tm71n2xbSMnO7SZyiaCmVIOPWi7ZToFyZvt95veDerHsgM23WGv5pM+Op/fbKfGU7CfqXXFMcLrja1AKUQ9Ueyyx0dclG2M2u71mtfa2zpeUo/ICaiXVuEgqW4DpRhCzYMRznYp3/CAyDP+3Ct5MRxYJNxbvcy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747296315; c=relaxed/simple; bh=0tGKkkemugSf6qbz3gshaWCoVsCRbxCI+SQBbX3dIFY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=COcuADjP9JN/tbu/pT0tqJ77Ds5lNh3ISzjaTc0zwlnyMKbxJ2XcFkyFvmM/KboGII4uPltDlLJSYVMwDQ8aHEUBaD1pJpta/uknxRlQYuZDcrFzVfH11M4DPD2PsVh/eMDy2sXa8zD2gnJuwNY1AW17QJYFb5liNh5bN0zKRbk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=QleRWDJ1; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QleRWDJ1" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-3a064a3e143so264747f8f.3 for ; Thu, 15 May 2025 01:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1747296311; x=1747901111; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=edff1LhptN7FQ5Bq2oruaEckY3n2IP7/Je81wTRfspE=; b=QleRWDJ1MjKGuTARD+JMrNkTAxf4HJRsTFLkXkCVtL9CbWW4H8867e4gRrYe6EwAgm XPMtN/ccgxu1Iakt4TGULyjyPIWkeK++REj8S0mb+Lp0Y5BdRQJ1RgMKofZ+1rn3lsyW bxi4phbRhYV5kVMHXtDrnLPMbUHaadKUFkpJh31Uhr5GNhzN3CoyH06OzrvpRMWIGd1p lPNsa58+0OPS7jisV6aHdqQaXvnPOoiqqmJRmt4T6k338Xqel0OrIM7fT7Wlbtpc6I1K tJpyOs9c9HSn4DpSUK56f70L5Bp4sMOeG4KS6HeQFC/D8fEHOlBzkrpRaFUFsy+XNvVH FJ7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747296311; x=1747901111; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=edff1LhptN7FQ5Bq2oruaEckY3n2IP7/Je81wTRfspE=; b=ggEXyymHcwsZoyO2UB0vdHVP1Rt0WNHZclfCyb9TuzXnouSH68sOUslhl05XcGxB5W qiKef9i7gTR8XsTvNoTlJPpKY2KYvT7i2+rjUz5Quni0doZqUkhnPZK1DnrEMmvqRiq0 L34aX+w7pYkTxOkaYKZHPucgrb3Ri+SmFItn4QH/J7QNidh9jv1A9IVtZECt6fBjWtfN 1lF1aTHUE8OH5OuFCneZSuaOTUDgo7RbGB9rnJuKUQ178nBy6563IlAkQZR0gDqHfsy6 IwD15cWk4Zjr23eMUJTtHnfMggjzYQgTdlHlXNfpvMVWEBl6nWxkK2V8JbcSkZQ1cb+X LIhA== X-Forwarded-Encrypted: i=1; AJvYcCX/Bgo5Jm0tCshbaaCbpR79ojY++2aNBnE7W1sH0Qeuzs76RGqXwtULQ7sPww+8atbvIrJmPnXDtS0VmPQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxeC7UKT1NaGlPBEiiKD8EjNWNr4TSsl5gW1YDnplCwH8haJiBt 7jreu4vJ3UPy4rpCDbPz8q2MpmzBzC5n86c60g+gw0tCBI8J7eIXM9khCXkihUY= X-Gm-Gg: ASbGncvOxXvgOa6P063DY2T9zpl+dBHAbZeQOfVLqn/5YtjCaLIHI4SmW0PLX4LbcT3 y0+eNy32qMnls1/3nSEtI6x2jKSTk5Zqi3NSJ6AB1EuyXi+H1Jlh5FtNSKMNrkJVtuAlSJ4BtsU W6wKiNjM7i1X8sxq7rYIiMH/TAeg6hvnBWdkWUdK1Ol9Don8eGnVRd8iVbgKx+gpYueScCOuL6j RugA2ybcy1frF8Rdpu23yNPtNFDLs6FosI1kmH41QRaPzA5rLraNI/e5qL3uRYmR+D1VSN/fYDr 84JoT9bYOBlEjF3beIrvYs8E9TdMp45ndiz296JqD3GxwdDQ6nDt8A== X-Google-Smtp-Source: AGHT+IGXvziHODCht+twr6uozgFfTyAclIKdnZuTVey4CsU1/XVbIcw96mTLNhe3rmJT4ESA13CsYg== X-Received: by 2002:a05:6000:2911:b0:39e:dbb0:310f with SMTP id ffacd0b85a97d-3a34992746amr5945525f8f.39.1747296311397; Thu, 15 May 2025 01:05:11 -0700 (PDT) Received: from [10.100.51.48] ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id ada2fe7eead31-4dea85df68fsm9441727137.18.2025.05.15.01.04.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 May 2025 01:05:10 -0700 (PDT) Message-ID: Date: Thu, 15 May 2025 10:04:53 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/12] module: Move modprobe_path and modules_disabled ctl_tables into the module subsys To: Joel Granados Cc: Luis Chamberlain , Sami Tolvanen , Daniel Gomez , Kees Cook , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , "James E.J. Bottomley" , Helge Deller , Greg Kroah-Hartman , Jiri Slaby , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, linux-parisc@vger.kernel.org, linux-serial@vger.kernel.org References: <20250509-jag-mv_ctltables_iter2-v1-0-d0ad83f5f4c3@kernel.org> <20250509-jag-mv_ctltables_iter2-v1-1-d0ad83f5f4c3@kernel.org> Content-Language: en-US From: Petr Pavlu In-Reply-To: <20250509-jag-mv_ctltables_iter2-v1-1-d0ad83f5f4c3@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/9/25 14:54, Joel Granados wrote: > Move module sysctl (modprobe_path and modules_disabled) out of sysctl.c > and into the modules subsystem. Make the modprobe_path variable static > as it no longer needs to be exported. Remove module.h from the includes > in sysctl as it no longer uses any module exported variables. > > This is part of a greater effort to move ctl tables into their > respective subsystems which will reduce the merge conflicts in > kernel/sysctl.c. > > Signed-off-by: Joel Granados > [...] > --- a/kernel/module/kmod.c > +++ b/kernel/module/kmod.c > @@ -60,7 +60,7 @@ static DEFINE_SEMAPHORE(kmod_concurrent_max, MAX_KMOD_CONCURRENT); > /* > 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; > > static void free_modprobe_argv(struct subprocess_info *info) > { > @@ -177,3 +177,33 @@ int __request_module(bool wait, const char *fmt, ...) > return ret; > } > EXPORT_SYMBOL(__request_module); > + > +#ifdef CONFIG_MODULES > +static const struct ctl_table kmod_sysctl_table[] = { > + { > + .procname = "modprobe", > + .data = &modprobe_path, > + .maxlen = KMOD_PATH_LEN, > + .mode = 0644, > + .proc_handler = proc_dostring, > + }, > + { > + .procname = "modules_disabled", > + .data = &modules_disabled, > + .maxlen = sizeof(int), > + .mode = 0644, > + /* only handle a transition from default "0" to "1" */ > + .proc_handler = proc_dointvec_minmax, > + .extra1 = SYSCTL_ONE, > + .extra2 = SYSCTL_ONE, > + }, This is minor.. but the file kernel/module/kmod.c contains the logic to request direct modprobe invocation by the kernel. Registering the modprobe_path sysctl here is appropriate. However, the modules_disabled setting affects the entire module loader so I don't think it's best to register it here. I suggest keeping a single table for the module sysctl values but moving it to kernel/module/main.c. This means the variable modprobe_path must retain external linkage, on the other hand, modules_disabled can be made static. -- Thanks, Petr > +}; > + > +static int __init init_kmod_sysctl(void) > +{ > + register_sysctl_init("kernel", kmod_sysctl_table); > + return 0; > +} > + > +subsys_initcall(init_kmod_sysctl); > +#endif