btrfs: don't stop searching after encountering the wrong item
PATCH 1/1 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.
--- fs/btrfs/ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/ioctl.c +5 -5
@@ -1797,23 +1797,23 @@ static noinline int copy_to_sk(struct btrfs_root *root,for (i = slot; i < nritems; i++) { 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 >BTRFS_SEARCH_ARGS_BUFSIZE ) { ret =1 ; 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; sh.len = item_len; sh.transid = found_transid;
Signature · 1 line
1.8.2.1.419.ga0b97c6
Quoted 10 lines · Gabriel de Perthuis
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.
Signed-off-by Gabriel de Perthuis <[email protected]>--- fs/btrfs/ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read Documentation/stable_kernel_rules.txt for how to do this properly.
</formletter>
PATCH 1/1 btrfs: don't stop searching after encountering the wrong item
In reply to Gabriel de PerthuisThe 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.
---
(resent, with the correct header to have stable copied)
fs/btrfs/ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/ioctl.c +5 -5
@@ -1794,23 +1794,23 @@ static noinline int copy_to_sk(struct btrfs_root *root,for (i = slot; i < nritems; i++) { 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 >BTRFS_SEARCH_ARGS_BUFSIZE ) { ret =1 ; 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; sh.len = item_len; sh.transid = found_transid;
Signature · 1 line
1.8.2.1.419.ga0b97c6