All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: kbuild-all@lists.01.org
Subject: Re: [linux-next:master 12105/12116] include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small
Date: Thu, 09 Sep 2021 08:45:56 -0700	[thread overview]
Message-ID: <202109090843.9E28C97@keescook> (raw)
In-Reply-To: <202109091134.FHnRmRxu-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 2552 bytes --]

On Thu, Sep 09, 2021 at 11:49:55AM +0800, kernel test robot wrote:
> 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.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
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 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();
>          |    ^~~~~~~~~~~~~~~


        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)


-- 
Kees Cook

WARNING: multiple messages have this Message-ID (diff)
From: Kees Cook <keescook@chromium.org>
To: kernel test robot <lkp@intel.com>
Cc: kbuild-all@lists.01.org,
	Linux Memory Management List <linux-mm@kvack.org>,
	Daniel Micay <danielmicay@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [linux-next:master 12105/12116] include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small
Date: Thu, 9 Sep 2021 08:45:56 -0700	[thread overview]
Message-ID: <202109090843.9E28C97@keescook> (raw)
In-Reply-To: <202109091134.FHnRmRxu-lkp@intel.com>

On Thu, Sep 09, 2021 at 11:49:55AM +0800, kernel test robot wrote:
> 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.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
> Reported-by: kernel test robot <lkp@intel.com>
> 
> 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();
>          |    ^~~~~~~~~~~~~~~


        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)


-- 
Kees Cook


  reply	other threads:[~2021-09-09 15:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  3:49 [linux-next:master 12105/12116] 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
2021-09-09  3:49 ` kernel test robot
2021-09-09 15:45 ` Kees Cook [this message]
2021-09-09 15:45   ` Kees Cook
2021-09-09 15:53   ` Kees Cook
2021-09-09 15:53     ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202109090843.9E28C97@keescook \
    --to=keescook@chromium.org \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.