diff options
author | Gabriel de Perthuis <g2p.code@gmail.com> | 2013-05-06 17:40:18 +0000 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2013-06-05 10:30:25 -0400 |
commit | 2f7616ff35bec1a646a77ffb918bc022d299c0a9 (patch) | |
tree | c0aac372f1ed6fde95573a9f30c52beecf559de8 /fs/btrfs | |
parent | a844562532ebf5f4fe6cd4556e5fef326502ae36 (diff) | |
download | linux-rt-2f7616ff35bec1a646a77ffb918bc022d299c0a9.tar.gz |
btrfs: don't stop searching after encountering the wrong item
[ Upstream commit 03b71c6ca6286625d8f1ed44aabab9b5bf5dac10 ]
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: Gabriel de Perthuis <g2p.code+btrfs@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ioctl.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 9df50fa8a078..8613626a1a20 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1707,7 +1707,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 > @@ -1716,10 +1720,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; |