Skip to content

Commit

Permalink
btrfs: don't stop searching after encountering the wrong item
Browse files Browse the repository at this point in the history
commit 03b71c6 upstream.

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

Signed-off-by: Gabriel de Perthuis <g2p.code+btrfs@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Gabriel de Perthuis authored and Greg Kroah-Hartman committed May 24, 2013
1 parent ae101a3 commit 3f98318
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,11 @@ static noinline int copy_to_sk(struct btrfs_root *root,
item_off = btrfs_item_ptr_offset(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;

if (sizeof(sh) + item_len + *sk_offset >
Expand All @@ -1548,10 +1552,6 @@ static noinline int copy_to_sk(struct btrfs_root *root,
goto overflow;
}

btrfs_item_key_to_cpu(leaf, key, i);
if (!key_in_sk(key, sk))
continue;

sh.objectid = key->objectid;
sh.offset = key->offset;
sh.type = key->type;
Expand Down

0 comments on commit 3f98318

Please sign in to comment.