]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
Btrfs: check btree node's nritems
authorLiu Bo <bo.li.liu@oracle.com>
Wed, 24 Aug 2016 00:37:45 +0000 (17:37 -0700)
committerChris Mason <clm@fb.com>
Thu, 25 Aug 2016 10:58:30 +0000 (03:58 -0700)
commit053ab70f0604224c7893b43f9d9d5efa283580d6
tree7f2ac232c96eafbfbc71a85337ad935d9e599473
parent35bbb97fc898aeb874cb7c8b746f091caa359994
Btrfs: check btree node's nritems

When btree node (level = 1) has nritems which equals to zero,
we can end up with panic due to insert_ptr()'s

BUG_ON(slot > nritems);

where slot is 1 and nritems is 0, as copy_for_split() calls
insert_ptr(.., path->slots[1] + 1, ...);

A invalid value results in the whole mess, this adds the check
for btree's node nritems so that we stop reading block when
when something is wrong.

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>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/disk-io.c