]> git.baikalelectronics.ru Git - kernel.git/commit
nilfs2: fix sanity check of btree level in nilfs_btree_root_broken()
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Tue, 5 May 2015 23:24:00 +0000 (16:24 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 6 May 2015 00:10:11 +0000 (17:10 -0700)
commitb1ee97ba72549fc38eb88a2caa6c08d2a6361f79
treeb515748f38393aa4b3ff6f7562848e3242bf9739
parent95179baddeb2678b4b12aab2290b9d7d3f5aca41
nilfs2: fix sanity check of btree level in nilfs_btree_root_broken()

The range check for b-tree level parameter in nilfs_btree_root_broken()
is wrong; it accepts the case of "level == NILFS_BTREE_LEVEL_MAX" even
though the level is limited to values in the range of 0 to
(NILFS_BTREE_LEVEL_MAX - 1).

Since the level parameter is read from storage device and used to index
nilfs_btree_path array whose element count is NILFS_BTREE_LEVEL_MAX, it
can cause memory overrun during btree operations if the boundary value
is set to the level parameter on device.

This fixes the broken sanity check and adds a comment to clarify that
the upper bound NILFS_BTREE_LEVEL_MAX is exclusive.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/nilfs2/btree.c
include/linux/nilfs2_fs.h