diff options
author | Gabriel de Perthuis <g2p.code@gmail.com> | 2013-05-06 13:40:18 -0400 |
---|---|---|
committer | Josef Bacik <jbacik@fusionio.com> | 2013-05-17 21:40:10 -0400 |
commit | 03b71c6ca6286625d8f1ed44aabab9b5bf5dac10 (patch) | |
tree | 5b5b9c8b566c2e4853f8c43dc46e9a9313c6c442 | |
parent | a52f4cd2b1a863a42c1cb268b1cddad451cdfede (diff) |
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: Gabriel de Perthuis <g2p.code+btrfs@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
-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 0de4a2fcfb24..0f81d67cdc8d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -1801,7 +1801,11 @@ static noinline int copy_to_sk(struct btrfs_root *root, | |||
1801 | item_off = btrfs_item_ptr_offset(leaf, i); | 1801 | item_off = btrfs_item_ptr_offset(leaf, i); |
1802 | item_len = btrfs_item_size_nr(leaf, i); | 1802 | item_len = btrfs_item_size_nr(leaf, i); |
1803 | 1803 | ||
1804 | if (item_len > BTRFS_SEARCH_ARGS_BUFSIZE) | 1804 | btrfs_item_key_to_cpu(leaf, key, i); |
1805 | if (!key_in_sk(key, sk)) | ||
1806 | continue; | ||
1807 | |||
1808 | if (sizeof(sh) + item_len > BTRFS_SEARCH_ARGS_BUFSIZE) | ||
1805 | item_len = 0; | 1809 | item_len = 0; |
1806 | 1810 | ||
1807 | if (sizeof(sh) + item_len + *sk_offset > | 1811 | if (sizeof(sh) + item_len + *sk_offset > |
@@ -1810,10 +1814,6 @@ static noinline int copy_to_sk(struct btrfs_root *root, | |||
1810 | goto overflow; | 1814 | goto overflow; |
1811 | } | 1815 | } |
1812 | 1816 | ||
1813 | btrfs_item_key_to_cpu(leaf, key, i); | ||
1814 | if (!key_in_sk(key, sk)) | ||
1815 | continue; | ||
1816 | |||
1817 | sh.objectid = key->objectid; | 1817 | sh.objectid = key->objectid; |
1818 | sh.offset = key->offset; | 1818 | sh.offset = key->offset; |
1819 | sh.type = key->type; | 1819 | sh.type = key->type; |