[PATCH 07/10] uapi: stddef.h: Introduce __kernel_nonstring

Kees Cook posted 10 patches 1 year ago
[PATCH 07/10] uapi: stddef.h: Introduce __kernel_nonstring
Posted by Kees Cook 1 year ago
In order to annotate byte arrays in UAPI that are not C strings (i.e.
they may not be NUL terminated), the "nonstring" attribute is needed.
However, we can't expose this to userspace as it is compiler version
specific.

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Sven Eckelmann <sven@narfation.org>
Cc: Tadeusz Struk <tadeusz.struk@linaro.org>
Cc: Erick Archer <erick.archer@outlook.com>
Cc: Dmitry Antipov <dmantipov@yandex.ru>
---
 include/uapi/linux/stddef.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/stddef.h b/include/uapi/linux/stddef.h
index 58154117d9b0..0e7d289b7c2e 100644
--- a/include/uapi/linux/stddef.h
+++ b/include/uapi/linux/stddef.h
@@ -63,4 +63,10 @@
 #define __counted_by_be(m)
 #endif
 
+#ifdef __KERNEL__
+#define __kernel_nonstring	__nonstring
+#else
+#define __kernel_nonstring
+#endif
+
 #endif /* _UAPI_LINUX_STDDEF_H */
-- 
2.34.1