1. 22 1月, 2018 1 次提交
    • N
      btrfs: Fix out of bounds access in btrfs_search_slot · 9ea2c7c9
      Nikolay Borisov 提交于
      When modifying a tree where the root is at BTRFS_MAX_LEVEL - 1 then
      the level variable is going to be 7 (this is the max height of the
      tree). On the other hand btrfs_cow_block is always called with
      "level + 1" as an index into the nodes and slots arrays. This leads to
      an out of bounds access. Admittdely this will be benign since an OOB
      access of the nodes array will likely read the 0th element from the
      slots array, which in this case is going to be 0 (since we start CoW at
      the top of the tree). The OOB access into the slots array in turn will
      read the 0th and 1st values of the locks array, which would both be 0
      at the time. However, this benign behavior relies on the fact that the
      path being passed hasn't been initialised, if it has already been used to
      query a btree then it could potentially have populated the nodes/slots arrays.
      
      Fix it by explicitly checking if we are at level 7 (the maximum allowed
      index in nodes/slots arrays) and explicitly call the CoW routine with
      NULL for parent's node/slot.
      Signed-off-by: NNikolay Borisov <nborisov@suse.com>
      Fixes-coverity-id: 711515
      Reviewed-by: NDavid Sterba <dsterba@suse.com>
      Signed-off-by: NDavid Sterba <dsterba@suse.com>
      9ea2c7c9
  2. 07 12月, 2017 1 次提交
  3. 30 10月, 2017 2 次提交
  4. 16 8月, 2017 1 次提交
  5. 20 6月, 2017 2 次提交
  6. 09 5月, 2017 1 次提交
    • M
      treewide: use kv[mz]alloc* rather than opencoded variants · 752ade68
      Michal Hocko 提交于
      There are many code paths opencoding kvmalloc.  Let's use the helper
      instead.  The main difference to kvmalloc is that those users are
      usually not considering all the aspects of the memory allocator.  E.g.
      allocation requests <= 32kB (with 4kB pages) are basically never failing
      and invoke OOM killer to satisfy the allocation.  This sounds too
      disruptive for something that has a reasonable fallback - the vmalloc.
      On the other hand those requests might fallback to vmalloc even when the
      memory allocator would succeed after several more reclaim/compaction
      attempts previously.  There is no guarantee something like that happens
      though.
      
      This patch converts many of those places to kv[mz]alloc* helpers because
      they are more conservative.
      
      Link: http://lkml.kernel.org/r/20170306103327.2766-2-mhocko@kernel.orgSigned-off-by: NMichal Hocko <mhocko@suse.com>
      Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> # Xen bits
      Acked-by: NKees Cook <keescook@chromium.org>
      Acked-by: NVlastimil Babka <vbabka@suse.cz>
      Acked-by: Andreas Dilger <andreas.dilger@intel.com> # Lustre
      Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> # KVM/s390
      Acked-by: Dan Williams <dan.j.williams@intel.com> # nvdim
      Acked-by: David Sterba <dsterba@suse.com> # btrfs
      Acked-by: Ilya Dryomov <idryomov@gmail.com> # Ceph
      Acked-by: Tariq Toukan <tariqt@mellanox.com> # mlx4
      Acked-by: Leon Romanovsky <leonro@mellanox.com> # mlx5
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Kent Overstreet <kent.overstreet@gmail.com>
      Cc: Santosh Raspatur <santosh@chelsio.com>
      Cc: Hariprasad S <hariprasad@chelsio.com>
      Cc: Yishai Hadas <yishaih@mellanox.com>
      Cc: Oleg Drokin <oleg.drokin@intel.com>
      Cc: "Yan, Zheng" <zyan@redhat.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: David Miller <davem@davemloft.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      752ade68
  7. 18 4月, 2017 2 次提交
  8. 28 2月, 2017 1 次提交
  9. 24 2月, 2017 1 次提交
    • F
      Btrfs: try harder to migrate items to left sibling before splitting a leaf · 263d3995
      Filipe Manana 提交于
      Before attempting to split a leaf we try to migrate items from the leaf to
      its right and left siblings. We start by trying to move items into the
      rigth sibling and, if the new item is meant to be inserted at the end of
      our leaf, we try to free from our leaf an amount of bytes equal to the
      number of bytes used by the new item, by setting the variable space_needed
      to the byte size of that new item. However if we fail to move enough items
      to the right sibling due to lack of space in that sibling, we then try
      to move items into the left sibling, and in that case we try to free
      an amount equal to the size of the new item from our leaf, when we need
      only to free an amount corresponding to the size of the new item minus
      the current free space of our leaf. So make sure that before we try to
      move items to the left sibling we do set the variable space_needed with
      a value corresponding to the new item's size minus the leaf's current
      free space.
      Signed-off-by: NFilipe Manana <fdmanana@suse.com>
      Reviewed-by: NLiu Bo <bo.li.liu@oracle.com>
      263d3995
  10. 17 2月, 2017 7 次提交
  11. 14 2月, 2017 3 次提交
  12. 06 12月, 2016 3 次提交
  13. 30 11月, 2016 4 次提交
  14. 27 9月, 2016 6 次提交
  15. 26 9月, 2016 1 次提交
  16. 26 7月, 2016 4 次提交