]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: set generation before calling btrfs_clean_tree_block in btrfs_init_new_buffer
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Tue, 20 Sep 2022 13:43:51 +0000 (22:43 +0900)
committerDavid Sterba <dsterba@suse.com>
Thu, 29 Sep 2022 15:08:31 +0000 (17:08 +0200)
commit3d7ffff65adda50716dff800b43c1dae4e2d75ca
tree3bbcdb1c58e7d96e0cc5f9d4ba439e7c1c9ac285
parentda9696b840cbb2e3208897fc4241b29d417b3feb
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 7347054c035ee7be ("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 55c69072d6bd5be1 ("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
Reported-by: syzbot <syzbot+fba8e2116a12609b6c59@syzkaller.appspotmail.com>
Fixes: 7347054c035ee7be ("btrfs: Deduplicate extent_buffer init code")
CC: stable@vger.kernel.org # 4.19+
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c