mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw
@ 2026-11-14  2:45 Marwan Mohamed Zein
  2026-11-14  6:30 ` Alexandre Courbot
  2026-11-14 11:16 ` Miguel Ojeda
  0 siblings, 2 replies; 5+ messages in thread
From: Marwan Mohamed Zein @ 2026-11-14  2:45 UTC (permalink / raw)
  To: ojeda
  Cc: rust-for-linux, linux-kernel, boqun, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, daniel.almeida, tamir,
	acourbot, work, martell0x1, spidermana

From: martell0x1 <marawanzein222@gmail.com>

The returned slice is derived from `out`, but lifetime elision
ties it to `self` because this is a method. Explicitly bind the
return lifetime to `out` so the returned slice cannot outlive
its backing buffer.

Reported-by: spidermana <xuyiwen14@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1265
Signed-off-by: martell0x1 <marawanzein222@gmail.com>
---
 rust/kernel/iov.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/iov.rs b/rust/kernel/iov.rs
index 43bae8923..8caf04518 100644
--- a/rust/kernel/iov.rs
+++ b/rust/kernel/iov.rs
@@ -161,7 +161,7 @@ pub fn copy_from_iter_vec<A: Allocator>(
     ///
     /// This will never write uninitialized bytes to the provided buffer.
     #[inline]
-    pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8] {
+    pub fn copy_from_iter_raw<'a>(&mut self, out: &'a mut [MaybeUninit<u8>]) -> &'a mut [u8] {
         let capacity = out.len();
         let out = out.as_mut_ptr().cast::<u8>();
 

base-commit: ee83899302a0457a3ba47464a13e8682bd7ba27d
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw
  2026-11-14  2:45 [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw Marwan Mohamed Zein
@ 2026-11-14  6:30 ` Alexandre Courbot
  2026-11-14 11:16 ` Miguel Ojeda
  1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Courbot @ 2026-11-14  6:30 UTC (permalink / raw)
  To: Marwan Mohamed Zein
  Cc: ojeda, rust-for-linux, linux-kernel, boqun, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, daniel.almeida,
	tamir, work, spidermana

On Sat Nov 14, 2026 at 11:45 AM JST, Marwan Mohamed Zein wrote:
> From: martell0x1 <marawanzein222@gmail.com>

Please sign with a full name.

>
> The returned slice is derived from `out`, but lifetime elision
> ties it to `self` because this is a method. Explicitly bind the
> return lifetime to `out` so the returned slice cannot outlive
> its backing buffer.
>
> Reported-by: spidermana <xuyiwen14@gmail.com>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1265
> Signed-off-by: martell0x1 <marawanzein222@gmail.com>

On these tags as well.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw
  2026-11-14  2:45 [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw Marwan Mohamed Zein
  2026-11-14  6:30 ` Alexandre Courbot
@ 2026-11-14 11:16 ` Miguel Ojeda
  2026-11-14 11:19   ` Miguel Ojeda
  1 sibling, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2026-11-14 11:16 UTC (permalink / raw)
  To: Marwan Mohamed Zein
  Cc: ojeda, rust-for-linux, linux-kernel, boqun, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, daniel.almeida,
	tamir, acourbot, work, spidermana

On Sat, Nov 14, 2026 at 3:45 AM Marwan Mohamed Zein
<marawanzein222@gmail.com> wrote:
>
> Reported-by: spidermana <xuyiwen14@gmail.com>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1265
> Signed-off-by: martell0x1 <marawanzein222@gmail.com>

Thanks for the patch!

On top of what Alexandre said, for fixes, please try to find which
commit introduced the issue and then add a Fixes tag to it. Then,
please consider if it is something that may need to be backported:

  https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
  https://docs.kernel.org/process/stable-kernel-rules.html

So we would have written:

Cc: stable@vger.kernel.org
Fixes: 06cb58b310ea ("rust: iov: add iov_iter abstractions for ITER_SOURCE")

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw
  2026-11-14 11:16 ` Miguel Ojeda
@ 2026-11-14 11:19   ` Miguel Ojeda
  2026-11-14 13:21     ` [PATCH v2] " Marwan Mohamed Zein
  0 siblings, 1 reply; 5+ messages in thread
From: Miguel Ojeda @ 2026-11-14 11:19 UTC (permalink / raw)
  To: Marwan Mohamed Zein
  Cc: ojeda, rust-for-linux, linux-kernel, boqun, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, daniel.almeida,
	acourbot, work, spidermana, Tamir Duberstein

On Sat, Nov 14, 2026 at 12:16 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> Thanks for the patch!
>
> On top of what Alexandre said, for fixes, please try to find which
> commit introduced the issue and then add a Fixes tag to it. Then,
> please consider if it is something that may need to be backported:
>
>   https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
>   https://docs.kernel.org/process/stable-kernel-rules.html
>
> So we would have written:
>
> Cc: stable@vger.kernel.org
> Fixes: 06cb58b310ea ("rust: iov: add iov_iter abstractions for ITER_SOURCE")

By the way, Tamir's email address in the Cc list has a typo --
correcting it here in case it helps.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] rust: kernel: fix lifetime of copy_from_iter_raw
  2026-11-14 11:19   ` Miguel Ojeda
@ 2026-11-14 13:21     ` Marwan Mohamed Zein
  0 siblings, 0 replies; 5+ messages in thread
From: Marwan Mohamed Zein @ 2026-11-14 13:21 UTC (permalink / raw)
  To: ojeda
  Cc: rust-for-linux, linux-kernel, stable, boqun, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, daniel.almeida,
	tamir, acourbot, work, Marwan Mohamed Zein, spidermana

The returned slice is derived from `out`, but lifetime elision
ties it to `self` because this is a method. Explicitly bind the
return lifetime to `out` so the returned slice cannot outlive
its backing buffer.

Fixes: 06cb58b310ea ("rust: iov: add iov_iter abstractions for ITER_SOURCE")
Cc: stable@vger.kernel.org
Reported-by: spidermana <xuyiwen14@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1265
Signed-off-by: Marwan Mohamed Zein <marawanzein222@gmail.com>
---
 v2:
- Use full name in author and sign-off.
- Add Fixes and Cc: stable tags as suggested by Miguel Ojeda.

 rust/kernel/iov.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/iov.rs b/rust/kernel/iov.rs
index 43bae8923..8caf04518 100644
--- a/rust/kernel/iov.rs
+++ b/rust/kernel/iov.rs
@@ -161,7 +161,7 @@ pub fn copy_from_iter_vec<A: Allocator>(
     ///
     /// This will never write uninitialized bytes to the provided buffer.
     #[inline]
-    pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8] {
+    pub fn copy_from_iter_raw<'a>(&mut self, out: &'a mut [MaybeUninit<u8>]) -> &'a mut [u8] {
         let capacity = out.len();
         let out = out.as_mut_ptr().cast::<u8>();
 

base-commit: ee83899302a0457a3ba47464a13e8682bd7ba27d
-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-14 13:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-14  2:45 [PATCH] rust: kernel: fix lifetime of copy_from_iter_raw Marwan Mohamed Zein
2026-11-14  6:30 ` Alexandre Courbot
2026-11-14 11:16 ` Miguel Ojeda
2026-11-14 11:19   ` Miguel Ojeda
2026-11-14 13:21     ` [PATCH v2] " Marwan Mohamed Zein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®