All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] string: Introduce __free(kfree_const)
@ 2026-08-11  7:13 Andy Shevchenko
  2026-08-11 10:42 ` Chen-Yu Tsai
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-11  7:13 UTC (permalink / raw)
  To: Andy Shevchenko, linux-hardening, linux-kernel
  Cc: Kees Cook, Andy Shevchenko, Chen-Yu Tsai

__free(kfree_const) may be used in the cases when one part of the code
relies on the constant string literals, while the other uses a heap
(via kasprintf(), for example).

Requested-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/CAGXv+5HGZwAKpGpyV4=QHfg7yBQPx-syc1Gma2qad_tzW_RLog@mail.gmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/string.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 75bfc194ad20..6f3501b56c11 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -294,8 +294,11 @@ static inline bool mem_is_zero(const void *s, size_t n)
 	return !memchr_inv(s, 0, n);
 }
 
+/* mm/util.c */
 extern void kfree_const(const void *x);
 
+DEFINE_FREE(kfree_const, void *, if (!IS_ERR_OR_NULL(_T)) kfree_const(_T))
+
 extern char *kstrdup(const char *s, gfp_t gfp) __malloc;
 extern const char *kstrdup_const(const char *s, gfp_t gfp);
 extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
-- 
2.50.1


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

end of thread, other threads:[~2026-08-11 11:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-11  7:13 [PATCH v1 1/1] string: Introduce __free(kfree_const) Andy Shevchenko
2026-08-11 10:42 ` Chen-Yu Tsai
2026-08-11 10:53   ` Andy Shevchenko
2026-08-11 10:58     ` Chen-Yu Tsai
2026-08-11 11:39       ` Chen-Yu Tsai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.