]> asedeno.scripts.mit.edu Git - linux.git/commit
m68knommu: fix memcpy() out of bounds warning in get_user()
authorGreg Ungerer <gerg@linux-m68k.org>
Fri, 17 Jan 2020 06:28:19 +0000 (16:28 +1000)
committerGreg Ungerer <gerg@linux-m68k.org>
Mon, 3 Feb 2020 04:43:35 +0000 (14:43 +1000)
commit8044aad70a1fbd66376cdb2a13e536db9dd6c132
tree193e4c1f48150567f7c32884a812a2bdb17b3f94
parentd5fae240b9bdb2d374624e6aa9f99a4527f111ec
m68knommu: fix memcpy() out of bounds warning in get_user()

Newer versions of gcc are giving warnings in the non-MMU m68k version
of the get_user() macro:

    ./arch/m68k/include/asm/string.h:72:25: warning: ‘__builtin_memcpy’ forming offset [3, 4] is out of the bounds [0, 2] of object ‘__gu_val’ with type ‘short unsigned int’ [-Warray-bounds]

The warnings are generated when smaller sized variables are used as the
result of user space pointers to larger values. For example a
short/2-byte variable stores the result of a user space int (4-byte)
pointer. The warning is in the 8-byte branch of get_user() - even
though that branch is not the taken branch in the warning cases.

Refactor the 8-byte branch of get_user() so that it uses a correctly
formed union type to read and write the source and destination objects.
Keep using the memcpy() just in case the user space pointer is not
naturaly aligned (not required for ColdFire, but needed for early
68000).

Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
arch/m68k/include/asm/uaccess_no.h