summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-21 12:47:25 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-21 12:47:25 -0700
commit2f0f6b0773be0a1ec475097ae54848eea42adc7d (patch)
tree63dc254caea8a8a76d0889305317cab33119289d /rust
parent27a59c0251e5d1f41a3a6fbae7c4dc478c34d919 (diff)
parent3dfaae04243cde460d82dfc2a7dd0bb6664d20ae (diff)
downloadlinux-next-2f0f6b0773be0a1ec475097ae54848eea42adc7d.tar.gz
linux-next-2f0f6b0773be0a1ec475097ae54848eea42adc7d.zip
Merge tag 'modules-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux
Pull module updates from Petr Pavlu: - Remove unnecessary module::args. Nowadays, no parameter-handling code points into the module::args buffer. The last user of module::args in xtensa/simdisk is updated and the data is then removed - Add Rust support for boolean parameters. This will initially be used by the Rust null block driver - Fix clearing the current charp parameter value when setting a new one fails due to an allocation failure - Improve the debugging code for kmod (request_module()) duplicates. Fix a potential use-after-free when waiting on a duplicate request and make several general improvements to the code - Fix the symbol size returned when looking up a data symbol through kallsyms - Smaller fixes and cleanups * tag 'modules-7.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux: params: fix charp corruption on allocation failure module: validate string table section types module/dups: Clean up includes module/dups: Use strcmp() to compare module names module/dups: Use scope-based cleanup helpers module/dups: Avoid unnecessary kmod_dup_req allocations module/dups: Fix use-after-free in kmod_dup_req lifetime handling module/dups: Inform duplicate requests about the result directly rust: module_param: support bool parameters rust: module_param: return value by copy from `value` module: Remove unnecessary module::args xtensa/simdisk: Avoid referring to module::args module: Remove unused DISCARD_EH_FRAME definition from module.lds.S module: procfs: use matching type for accumulator in module_total_size() module: use strscpy() to copy module names in stats and dup tracking params: fix path of /sys/module/XYZ/parameters/ in comment module/kallsyms: fix nextval for data symbol lookup
Diffstat (limited to 'rust')
-rw-r--r--rust/kernel/module_param.rs27
-rw-r--r--rust/macros/lib.rs1
-rw-r--r--rust/macros/module.rs1
3 files changed, 27 insertions, 2 deletions
diff --git a/rust/kernel/module_param.rs b/rust/kernel/module_param.rs
index 6541af218390..f9a14765a926 100644
--- a/rust/kernel/module_param.rs
+++ b/rust/kernel/module_param.rs
@@ -5,7 +5,7 @@
//! C header: [`include/linux/moduleparam.h`](srctree/include/linux/moduleparam.h)
use crate::prelude::*;
-use crate::str::BStr;
+use crate::str::{kstrtobool_bytes, BStr};
use bindings;
use kernel::sync::SetOnce;
@@ -105,6 +105,12 @@ impl_int_module_param!(u64);
impl_int_module_param!(isize);
impl_int_module_param!(usize);
+impl ModuleParam for bool {
+ fn try_from_param_arg(arg: &BStr) -> Result<Self> {
+ kstrtobool_bytes(arg)
+ }
+}
+
/// A wrapper for kernel parameters.
///
/// This type is instantiated by the [`module!`] macro when module parameters are
@@ -130,10 +136,26 @@ impl<T> ModuleParamAccess<T> {
}
}
+ /// Get a copy of the parameter value.
+ ///
+ /// Returns the value supplied at module load time, or the default value
+ /// if the parameter has not been set.
+ #[inline]
+ pub fn value(&self) -> T
+ where
+ T: Copy,
+ {
+ self.value.copy().unwrap_or(self.default)
+ }
+
/// Get a shared reference to the parameter value.
+ ///
+ /// Returns a reference to the value supplied at module load time, or a
+ /// reference to the default value if the parameter has not been set.
// Note: When sysfs access to parameters are enabled, we have to pass in a
// held lock guard here.
- pub fn value(&self) -> &T {
+ #[inline]
+ pub fn value_ref(&self) -> &T {
self.value.as_ref().unwrap_or(&self.default)
}
@@ -179,3 +201,4 @@ make_param_ops!(PARAM_OPS_I64, i64);
make_param_ops!(PARAM_OPS_U64, u64);
make_param_ops!(PARAM_OPS_ISIZE, isize);
make_param_ops!(PARAM_OPS_USIZE, usize);
+make_param_ops!(PARAM_OPS_BOOL, bool);
diff --git a/rust/macros/lib.rs b/rust/macros/lib.rs
index 37a6643db76e..24f96feaeb34 100644
--- a/rust/macros/lib.rs
+++ b/rust/macros/lib.rs
@@ -56,6 +56,7 @@ use syn::parse_macro_input;
/// - [`u64`]
/// - [`isize`]
/// - [`usize`]
+/// - [`bool`]
///
/// C header: [`include/linux/moduleparam.h`](srctree/include/linux/moduleparam.h)
///
diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index bd69d8dc4bbb..bc7027f8dbb2 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -192,6 +192,7 @@ fn param_ops_path(param_type: &str) -> Path {
"u64" => parse_quote!(::kernel::module_param::PARAM_OPS_U64),
"isize" => parse_quote!(::kernel::module_param::PARAM_OPS_ISIZE),
"usize" => parse_quote!(::kernel::module_param::PARAM_OPS_USIZE),
+ "bool" => parse_quote!(::kernel::module_param::PARAM_OPS_BOOL),
t => panic!("Unsupported parameter type {}", t),
}
}