Whamcloud - gitweb
LU-17504 build: fix array-index-out-of-bounds warning
authorJian Yu <yujian@whamcloud.com>
Wed, 3 Apr 2024 18:53:03 +0000 (11:53 -0700)
committerAndreas Dilger <adilger@whamcloud.com>
Sun, 7 Apr 2024 19:14:45 +0000 (19:14 +0000)
commitc1585822463f1011b440cad063189d6778342756
tree9e633e77b3ce39752c4cf9dc430d5b4793feaf18
parent32538d5bed904643291bac3db68e247e5bfd6284
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.

Lustre-change: https://review.whamcloud.com/54365
Lustre-commit: TBD (from 21505a19d671868171de2ad0f94120b1ca779695)

Change-Id: Ic461c4b30317bfd2b1e9f5b6be84c4a7fb4e3eb9
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54660
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@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