Whamcloud - gitweb
LU-17504 build: fix array-index-out-of-bounds warning 65/54365/8
authorJian Yu <yujian@whamcloud.com>
Wed, 3 Apr 2024 07:38:47 +0000 (00:38 -0700)
committerJian Yu <yujian@whamcloud.com>
Wed, 3 Apr 2024 07:38:47 +0000 (00:38 -0700)
commit21505a19d671868171de2ad0f94120b1ca779695
treee9d7e9c21123211987861691f29fddfcb5f71619
parentbb6a2d2e80f04645b488ecca6ba14cb628e3eeb3
LU-17504 build: fix array-index-out-of-bounds warning

On Linux kernel 6.5, due to commit 2d47c6956ab3
("ubsan: Tighten UBSAN_BOUNDS on GCC"), flexible
trailing arrays declared like 'lc_array_sum[1];'
will generate warnings when CONFIG_UBSAN & co. is
enabled:

  UBSAN: array-index-out-of-bounds in lprocfs_status.c:1609:17
  index 1 is out of range for type '__s64 [1]'

Since LPROCFS_STATS_FLAG_IRQ_SAFE flag is only used
in one place - obd_memory() counter, we can just
remove it and change obd_memory over to a regular
percpu_counter. This would both simplify the
lprocfs_counter() code, move over to using more
kernel functionality instead of libcfs, as well as
reduce overhead slightly for the memory accounting code.

Change-Id: Ic461c4b30317bfd2b1e9f5b6be84c4a7fb4e3eb9
Signed-off-by: Jian Yu <yujian@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/lprocfs_status.h
lustre/include/obd_support.h
lustre/obdclass/class_obd.c
lustre/obdclass/lprocfs_counters.c
lustre/obdclass/lprocfs_status.c