提交 85bca3c0 编写于 作者: J Joe Thornber 提交者: Mike Snitzer

dm btree: add a defensive bounds check to insert_at()

Corrupt metadata could trigger an out of bounds write.
Signed-off-by: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
上级 c671ffa5
......@@ -85,10 +85,12 @@ static int insert_at(size_t value_size, struct btree_node *node, unsigned index,
__dm_written_to_disk(value)
{
uint32_t nr_entries = le32_to_cpu(node->header.nr_entries);
uint32_t max_entries = le32_to_cpu(node->header.max_entries);
__le64 key_le = cpu_to_le64(key);
if (index > nr_entries ||
index >= le32_to_cpu(node->header.max_entries)) {
index >= max_entries ||
nr_entries >= max_entries) {
DMERR("too many entries in btree node for insert");
__dm_unbless_for_disk(value);
return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册