* include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0
@ 2026-04-07 4:03 kernel test robot
2026-04-07 5:12 ` Ian Rogers
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2026-04-07 4:03 UTC (permalink / raw)
To: Ian Rogers; +Cc: oe-kbuild-all, linux-kernel, Thomas Gleixner
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: bfe62a454542cfad3379f6ef5680b125f41e20f4
commit: a339671db64b12bb02492557d2b0658811286277 vdso: Switch get/put_unaligned() from packed struct to memcpy()
date: 3 months ago
config: mips-randconfig-r111-20260406 (https://download.01.org/0day-ci/archive/20260407/202604070917.ZVd6Ugz4-lkp@intel.com/config)
compiler: mips-linux-gcc (GCC) 13.4.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260407/202604070917.ZVd6Ugz4-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: a339671db64b ("vdso: Switch get/put_unaligned() from packed struct to memcpy()")
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604070917.ZVd6Ugz4-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/byteorder/little_endian.h:5,
from arch/mips/include/uapi/asm/byteorder.h:15,
from arch/mips/include/asm/bitops.h:21,
from include/linux/bitops.h:67,
from include/linux/kernel.h:23,
from arch/mips/boot/compressed/decompress.c:14:
In function 'get_unaligned_le32',
inlined from 'decompress_kernel' at arch/mips/boot/compressed/decompress.c:113:16:
>> include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0 [-Wstringop-overread]
23 | __builtin_memcpy(&__get_unaligned_val, (void *)(ptr), \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 | sizeof(__get_unaligned_val)); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/uapi/linux/byteorder/little_endian.h:35:51: note: in definition of macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
include/linux/unaligned.h:23:28: note: in expansion of macro '__get_unaligned_t'
23 | return le32_to_cpu(__get_unaligned_t(__le32, p));
| ^~~~~~~~~~~~~~~~~
In file included from arch/mips/boot/compressed/decompress.c:22:
arch/mips/boot/compressed/decompress.h: In function 'decompress_kernel':
arch/mips/boot/compressed/decompress.h:6:39: note: at offset -4 into source object '__image_end' of size [0, 2147483647]
6 | extern unsigned char __image_begin[], __image_end[];
| ^~~~~~~~~~~
vim +/__builtin_memcpy +23 include/vdso/unaligned.h
6
7 /**
8 * __get_unaligned_t - read an unaligned value from memory.
9 * @type: the type to load from the pointer.
10 * @ptr: the pointer to load from.
11 *
12 * Use memcpy to affect an unaligned type sized load avoiding undefined behavior
13 * from approaches like type punning that require -fno-strict-aliasing in order
14 * to be correct. As type may be const, use __unqual_scalar_typeof to map to a
15 * non-const type - you can't memcpy into a const type. The
16 * __get_unaligned_ctrl_type gives __unqual_scalar_typeof its required
17 * expression rather than type, a pointer is used to avoid warnings about mixing
18 * the use of 0 and NULL. The void* cast silences ubsan warnings.
19 */
20 #define __get_unaligned_t(type, ptr) ({ \
21 type *__get_unaligned_ctrl_type __always_unused = NULL; \
22 __unqual_scalar_typeof(*__get_unaligned_ctrl_type) __get_unaligned_val; \
> 23 __builtin_memcpy(&__get_unaligned_val, (void *)(ptr), \
24 sizeof(__get_unaligned_val)); \
25 __get_unaligned_val; \
26 })
27
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0
2026-04-07 4:03 include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0 kernel test robot
@ 2026-04-07 5:12 ` Ian Rogers
0 siblings, 0 replies; 2+ messages in thread
From: Ian Rogers @ 2026-04-07 5:12 UTC (permalink / raw)
To: kernel test robot, linux-mips
Cc: oe-kbuild-all, linux-kernel, Thomas Gleixner
On Mon, Apr 6, 2026 at 9:03 PM kernel test robot <lkp@intel.com> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: bfe62a454542cfad3379f6ef5680b125f41e20f4
> commit: a339671db64b12bb02492557d2b0658811286277 vdso: Switch get/put_unaligned() from packed struct to memcpy()
> date: 3 months ago
> config: mips-randconfig-r111-20260406 (https://download.01.org/0day-ci/archive/20260407/202604070917.ZVd6Ugz4-lkp@intel.com/config)
> compiler: mips-linux-gcc (GCC) 13.4.0
> sparse: v0.6.5-rc1
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260407/202604070917.ZVd6Ugz4-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Fixes: a339671db64b ("vdso: Switch get/put_unaligned() from packed struct to memcpy()")
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202604070917.ZVd6Ugz4-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/byteorder/little_endian.h:5,
> from arch/mips/include/uapi/asm/byteorder.h:15,
> from arch/mips/include/asm/bitops.h:21,
> from include/linux/bitops.h:67,
> from include/linux/kernel.h:23,
> from arch/mips/boot/compressed/decompress.c:14:
> In function 'get_unaligned_le32',
> inlined from 'decompress_kernel' at arch/mips/boot/compressed/decompress.c:113:16:
> >> include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0 [-Wstringop-overread]
> 23 | __builtin_memcpy(&__get_unaligned_val, (void *)(ptr), \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 24 | sizeof(__get_unaligned_val)); \
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> include/uapi/linux/byteorder/little_endian.h:35:51: note: in definition of macro '__le32_to_cpu'
> 35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
> | ^
> include/linux/unaligned.h:23:28: note: in expansion of macro '__get_unaligned_t'
> 23 | return le32_to_cpu(__get_unaligned_t(__le32, p));
> | ^~~~~~~~~~~~~~~~~
> In file included from arch/mips/boot/compressed/decompress.c:22:
> arch/mips/boot/compressed/decompress.h: In function 'decompress_kernel':
> arch/mips/boot/compressed/decompress.h:6:39: note: at offset -4 into source object '__image_end' of size [0, 2147483647]
> 6 | extern unsigned char __image_begin[], __image_end[];
> | ^~~~~~~~~~~
I wonder if in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/mips/boot/compressed/decompress.c#n113
```
image_size = get_unaligned_le32((void *)__image_end - 4);
```
would be better as:
```
image_size = get_unaligned_le32((void *)__image_begin + zimage_size - 4);
```
so that the code isn't negatively indexing an array.
Thanks,
Ian
>
> vim +/__builtin_memcpy +23 include/vdso/unaligned.h
>
> 6
> 7 /**
> 8 * __get_unaligned_t - read an unaligned value from memory.
> 9 * @type: the type to load from the pointer.
> 10 * @ptr: the pointer to load from.
> 11 *
> 12 * Use memcpy to affect an unaligned type sized load avoiding undefined behavior
> 13 * from approaches like type punning that require -fno-strict-aliasing in order
> 14 * to be correct. As type may be const, use __unqual_scalar_typeof to map to a
> 15 * non-const type - you can't memcpy into a const type. The
> 16 * __get_unaligned_ctrl_type gives __unqual_scalar_typeof its required
> 17 * expression rather than type, a pointer is used to avoid warnings about mixing
> 18 * the use of 0 and NULL. The void* cast silences ubsan warnings.
> 19 */
> 20 #define __get_unaligned_t(type, ptr) ({ \
> 21 type *__get_unaligned_ctrl_type __always_unused = NULL; \
> 22 __unqual_scalar_typeof(*__get_unaligned_ctrl_type) __get_unaligned_val; \
> > 23 __builtin_memcpy(&__get_unaligned_val, (void *)(ptr), \
> 24 sizeof(__get_unaligned_val)); \
> 25 __get_unaligned_val; \
> 26 })
> 27
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-07 5:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-07 4:03 include/vdso/unaligned.h:23:9: warning: '__builtin_memcpy' reading 4 bytes from a region of size 0 kernel test robot
2026-04-07 5:12 ` Ian Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®