[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202209030030.6E1ZzYRH-lkp@intel.com>
Date: Sat, 3 Sep 2022 00:27:20 +0800
From: kernel test robot <lkp@...el.com>
To: Kees Cook <keescook@...omium.org>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [kees:for-next/hardening 5/7] include/linux/string.h:303:42:
warning: 'strnlen' specified bound 4 exceeds source size 3
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
head: 772415ab4ccaf1211c0336a8a6bac851f0ad9b98
commit: 750b3123f855b1287c0c90f480c874df10f6abb5 [5/7] string: Introduce strtomem() and strtomem_pad()
config: microblaze-buildonly-randconfig-r003-20220901
compiler: microblaze-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=750b3123f855b1287c0c90f480c874df10f6abb5
git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git
git fetch --no-tags kees for-next/hardening
git checkout 750b3123f855b1287c0c90f480c874df10f6abb5
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/kernel.h:26,
from include/linux/cpumask.h:10,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/spinlock.h:62,
from include/linux/kref.h:16,
from include/kunit/test.h:20,
from lib/memcpy_kunit.c:7:
lib/memcpy_kunit.c: In function 'strtomem_test':
>> include/linux/string.h:303:42: warning: 'strnlen' specified bound 4 exceeds source size 3 [-Wstringop-overread]
303 | memcpy(dest, src, min(_dest_len, strnlen(src, _dest_len))); \
include/linux/minmax.h:32:39: note: in definition of macro '__cmp_once'
32 | typeof(y) unique_y = (y); \
| ^
include/linux/minmax.h:45:25: note: in expansion of macro '__careful_cmp'
45 | #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~
include/linux/string.h:303:27: note: in expansion of macro 'min'
303 | memcpy(dest, src, min(_dest_len, strnlen(src, _dest_len))); \
| ^~~
lib/memcpy_kunit.c:290:9: note: in expansion of macro 'strtomem'
290 | strtomem(wrap.output, input);
| ^~~~~~~~
lib/memcpy_kunit.c:275:27: note: source object allocated here
275 | static const char input[] = "hi";
| ^~~~~
In file included from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12:
include/linux/string.h:282:9: warning: 'strnlen' specified bound 4 exceeds source size 3 [-Wstringop-overread]
282 | memcpy_and_pad(dest, _dest_len, src, strnlen(src, _dest_len), pad); \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/memcpy_kunit.c:308:9: note: in expansion of macro 'strtomem_pad'
308 | strtomem_pad(wrap.output, input, 0xAA);
| ^~~~~~~~~~~~
lib/memcpy_kunit.c:275:27: note: source object allocated here
275 | static const char input[] = "hi";
| ^~~~~
vim +/strnlen +303 include/linux/string.h
284
285 /**
286 * strtomem - Copy NUL-terminated string to non-NUL-terminated buffer
287 *
288 * @dest: Pointer of destination character array (marked as __nonstring)
289 * @src: Pointer to NUL-terminated string
290 *
291 * This is a replacement for strncpy() uses where the destination is not
292 * a NUL-terminated string, but with bounds checking on the source size, and
293 * without trailing padding. If padding is required, use strtomem_pad().
294 *
295 * Note that the size of @dest is not an argument, as the length of @dest
296 * must be discoverable by the compiler.
297 */
298 #define strtomem(dest, src) do { \
299 const size_t _dest_len = __builtin_object_size(dest, 1); \
300 \
301 BUILD_BUG_ON(!__builtin_constant_p(_dest_len) || \
302 _dest_len == (size_t)-1); \
> 303 memcpy(dest, src, min(_dest_len, strnlen(src, _dest_len))); \
304 } while (0)
305
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (136927 bytes)
Powered by blists - more mailing lists