Re: [syzbot] [bcachefs?] KMSAN: uninit-value in bch2_btree_node_iter_init (2)

From: Piotr Zalewski
Date: Sun Nov 17 2024 - 18:51:54 EST


Hi, all

This seems to be the proper way to fix this?:

diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index 89a42ee81e5c..f92a3fb946de 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -324,6 +324,7 @@ static void btree_node_sort(struct bch_fs *c, struct btree *b,
start_time = local_clock();

u64s = bch2_sort_keys(out->keys.start, &sort_iter.iter);
+ memset((out->keys.start + u64s), 0, bytes - sizeof(struct btree_node) - u64s * sizeof(u64));

out->keys.u64s = cpu_to_le16(u64s);