Skip to contentSkip to conversation

linux-next: build failure after merge of the modules tree

DISCUSSION Stephen Rothwell 3 participants 5 messages Nov 4, 2025 – Dec 4, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the modules tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> rust/kernel/module_param.rs:75:47

   |
75 |         let new_value = T::try_from_param_arg(arg)?;
   |                         --------------------- ^^^ expected `&BStr`, found `&CStr`
   |                         |
   |                         arguments to this function are incorrect
   |

= note: expected reference &BStr
found reference &ffi::CStr
note: associated function defined here
--> rust/kernel/module_param.rs:32:8

   |
32 |     fn try_from_param_arg(arg: &BStr) -> Result<Self>;
   |        ^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

0b08fc292842 ("rust: introduce module_param module")

This is some interaction with something later in linux-next - presumably commit

3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")

from the rust tree.

Hopefully someone can provide a resolution for me tomorrow.

I have used the modules tree from next-20251103 for today.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw

Hi,

Quoted 32 lines · Stephen Rothwell

Hi all,

After merging the modules tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> rust/kernel/module_param.rs:75:47

   |
75 |         let new_value = T::try_from_param_arg(arg)?;
   |                         --------------------- ^^^ expected `&BStr`, found `&CStr`
   |                         |
   |                         arguments to this function are incorrect
   |

= note: expected reference &BStr
found reference &ffi::CStr
note: associated function defined here
--> rust/kernel/module_param.rs:32:8

   |
32 |     fn try_from_param_arg(arg: &BStr) -> Result<Self>;
   |        ^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

0b08fc292842 ("rust: introduce module_param module")

This is some interaction with something later in linux-next - presumably commit

Quoted 7 lines

3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")

from the rust tree.

Hopefully someone can provide a resolution for me tomorrow.

I have used the modules tree from next-20251103 for today.

Please use the following resolution:

