diff options
author | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2015-05-05 19:24:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-05-05 20:10:11 -0400 |
commit | d8fd150fe3935e1692bf57c66691e17409ebb9c1 (patch) | |
tree | b515748f38393aa4b3ff6f7562848e3242bf9739 /fs/nilfs2/btree.c | |
parent | 05836c378c7af9527b98a83746f32c7289a5f3c8 (diff) |
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>
Diffstat (limited to 'fs/nilfs2/btree.c')
-rw-r--r-- | fs/nilfs2/btree.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c index 059f37137f9a..919fd5bb14a8 100644 --- a/fs/nilfs2/btree.c +++ b/fs/nilfs2/btree.c | |||
@@ -388,7 +388,7 @@ static int nilfs_btree_root_broken(const struct nilfs_btree_node *node, | |||
388 | nchildren = nilfs_btree_node_get_nchildren(node); | 388 | nchildren = nilfs_btree_node_get_nchildren(node); |
389 | 389 | ||
390 | if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN || | 390 | if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN || |
391 | level > NILFS_BTREE_LEVEL_MAX || | 391 | level >= NILFS_BTREE_LEVEL_MAX || |
392 | nchildren < 0 || | 392 | nchildren < 0 || |
393 | nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) { | 393 | nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) { |
394 | pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n", | 394 | pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n", |