From 51b425d63a4d9482448da633224d82fa9fb4ec5d Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Fri, 6 Dec 2024 09:50:58 -0800 Subject: [PATCH] LU-18518 ldiskfs: fix htree_lock array-index-out-of-bounds This patch replaces 0-length trailing arrays with flexible arrays in htree_lock.h to resolve the UBSAN array-index-out-of-bounds runtime warnings. Test-Parameters: mdtcount=4 mdscount=2 \ clientdistro=ubuntu2404 testlist=sanity Change-Id: I30b624a09f3f918ddaac105fb06db9fd4c693799 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57327 Tested-by: jenkins Tested-by: Shuichi Ihara Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- ldiskfs/kernel_patches/patches/base/ext4-htree-lock.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ldiskfs/kernel_patches/patches/base/ext4-htree-lock.patch b/ldiskfs/kernel_patches/patches/base/ext4-htree-lock.patch index 2e76284..3601087 100644 --- a/ldiskfs/kernel_patches/patches/base/ext4-htree-lock.patch +++ b/ldiskfs/kernel_patches/patches/base/ext4-htree-lock.patch @@ -152,7 +152,7 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h + /* private data */ + void *lh_private; + /* array of children locks */ -+ struct htree_lock_child lh_children[0]; ++ struct htree_lock_child lh_children[]; +}; + +/* htree_lock_node_t is child-lock for a specific key (ln_value) */ @@ -180,7 +180,7 @@ Index: linux-3.10.0-229.1.2.fc21.x86_64/include/linux/htree_lock.h + unsigned lk_depth; + htree_lock_mode_t lk_mode; + struct list_head lk_blocked_list; -+ struct htree_lock_node lk_nodes[0]; ++ struct htree_lock_node lk_nodes[]; +}; + +/* create a lock head, which stands for a resource */ -- 1.8.3.1