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

* Re: [PATCH v1 1/1] string: Introduce __free(kfree_const)
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Chen-Yu Tsai @ 2026-08-11 10:42 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-hardening, linux-kernel, Kees Cook, Andy Shevchenko

On Tue, Aug 11, 2026 at 3:13 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> __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))
> +

Matches what we already have for kfree(), so

Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

>  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	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] string: Introduce __free(kfree_const)
  2026-08-11 10:42 ` Chen-Yu Tsai
@ 2026-08-11 10:53   ` Andy Shevchenko
  2026-08-11 10:58     ` Chen-Yu Tsai
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2026-08-11 10:53 UTC (permalink / raw)
  To: Chen-Yu Tsai; +Cc: linux-hardening, linux-kernel, Kees Cook, Andy Shevchenko

On Tue, Aug 11, 2026 at 06:42:51PM +0800, Chen-Yu Tsai wrote:
> On Tue, Aug 11, 2026 at 3:13 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

> Matches what we already have for kfree(), so
> 
> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

Thanks!

I think you can incorporate this to (will be) your mini-series. But let's hear
from Kees and others if he is okay with the idea.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] string: Introduce __free(kfree_const)
  2026-08-11 10:53   ` Andy Shevchenko
@ 2026-08-11 10:58     ` Chen-Yu Tsai
  2026-08-11 11:39       ` Chen-Yu Tsai
  0 siblings, 1 reply; 5+ messages in thread
From: Chen-Yu Tsai @ 2026-08-11 10:58 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-hardening, linux-kernel, Kees Cook, Andy Shevchenko

On Tue, Aug 11, 2026 at 6:53 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Tue, Aug 11, 2026 at 06:42:51PM +0800, Chen-Yu Tsai wrote:
> > On Tue, Aug 11, 2026 at 3:13 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
>
> > Matches what we already have for kfree(), so
> >
> > Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
>
> Thanks!
>
> I think you can incorporate this to (will be) your mini-series. But let's hear
> from Kees and others if he is okay with the idea.

If folks can merge it for the next cycle that would be even better.
My series already has three cross-tree build dependencies...


ChenYu

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

* Re: [PATCH v1 1/1] string: Introduce __free(kfree_const)
  2026-08-11 10:58     ` Chen-Yu Tsai
@ 2026-08-11 11:39       ` Chen-Yu Tsai
  0 siblings, 0 replies; 5+ messages in thread
From: Chen-Yu Tsai @ 2026-08-11 11:39 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-hardening, linux-kernel, Kees Cook, Andy Shevchenko

On Tue, Aug 11, 2026 at 6:58 PM Chen-Yu Tsai <wenst@chromium.org> wrote:
>
> On Tue, Aug 11, 2026 at 6:53 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Tue, Aug 11, 2026 at 06:42:51PM +0800, Chen-Yu Tsai wrote:
> > > On Tue, Aug 11, 2026 at 3:13 PM Andy Shevchenko
> > > <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > Matches what we already have for kfree(), so
> > >
> > > Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
> >
> > Thanks!
> >
> > I think you can incorporate this to (will be) your mini-series. But let's hear
> > from Kees and others if he is okay with the idea.
>
> If folks can merge it for the next cycle that would be even better.
> My series already has three cross-tree build dependencies...

Ah, no, I got it confused with my other stuff in-flight. This one is easy.

Anyway, will wait for others to respond.

^ permalink raw reply	[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.