rust/kernel/module_param.rs +1 -0
index e7d5c930a467d..6a8a7a875643a 100644
@@ -70,6 +70,7 @@ pub trait ModuleParam: Sized + Copy {
     // SAFETY: By function safety requirement, val is non-null, null-terminated
     // and valid for reads for the duration of this function.
     let arg = unsafe { CStr::from_char_ptr(val) };
+    let arg: &BStr = arg.as_ref();
 
     crate::error::from_result(|| {
         let new_value = T::try_from_param_arg(arg)?;
rust/macros/module.rs +2 -2
index d62e9c1e2a898..decb0849f3d33 100644
@@ -133,10 +133,10 @@ fn emit_params(&mut self, info: &ModuleInfo) {
                         ::kernel::module_param::KernelParam::new(
                             ::kernel::bindings::kernel_param {{
                                 name: if ::core::cfg!(MODULE) {{
-                                    ::kernel::c_str!(\"{param_name}\").as_bytes_with_nul()
+                                    ::kernel::c_str!(\"{param_name}\").to_bytes_with_nul()
                                 }} else {{
                                     ::kernel::c_str!(\"{module_name}.{param_name}\")
-                                        .as_bytes_with_nul()
+                                        .to_bytes_with_nul()
                                 }}.as_ptr(),
                                 // SAFETY: `__this_module` is constructed by the kernel at load
                                 // time and will not be freed until the module is unloaded.

Best regards,
Andreas Hindborg

#2 lore raw
In reply to Stephen Rothwell

Hi all,

Quoted 31 lines · On Tue, 4 Nov 2025 15:45:00 +1100 Stephen Rothwell <[email protected]> wrote:

After merging the modules tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> rust/kernel/module_param.rs:75:47

   |
75 |         let new_value = T::try_from_param_arg(arg)?;
   |                         --------------------- ^^^ expected `&BStr`, found `&CStr`
   |                         |
   |                         arguments to this function are incorrect
   |

= note: expected reference &BStr
found reference &ffi::CStr
note: associated function defined here
--> rust/kernel/module_param.rs:32:8

   |
32 |     fn try_from_param_arg(arg: &BStr) -> Result<Self>;
   |        ^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

0b08fc292842 ("rust: introduce module_param module")

This is some interaction with something later in linux-next - presumably commit

Quoted 7 lines

3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")

from the rust tree.

Hopefully someone can provide a resolution for me tomorrow.

I have used the modules tree from next-20251103 for today.

I have used the modules tree as is and applied the below merge resolution patch (supplied by Andreas) to the merge of the rust tree.

From: Stephen Rothwell <[email protected]>
Date: Wed, 5 Nov 2025 14:52:29 +1100
Subject: [PATCH] fix up for "rust: replace CStr with core::ffi::CStr"

interacting with commit

0b08fc292842 ("rust: introduce module_param module")

from the modules tree.

---
 rust/kernel/module_param.rs | 1 +
 rust/macros/module.rs       | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
rust/kernel/module_param.rs +1 -0
index e7d5c930a467..6a8a7a875643 100644
@@ -70,6 +70,7 @@ pub trait ModuleParam: Sized + Copy {
     // SAFETY: By function safety requirement, val is non-null, null-terminated
     // and valid for reads for the duration of this function.
     let arg = unsafe { CStr::from_char_ptr(val) };
+    let arg: &BStr = arg.as_ref();
 
     crate::error::from_result(|| {
         let new_value = T::try_from_param_arg(arg)?;
rust/macros/module.rs +2 -2
index 1a22de73d512..f6a94712384f 100644
@@ -133,10 +133,10 @@ fn emit_params(&mut self, info: &ModuleInfo) {
                         ::kernel::module_param::KernelParam::new(
                             ::kernel::bindings::kernel_param {{
                                 name: if ::core::cfg!(MODULE) {{
-                                    ::kernel::c_str!(\"{param_name}\").as_bytes_with_nul()
+                                    ::kernel::c_str!(\"{param_name}\").to_bytes_with_nul()
                                 }} else {{
                                     ::kernel::c_str!(\"{module_name}.{param_name}\")
-                                        .as_bytes_with_nul()
+                                        .to_bytes_with_nul()
                                 }}.as_ptr(),
                                 // SAFETY: `__this_module` is constructed by the kernel at load
                                 // time and will not be freed until the module is unloaded.
Signature · 5 lines
2.51.1

-- 
Cheers,
Stephen Rothwell
maintainer
#3 lore raw
Quoted 36 lines · Stephen Rothwell

Hi all,

Quoted 33 lines · On Tue, 4 Nov 2025 15:45:00 +1100 Stephen Rothwell <[email protected]> wrote:

After merging the modules tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> rust/kernel/module_param.rs:75:47

   |
75 |         let new_value = T::try_from_param_arg(arg)?;
   |                         --------------------- ^^^ expected `&BStr`, found `&CStr`
   |                         |
   |                         arguments to this function are incorrect
   |

= note: expected reference &BStr
found reference &ffi::CStr
note: associated function defined here
--> rust/kernel/module_param.rs:32:8

   |
32 |     fn try_from_param_arg(arg: &BStr) -> Result<Self>;
   |        ^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

0b08fc292842 ("rust: introduce module_param module")

This is some interaction with something later in linux-next - presumably commit

3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")

Quoted 8 lines
Quoted 5 lines

from the rust tree.

Hopefully someone can provide a resolution for me tomorrow.

I have used the modules tree from next-20251103 for today.

I have used the modules tree as is and applied the below merge resolution patch (supplied by Andreas) to the merge of the rust tree.

Yes, that is the correct resolution. I tested that yesterday when I contacted Andreas and Tamir.

Thanks

Quoted 46 lines

From: Stephen Rothwell <[email protected]>
Date: Wed, 5 Nov 2025 14:52:29 +1100
Subject: [PATCH] fix up for "rust: replace CStr with core::ffi::CStr"

interacting with commit

0b08fc292842 ("rust: introduce module_param module")

from the modules tree.

---
 rust/kernel/module_param.rs | 1 +
 rust/macros/module.rs       | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
rust/kernel/module_param.rs +1 -0
index e7d5c930a467..6a8a7a875643 100644
@@ -70,6 +70,7 @@ pub trait ModuleParam: Sized + Copy {
     // SAFETY: By function safety requirement, val is non-null, null-terminated
     // and valid for reads for the duration of this function.
     let arg = unsafe { CStr::from_char_ptr(val) };
+    let arg: &BStr = arg.as_ref();
 
     crate::error::from_result(|| {
         let new_value = T::try_from_param_arg(arg)?;
rust/macros/module.rs +2 -2
index 1a22de73d512..f6a94712384f 100644
@@ -133,10 +133,10 @@ fn emit_params(&mut self, info: &ModuleInfo) {
                         ::kernel::module_param::KernelParam::new(
                             ::kernel::bindings::kernel_param {{
                                 name: if ::core::cfg!(MODULE) {{
-                                    ::kernel::c_str!(\"{param_name}\").as_bytes_with_nul()
+                                    ::kernel::c_str!(\"{param_name}\").to_bytes_with_nul()
                                 }} else {{
                                     ::kernel::c_str!(\"{module_name}.{param_name}\")
-                                        .as_bytes_with_nul()
+                                        .to_bytes_with_nul()
                                 }}.as_ptr(),
                                 // SAFETY: `__this_module` is constructed by the kernel at load
                                 // time and will not be freed until the module is unloaded.
#4 lore raw
In reply to Stephen Rothwell

Hi all,

Quoted 91 lines · On Wed, 5 Nov 2025 15:51:09 +1100 Stephen Rothwell <[email protected]> wrote:
Quoted 31 lines · On Tue, 4 Nov 2025 15:45:00 +1100 Stephen Rothwell <[email protected]> wrote:

After merging the modules tree, today's linux-next build (x86_64 allmodconfig) failed like this:

error[E0308]: mismatched types
--> rust/kernel/module_param.rs:75:47

   |
75 |         let new_value = T::try_from_param_arg(arg)?;
   |                         --------------------- ^^^ expected `&BStr`, found `&CStr`
   |                         |
   |                         arguments to this function are incorrect
   |

= note: expected reference &BStr
found reference &ffi::CStr
note: associated function defined here
--> rust/kernel/module_param.rs:32:8

   |
32 |     fn try_from_param_arg(arg: &BStr) -> Result<Self>;
   |        ^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try rustc --explain E0308.

Caused by commit

0b08fc292842 ("rust: introduce module_param module")

This is some interaction with something later in linux-next - presumably commit

Quoted 7 lines

3b83f5d5e78a ("rust: replace CStr with core::ffi::CStr")

from the rust tree.

Hopefully someone can provide a resolution for me tomorrow.

I have used the modules tree from next-20251103 for today.

I have used the modules tree as is and applied the below merge resolution patch (supplied by Andreas) to the merge of the rust tree.

From: Stephen Rothwell <[email protected]>
Date: Wed, 5 Nov 2025 14:52:29 +1100
Subject: [PATCH] fix up for "rust: replace CStr with core::ffi::CStr"

interacting with commit

0b08fc292842 ("rust: introduce module_param module")

from the modules tree.

---
 rust/kernel/module_param.rs | 1 +
 rust/macros/module.rs       | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
rust/kernel/module_param.rs +1 -0
index e7d5c930a467..6a8a7a875643 100644
@@ -70,6 +70,7 @@ pub trait ModuleParam: Sized + Copy {
     // SAFETY: By function safety requirement, val is non-null, null-terminated
     // and valid for reads for the duration of this function.
     let arg = unsafe { CStr::from_char_ptr(val) };
+    let arg: &BStr = arg.as_ref();
 
     crate::error::from_result(|| {
         let new_value = T::try_from_param_arg(arg)?;
rust/macros/module.rs +2 -2
index 1a22de73d512..f6a94712384f 100644
@@ -133,10 +133,10 @@ fn emit_params(&mut self, info: &ModuleInfo) {
                         ::kernel::module_param::KernelParam::new(
                             ::kernel::bindings::kernel_param {{
                                 name: if ::core::cfg!(MODULE) {{
-                                    ::kernel::c_str!(\"{param_name}\").as_bytes_with_nul()
+                                    ::kernel::c_str!(\"{param_name}\").to_bytes_with_nul()
                                 }} else {{
                                     ::kernel::c_str!(\"{module_name}.{param_name}\")
-                                        .as_bytes_with_nul()
+                                        .to_bytes_with_nul()
                                 }}.as_ptr(),
                                 // SAFETY: `__this_module` is constructed by the kernel at load
                                 // time and will not be freed until the module is unloaded.
Signature · 1 line
2.51.1

This now needs to be applied to the merge of the modules tree (as the rust tree has been merged by Linus).

Signature · 2 lines
Cheers,
Stephen Rothwell