https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90673

            Bug ID: 90673
           Summary: A problem with 'copy destination size is too small'
                    warning in copy_from_user
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yaro330 at gmail dot com
  Target Milestone: ---

Example function:
static ssize_t ipa3_write_ep_holb(struct file *file,
                const char __user *buf, size_t count, loff_t *ppos)
{

 unsigned long missing;
 char dbg_buff[512];
 missing = copy_from_user(dbg_buff, ubuf, count);
 if (missing)
   return -EFAULT;
}

call to copy_from_user is triggering an error:

error: call to ‘__bad_copy_to’ declared with attribute error: copy destination
size is too small

and no matter how high I set size for it the error persists.
Replacing 'count' with 'sizeof(buf)' fixes the error but it doesn't seem to
make much sence.

Exact gcc version: gcc version 8.3.1 20190329 (GCC)
Link to the file and entore function that gcc errors on:
https://github.com/YaroST12/VIOLET_Kernel/blob/b300d2b072c072738297ea981ace652d54a8fea1/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c#L144
(pushed away from working branch)

Reply via email to