Whamcloud - gitweb
LU-17504 build: fix array-index-out-of-bounds warning 65/54365/9
authorJian Yu <yujian@whamcloud.com>
Wed, 3 Apr 2024 07:38:47 +0000 (00:38 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 15 Apr 2024 16:52:49 +0000 (16:52 +0000)
commitb698abd415bc4a810f307611fe984e50e007581e
tree51396c1f9f8f36d61a4d19b68acac051ebe0fa55
parent5dc91df283fb5a7030b384f224085d73268dcca5
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>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54365
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@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