]> git.hungrycats.org Git - linux/commit
Btrfs: error out if generic_bin_search get invalid arguments
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 23 Jun 2016 23:32:45 +0000 (16:32 -0700)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Wed, 17 Aug 2016 02:06:35 +0000 (22:06 -0400)
commit7768b7ed281485dbac9d5c4ad067388f91792a11
tree87ea41b1d1cc46b1d8906b9e189c5aea2cd3f8d6
parenteb75696d60f610b23d8b23df2ffcf45ae56176b3
Btrfs: error out if generic_bin_search get invalid arguments

With btrfs-corrupt-block, one can set btree node/leaf's field, if
we assign a negative value to node/leaf, we can get various hangs,
eg. if extent_root's nritems is -2ULL, then we get stuck in
 btrfs_read_block_groups() because it has a while loop and
btrfs_search_slot() on extent_root will always return the first
 child.

This lets us know what's happening and returns a EINVAL to callers
instead of returning the first item.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 5e24e9af01abcb151173bb133f1a72b94239c670)
fs/btrfs/ctree.c