[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250206195658.79231973@pumpkin>
Date: Thu, 6 Feb 2025 19:56:58 +0000
From: David Laight <david.laight.linux@...il.com>
To: Kees Cook <kees@...nel.org>
Cc: Suren Baghdasaryan <surenb@...gle.com>, Kent Overstreet
<kent.overstreet@...ux.dev>, Andy Shevchenko <andy@...nel.org>, Luc Van
Oostenryck <luc.vanoostenryck@...il.com>, Nathan Chancellor
<nathan@...nel.org>, Nick Desaulniers <ndesaulniers@...gle.com>, Bill
Wendling <morbo@...gle.com>, Justin Stitt <justinstitt@...gle.com>, Philipp
Reisner <philipp.reisner@...bit.com>, Miguel Ojeda <ojeda@...nel.org>,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH 2/3] compiler.h: Introduce __must_be_char_array()
On Thu, 6 Feb 2025 10:11:29 -0800
Kees Cook <kees@...nel.org> wrote:
> In preparation for adding stricter type checking to the str/mem*()
> helpers, provide a way to check that a variable is a character array
> via __must_be_char_array().
>
...
> +#define __is_char_array(a) (__is_array(a) && sizeof((a)[0]) == 1)
> +#define __must_be_char_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_char_array(a), \
> + "must be byte array")
If you are only checking the size, perhaps __is_byte_array() would
be a better name.
(You've even used 'byte' in the error message.)
David
Powered by blists - more mailing lists