Whamcloud - gitweb
LU-17794 lustre: replace 0-length arrays with flexible arrays (3/3) 77/56077/4
authorJian Yu <yujian@whamcloud.com>
Wed, 21 Aug 2024 20:19:43 +0000 (13:19 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 30 Aug 2024 06:00:50 +0000 (06:00 +0000)
commit37acaa912f34d68f37f788d5478e04838b040fc9
tree3c12bd7ebb5f1ee398d87347e374f1502efdd6be
parent89b0bcdab5d7030cf8ad00f541e340fe539f3013
LU-17794 lustre: replace 0-length arrays with flexible arrays (3/3)

This patch replaces 0-length arrays with flexible arrays to
resolve the UBSAN array-index-out-of-bounds runtime warnings.

Most replacement of 0-length arrays with flexible arrays
requires no special handling. Simply removing the “0” in
the array declaration is sufficient.

In order to have a flexible array member in a union or alone
in a struct, it needs to be wrapped in an anonymous struct
with at least 1 named member, but that member can be empty.
This was wrapped in Linux with the DECLARE_FLEX_ARRAY() macro.

This patch also work-arounds SWIG limitations with flexible arrays.

Test-Parameters: optional mdtcount=4 mdscount=2 \
  clientdistro=ubuntu2404 testgroup=full-dne-part-1
Test-Parameters: optional mdtcount=4 mdscount=2 \
  clientdistro=ubuntu2404 testgroup=full-dne-part-2
Test-Parameters: optional mdtcount=4 mdscount=2 \
  clientdistro=ubuntu2404 testgroup=full-dne-part-3

Change-Id: I873663373332d63fb79137163149d42663f34705
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56077
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: Bruno Faccini <bfaccini@nvidia.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/include/uapi/linux/lnet/lnet-dlc.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/tests/lutf/src/Makefile.am