Whamcloud - gitweb
LU-17794 lustre: replace 0-length arrays with flexible arrays (1/3) 74/55874/7
authorJian Yu <yujian@whamcloud.com>
Tue, 6 Aug 2024 10:26:45 +0000 (03:26 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 23 Aug 2024 21:59:45 +0000 (21:59 +0000)
commit51a281cdb405fec311f280cfabc156c8746e2412
treeda5b7c564cc2f09ae2c9c9dd4054fea09dda3839
parentd0cfa638df48da39562ca8cfadee1347a2923b36
LU-17794 lustre: replace 0-length arrays with flexible arrays (1/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.

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: I0e23a92382686678951f5d0dc56d91c895af7817
Signed-off-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55874
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Xi <lixi@ddn.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
36 files changed:
libcfs/include/libcfs/libcfs_hash.h
lnet/include/lnet/lib-types.h
lnet/include/uapi/linux/lnet/libcfs_ioctl.h
lnet/include/uapi/linux/lnet/lnetst.h
lnet/klnds/o2iblnd/o2iblnd.h
lnet/klnds/socklnd/socklnd.h
lnet/lnet/lib-cpt.c
lnet/selftest/console.h
lnet/selftest/selftest.h
lnet/utils/lst.c
lustre/doc/llapi_heat_get.3
lustre/include/lprocfs_status.h
lustre/include/lustre/libiam.h
lustre/include/lustre/lustreapi.h
lustre/include/lustre_dlm.h
lustre/include/lustre_lmv.h
lustre/include/lustre_net.h
lustre/include/lustre_scrub.h
lustre/include/lustre_sec.h
lustre/include/uapi/linux/lustre/lustre_cfg.h
lustre/include/uapi/linux/lustre/lustre_idl.h
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/lfsck/lfsck_internal.h
lustre/lmv/lmv_obd.c
lustre/lov/lov_cl_internal.h
lustre/mgs/mgs_llog.c
lustre/obdclass/kernelcomm.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_iam.h
lustre/osd-ldiskfs/osd_iam_lvar.c
lustre/ptlrpc/gss/gss_krb5.h
lustre/ptlrpc/ptlrpcd.c
lustre/tests/check_fhandle_syscalls.c
lustre/utils/liblustreapi_chlg.c
lustre/utils/lsnapshot.c
lustre/utils/mount_utils.c