diff options
| author | Jan Polensky <japo@linux.ibm.com> | 2026-06-01 19:46:23 +0200 |
|---|---|---|
| committer | Alexander Gordeev <agordeev@linux.ibm.com> | 2026-06-10 16:25:13 +0200 |
| commit | 71247e71a41fb79ff3612961957b05153fed2862 (patch) | |
| tree | 7f894bc16139fa1f2de754d89d122d8e3b79960c /rust | |
| parent | fc1118cdc3618bef1433040bf5fa09b438ec3428 (diff) | |
| download | linux-71247e71a41fb79ff3612961957b05153fed2862.tar.gz linux-71247e71a41fb79ff3612961957b05153fed2862.zip | |
rust: helpers: Add memchr wrapper for string operations
Add a dedicated string helper file with a memchr wrapper that uses the
kernel's instrumented memchr() function to ensure KASAN and FORTIFY_SOURCE
protections are preserved for Rust code.
Reported-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Link: https://lore.kernel.org/rust-for-linux/CANiq72mXAZc0sNM7ShX8VDVs_7zJddawP-e=wt+ERr1YUCcWUw@mail.gmail.com/
Signed-off-by: Jan Polensky <japo@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Acked-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Diffstat (limited to 'rust')
| -rw-r--r-- | rust/helpers/helpers.c | 1 | ||||
| -rw-r--r-- | rust/helpers/string.c | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c index 625921e27dfb..592b9bdb4e4a 100644 --- a/rust/helpers/helpers.c +++ b/rust/helpers/helpers.c @@ -88,6 +88,7 @@ #include "signal.c" #include "slab.c" #include "spinlock.c" +#include "string.c" #include "sync.c" #include "task.c" #include "time.c" diff --git a/rust/helpers/string.c b/rust/helpers/string.c new file mode 100644 index 000000000000..8ef30eb07a15 --- /dev/null +++ b/rust/helpers/string.c @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/string.h> + +__rust_helper void *rust_helper_memchr(const void *s, int c, size_t n) +{ + return memchr(s, c, n); +} |
