From: Kees Cook Date: Tue, 25 Oct 2022 23:05:18 +0000 (-0700) Subject: fortify: Do not cast to "unsigned char" X-Git-Tag: v6.0.16~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05b613abddff243316d4932367941df7253126e4;p=thirdparty%2Fkernel%2Fstable.git fortify: Do not cast to "unsigned char" [ Upstream commit e9a40e1585d792751d3a122392695e5a53032809 ] Do not cast to "unsigned char", as this needlessly creates type problems when attempting builds without -Wno-pointer-sign[1]. The intent of the cast is to drop possible "const" types. [1] https://lore.kernel.org/lkml/CAHk-=wgz3Uba8w7kdXhsqR1qvfemYL+OFQdefJnkeqXG8qZ_pA@mail.gmail.com/ Suggested-by: Linus Torvalds Fixes: 3009f891bb9f ("fortify: Allow strlen() and strnlen() to pass compile-time known lengths") Cc: linux-hardening@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- diff --git a/include/linux/fortify-string.h b/include/linux/fortify-string.h index ae076aae9e662..c26160fe2e34e 100644 --- a/include/linux/fortify-string.h +++ b/include/linux/fortify-string.h @@ -17,7 +17,7 @@ void __write_overflow_field(size_t avail, size_t wanted) __compiletime_warning(" #define __compiletime_strlen(p) \ ({ \ - unsigned char *__p = (unsigned char *)(p); \ + char *__p = (char *)(p); \ size_t __ret = SIZE_MAX; \ size_t __p_size = __builtin_object_size(p, 1); \ if (__p_size != SIZE_MAX && \