rust: kernel: fix lifetime of copy_from_iter_raw
Subsystems (2)
PATCH 1/1 rust: kernel: fix lifetime of copy_from_iter_raw
From: martell0x1 <[email protected]>
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.
--- rust/kernel/iov.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/iov.rs +1 -1
@@ -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: &'amut [MaybeUninit <u8 >]) -> &'amut [u8 ] {let capacity = out.len ();let out = out.as_mut_ptr ().cast ::<u8 >();
base-commit: ee83899302a0457a3ba47464a13e8682bd7ba27d
Signature · 1 line
2.47.3
Alexandre Courbot
reviewerQuoted 1 line · Marwan Mohamed Zein
From: martell0x1 <[email protected]>
Please sign with a full name.
Quoted 9 lines
The returned slice is derived from
out, but lifetime elision ties it toselfbecause this is a method. Explicitly bind the return lifetime tooutso the returned slice cannot outlive its backing buffer.Reported-by spidermana <[email protected]>Signed-off-by martell0x1 <[email protected]>
On these tags as well.
Quoted 4 lines · Marwan Mohamed Zein
Reported-by spidermana <[email protected]>Signed-off-by martell0x1 <[email protected]>
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:
Cheers,
Miguel
Quoted 7 lines · Miguel Ojeda
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:
Quoted 7 lines
https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
https://docs.kernel.org/process/stable-kernel-rules.htmlSo we would have written:
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
PATCH v2 1/1 rust: kernel: fix lifetime of copy_from_iter_raw
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.
---
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(-)
rust/kernel/iov.rs +1 -1
@@ -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: &'amut [MaybeUninit <u8 >]) -> &'amut [u8 ] {let capacity = out.len ();let out = out.as_mut_ptr ().cast ::<u8 >();
base-commit: ee83899302a0457a3ba47464a13e8682bd7ba27d
Signature · 1 line
2.47.3
Miguel Ojeda
AppliedQuoted 11 lines · Marwan Mohamed Zein
The returned slice is derived from
out, but lifetime elision ties it toselfbecause this is a method. Explicitly bind the return lifetime tooutso the returned slice cannot outlive its backing buffer.Fixes 06cb58b310ea ("rust: iov: add iov_iter abstractions for ITER_SOURCE")Reported-by spidermana <[email protected]>Signed-off-by Marwan Mohamed Zein <[email protected]>
Applied to rust-fixes -- tags still welcome for a day or so!
[ Reworded title. - Miguel ]
Cheers,
Miguel