lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251020-cstr-debug-utf-8-v1-1-1933c0a6d6b9@kernel.org>
Date: Mon, 20 Oct 2025 11:27:28 -0400
From: Tamir Duberstein <tamird@...nel.org>
To: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, 
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
 Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>, 
 Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, 
 Danilo Krummrich <dakr@...nel.org>, Tamir Duberstein <tamird@...il.com>, 
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org, 
 Tamir Duberstein <tamird@...nel.org>
Subject: [PATCH] rust: fix tests under Rust 1.89.0's `CStr` `Debug` impl

Starting with Rust 1.89.0, `<CStr as Debug>::fmt` prints UTF-8 sequences
unescaped.

Thus update our test to expect the new behavior starting with Rust
1.89.0.

Fixes: a1ec674cd709 ("rust: replace `CStr` with `core::ffi::CStr`")
Link: https://github.com/rust-lang/rust/commit/a82062055af1ecdcb7f4d3371855aae843fc0ae3
Signed-off-by: Tamir Duberstein <tamird@...nel.org>
---
Hi Miguel, please feel free to rebase this in, if easier.
---
 init/Kconfig       | 3 +++
 rust/kernel/str.rs | 6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index cab3ad28ca49..aa29eae7f14b 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -156,6 +156,9 @@ config RUSTC_HAS_SPAN_FILE
 config RUSTC_HAS_UNNECESSARY_TRANSMUTES
 	def_bool RUSTC_VERSION >= 108800
 
+config RUSTC_HAS_CSTR_DEBUG_UTF8
+	def_bool RUSTC_VERSION >= 108900
+
 config RUSTC_HAS_FILE_WITH_NUL
 	def_bool RUSTC_VERSION >= 108900
 
diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs
index da539e1f29d4..f2d60288eced 100644
--- a/rust/kernel/str.rs
+++ b/rust/kernel/str.rs
@@ -478,7 +478,11 @@ fn test_cstr_debug() -> Result {
         let non_ascii = c"d\xe9j\xe0 vu";
         assert_eq!(format!("{non_ascii:?}"), "\"d\\xe9j\\xe0 vu\"");
         let good_bytes = c"\xf0\x9f\xa6\x80";
-        assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\"");
+        if cfg!(CONFIG_RUSTC_HAS_CSTR_DEBUG_UTF8) {
+            assert_eq!(format!("{good_bytes:?}"), "\"🦀\"");
+        } else {
+            assert_eq!(format!("{good_bytes:?}"), "\"\\xf0\\x9f\\xa6\\x80\"");
+        }
         Ok(())
     }
 

---
base-commit: a1ec674cd709fec213acbb567e699c5f6f58cb60
change-id: 20251020-cstr-debug-utf-8-8e9c43a1b757

Best regards,
--  
Tamir Duberstein <tamird@...nel.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