Skip to content

Commit cbddcc4

Browse files
Tetsuo Handakdave
authored andcommitted
btrfs: set generation before calling btrfs_clean_tree_block in btrfs_init_new_buffer
syzbot is reporting uninit-value in btrfs_clean_tree_block() [1], for commit bc877d2 ("btrfs: Deduplicate extent_buffer init code") missed that btrfs_set_header_generation() in btrfs_init_new_buffer() must not be moved to after clean_tree_block() because clean_tree_block() is calling btrfs_header_generation() since commit 55c6907 ("Btrfs: Fix extent_buffer usage when nodesize != leafsize"). Since memzero_extent_buffer() will reset "struct btrfs_header" part, we can't move btrfs_set_header_generation() to before memzero_extent_buffer(). Just re-add btrfs_set_header_generation() before btrfs_clean_tree_block(). Link: https://syzkaller.appspot.com/bug?extid=fba8e2116a12609b6c59 [1] Reported-by: syzbot <[email protected]> Fixes: bc877d2 ("btrfs: Deduplicate extent_buffer init code") CC: [email protected] # 4.19+ Signed-off-by: Tetsuo Handa <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent db21370 commit cbddcc4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4890,6 +4890,9 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
48904890
!test_bit(BTRFS_ROOT_RESET_LOCKDEP_CLASS, &root->state))
48914891
lockdep_owner = BTRFS_FS_TREE_OBJECTID;
48924892

4893+
/* btrfs_clean_tree_block() accesses generation field. */
4894+
btrfs_set_header_generation(buf, trans->transid);
4895+
48934896
/*
48944897
* This needs to stay, because we could allocate a freed block from an
48954898
* old tree into a new tree, so we need to make sure this new block is

0 commit comments

Comments
 (0)