include/asm-generic/unaligned.h:14:15: warning: array subscript -1 is outside array bounds of 'char[]'

From: kernel test robot
Date: Tue Sep 19 2023 - 11:30:33 EST


Hi Ard,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2cf0f715623872823a72e451243bbf555d10d032
commit: a050910972bb25152b42ad2e544652117c5ad915 efi/libstub: implement generic EFI zboot
date: 12 months ago
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20230919/202309192322.kHMCRGo5-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309192322.kHMCRGo5-lkp@xxxxxxxxx/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
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309192322.kHMCRGo5-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/firmware/efi/libstub/zboot.c:163:1: warning: no previous prototype for 'efi_zboot_entry' [-Wmissing-prototypes]
163 | efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab)
| ^~~~~~~~~~~~~~~
In file included from include/linux/byteorder/little_endian.h:5,
from arch/loongarch/include/uapi/asm/byteorder.h:11,
from include/asm-generic/qrwlock_types.h:6,
from ./arch/loongarch/include/generated/asm/qrwlock_types.h:1,
from include/asm-generic/spinlock_types.h:13,
from ./arch/loongarch/include/generated/asm/spinlock_types.h:1,
from include/linux/spinlock_types_raw.h:7,
from include/linux/ratelimit_types.h:7,
from include/linux/printk.h:9,
from include/asm-generic/bug.h:22,
from arch/loongarch/include/asm/bug.h:21,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/preempt.h:5,
from ./arch/loongarch/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:78,
from include/linux/spinlock.h:55,
from include/linux/wait.h:9,
from include/linux/wait_bit.h:8,
from include/linux/fs.h:6,
from include/linux/proc_fs.h:10,
from include/linux/efi.h:19,
from drivers/firmware/efi/libstub/zboot.c:3:
In function 'get_unaligned_le32',
inlined from 'load_file' at drivers/firmware/efi/libstub/zboot.c:92:22:
>> include/asm-generic/unaligned.h:14:15: warning: array subscript -1 is outside array bounds of 'char[]' [-Warray-bounds=]
14 | __pptr->x; \
| ~~~~~~^~~
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/asm-generic/unaligned.h:32:28: note: in expansion of macro '__get_unaligned_t'
32 | return le32_to_cpu(__get_unaligned_t(__le32, p));
| ^~~~~~~~~~~~~~~~~
drivers/firmware/efi/libstub/zboot.c: In function 'load_file':
drivers/firmware/efi/libstub/zboot.c:33:30: note: at offset -4 into object '_gzdata_end' of size [0, 9223372036854775807]
33 | extern char _gzdata_start[], _gzdata_end[];
| ^~~~~~~~~~~


vim +14 include/asm-generic/unaligned.h

aafe4dbed0bf6c Arnd Bergmann 2009-05-13 11
803f4e1eab7a89 Arnd Bergmann 2021-05-08 12 #define __get_unaligned_t(type, ptr) ({ \
803f4e1eab7a89 Arnd Bergmann 2021-05-08 13 const struct { type x; } __packed *__pptr = (typeof(__pptr))(ptr); \
803f4e1eab7a89 Arnd Bergmann 2021-05-08 @14 __pptr->x; \
803f4e1eab7a89 Arnd Bergmann 2021-05-08 15 })
803f4e1eab7a89 Arnd Bergmann 2021-05-08 16

:::::: The code at line 14 was first introduced by commit
:::::: 803f4e1eab7a8938ba3a3c30dd4eb5e9eeef5e63 asm-generic: simplify asm/unaligned.h

:::::: TO: Arnd Bergmann <arnd@xxxxxxxx>
:::::: CC: Arnd Bergmann <arnd@xxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki