diff options
| author | Peder Bergan <peder.bergan@gmail.com> | 2026-11-17 18:57:06 +0100 |
|---|---|---|
| committer | Miguel Ojeda <ojeda@kernel.org> | 2026-11-19 10:11:45 +0100 |
| commit | cf2212fd3053857f800cc22d903118d522131ca8 (patch) | |
| tree | ea1def1bfa25bf35691e15c80ff44eb44fc7984d /kernel/debug | |
| parent | df71affdd95ea60fa3fb31e666389a53fd3297db (diff) | |
rust: str: tie Formatter to its backing buffer
Formatter::new() returns a Formatter whose lifetime is independent of the
borrow of its backing buffer. Safe code can therefore drop the buffer and
then write through the formatter, causing a use-after-free.
Tie the buffer borrow to the formatter's lifetime so that the borrow
checker rejects such callers and prevents overlapping mutable access.
Fixes: 87482d6d9104 ("rust: str: allow `str::Formatter` to format into `&mut [u8]`.")
Cc: stable@vger.kernel.org
Reported-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
Closes: https://github.com/Rust-for-Linux/linux/issues/1261
Signed-off-by: Peder Bergan <peder.bergan@gmail.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20261117-formatter-lifetime-v2-1-e216d86ffb57@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'kernel/debug')
0 files changed, 0 insertions, 0 deletions
