Commit 03b71c6c authored by Gabriel de Perthuis's avatar Gabriel de Perthuis Committed by Josef Bacik

btrfs: don't stop searching after encountering the wrong item

The search ioctl skips items that are too large for a result buffer, but
inline items of a certain size occuring before any search result is
found would trigger an overflow and stop the search entirely.

Bug: https://bugzilla.kernel.org/show_bug.cgi?id=57641

Cc: stable@vger.kernel.org
Signed-off-by: default avatarGabriel de Perthuis <g2p.code+btrfs@gmail.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent a52f4cd2
...@@ -1801,7 +1801,11 @@ static noinline int copy_to_sk(struct btrfs_root *root, ...@@ -1801,7 +1801,11 @@ static noinline int copy_to_sk(struct btrfs_root *root,
item_off = btrfs_item_ptr_offset(leaf, i); item_off = btrfs_item_ptr_offset(leaf, i);
item_len = btrfs_item_size_nr(leaf, i); item_len = btrfs_item_size_nr(leaf, i);
if (item_len > BTRFS_SEARCH_ARGS_BUFSIZE) btrfs_item_key_to_cpu(leaf, key, i);
if (!key_in_sk(key, sk))
continue;
if (sizeof(sh) + item_len > BTRFS_SEARCH_ARGS_BUFSIZE)
item_len = 0; item_len = 0;
if (sizeof(sh) + item_len + *sk_offset > if (sizeof(sh) + item_len + *sk_offset >
...@@ -1810,10 +1814,6 @@ static noinline int copy_to_sk(struct btrfs_root *root, ...@@ -1810,10 +1814,6 @@ static noinline int copy_to_sk(struct btrfs_root *root,
goto overflow; goto overflow;
} }
btrfs_item_key_to_cpu(leaf, key, i);
if (!key_in_sk(key, sk))
continue;
sh.objectid = key->objectid; sh.objectid = key->objectid;
sh.offset = key->offset; sh.offset = key->offset;
sh.type = key->type; sh.type = key->type;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment