include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small
kernel test robot
build bottree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 999569d59a0aa2509ae4a67ecc266c1134e37e7b commit: f5b1a5d922d3199e0637349239b43aed6c7656b9 [12105/12116] mm/vmalloc: add __alloc_size attributes for better bounds checking config: i386-randconfig-a002-20200329 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f5b1a5d922d3199e0637349239b43aed6c7656b9
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout f5b1a5d922d3199e0637349239b43aed6c7656b9
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/rapidio/devices/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
In file included from arch/x86/include/asm/preempt.h:7,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/mm_types.h:9,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/rapidio/devices/rio_mport_cdev.c:13:
In function 'check_copy_size',
inlined from 'copy_from_user' at include/linux/uaccess.h:191:6,
inlined from 'rio_mport_transfer_ioctl' at drivers/rapidio/devices/rio_mport_cdev.c:983:6:
>> include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small
213 | __bad_copy_to();
| ^~~~~~~~~~~~~~~vim +/__bad_copy_to +213 include/linux/thread_info.h
b0377fedb6528087 Al Viro 2017-06-29 202
9dd819a15162f8f8 Kees Cook 2019-09-25 203 static __always_inline __must_check bool
b0377fedb6528087 Al Viro 2017-06-29 204 check_copy_size(const void *addr, size_t bytes, bool is_source)
b0377fedb6528087 Al Viro 2017-06-29 205 {
122b05c65c5d9cad Kees Cook 2021-06-17 206 int sz = __builtin_object_size(addr, 0);
b0377fedb6528087 Al Viro 2017-06-29 207 if (unlikely(sz >= 0 && sz < bytes)) {
b0377fedb6528087 Al Viro 2017-06-29 208 if (!__builtin_constant_p(bytes))
b0377fedb6528087 Al Viro 2017-06-29 209 copy_overflow(sz, bytes);
b0377fedb6528087 Al Viro 2017-06-29 210 else if (is_source)
b0377fedb6528087 Al Viro 2017-06-29 211 __bad_copy_from();
b0377fedb6528087 Al Viro 2017-06-29 212 else
b0377fedb6528087 Al Viro 2017-06-29 @213 __bad_copy_to();
b0377fedb6528087 Al Viro 2017-06-29 214 return false;
b0377fedb6528087 Al Viro 2017-06-29 215 }
6d13de1489b6bf53 Kees Cook 2019-12-04 216 if (WARN_ON_ONCE(bytes > INT_MAX))
6d13de1489b6bf53 Kees Cook 2019-12-04 217 return false;
b0377fedb6528087 Al Viro 2017-06-29 218 check_object_size(addr, bytes, is_source);
b0377fedb6528087 Al Viro 2017-06-29 219 return true;
b0377fedb6528087 Al Viro 2017-06-29 220 }b0377fedb6528087 Al Viro 2017-06-29 221
:::::: The code at line 213 was first introduced by commit
:::::: b0377fedb6528087ed319b0d054d6ed82240372c copy_{to,from}_user(): consolidate object size checks
:::::: TO: Al Viro <[email protected]>
:::::: CC: Al Viro <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Quoted 29 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 999569d59a0aa2509ae4a67ecc266c1134e37e7b commit: f5b1a5d922d3199e0637349239b43aed6c7656b9 [12105/12116] mm/vmalloc: add __alloc_size attributes for better bounds checking config: i386-randconfig-a002-20200329 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f5b1a5d922d3199e0637349239b43aed6c7656b9
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkoutf5b1a5d922d3199e0637349239b43aed6c7656b9
# save the attached .config to linux build tree
mkdirbuild_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bashdrivers/rapidio/devices/If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All errors (new ones prefixed by >>):
In file included from
arch/x86/include/asm/preempt.h:7,
frominclude/linux/preempt.h:78,
frominclude/linux/spinlock.h:55,
frominclude/linux/mm_types.h:9,
frominclude/linux/buildid.h:5,
frominclude/linux/module.h:14,
fromdrivers/rapidio/devices/rio_mport_cdev.c:13:
In function 'check_copy_size',
inlined from 'copy_from_user' atinclude/linux/uaccess.h:191:6,
inlined from 'rio_mport_transfer_ioctl' atdrivers/rapidio/devices/rio_mport_cdev.c:983:6:
Quoted 3 lines
Quoted 1 line
Quoted 1 line
include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small213 | __bad_copy_to(); | ^~~~~~~~~~~~~~~
transfer = vmalloc(array_size(sizeof(*transfer), transaction.count));
if (!transfer)
return -ENOMEM;
if (unlikely(copy_from_user(transfer,
(void __user *)(uintptr_t)transaction.block,
array_size(sizeof(*transfer), transaction.count)))) {Uhhhmm... allocation size and copy size are identical...
array_size(sizeof(*transfer), transaction.count) array_size(sizeof(*transfer), transaction.count)
Signature · 1 line
Kees Cook
Quoted 43 lines · Kees Cook
Quoted 29 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 999569d59a0aa2509ae4a67ecc266c1134e37e7b commit: f5b1a5d922d3199e0637349239b43aed6c7656b9 [12105/12116] mm/vmalloc: add __alloc_size attributes for better bounds checking config: i386-randconfig-a002-20200329 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f5b1a5d922d3199e0637349239b43aed6c7656b9
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkoutf5b1a5d922d3199e0637349239b43aed6c7656b9
# save the attached .config to linux build tree
mkdirbuild_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bashdrivers/rapidio/devices/If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All errors (new ones prefixed by >>):
In file included from
arch/x86/include/asm/preempt.h:7,
frominclude/linux/preempt.h:78,
frominclude/linux/spinlock.h:55,
frominclude/linux/mm_types.h:9,
frominclude/linux/buildid.h:5,
frominclude/linux/module.h:14,
fromdrivers/rapidio/devices/rio_mport_cdev.c:13:
In function 'check_copy_size',
inlined from 'copy_from_user' atinclude/linux/uaccess.h:191:6,
inlined from 'rio_mport_transfer_ioctl' atdrivers/rapidio/devices/rio_mport_cdev.c:983:6:Quoted 3 lines
Quoted 1 line
Quoted 1 line
include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small213 | __bad_copy_to(); | ^~~~~~~~~~~~~~~transfer = vmalloc(array_size(sizeof(*transfer), transaction.count)); if (!transfer) return -ENOMEM; if (unlikely(copy_from_user(transfer, (void __user *)(uintptr_t)transaction.block, array_size(sizeof(*transfer), transaction.count)))) {
Quoted 4 lines
Uhhhmm... allocation size and copy size are identical...
array_size(sizeof(*transfer), transaction.count)
array_size(sizeof(*transfer), transaction.count)
This appears to be an optimization(?) bug in GCC 9.3. This warning (correctly) does not appear in later versions.
Signature · 1 line
Kees Cook