1. 22 8月, 2018 1 次提交
  2. 26 5月, 2018 1 次提交
    • M
      idr: fix invalid ptr dereference on item delete · 7a4deea1
      Matthew Wilcox 提交于
      If the radix tree underlying the IDR happens to be full and we attempt
      to remove an id which is larger than any id in the IDR, we will call
      __radix_tree_delete() with an uninitialised 'slot' pointer, at which
      point anything could happen.  This was easiest to hit with a single
      entry at id 0 and attempting to remove a non-0 id, but it could have
      happened with 64 entries and attempting to remove an id >= 64.
      
      Roman said:
      
        The syzcaller test boils down to opening /dev/kvm, creating an
        eventfd, and calling a couple of KVM ioctls. None of this requires
        superuser. And the result is dereferencing an uninitialized pointer
        which is likely a crash. The specific path caught by syzbot is via
        KVM_HYPERV_EVENTD ioctl which is new in 4.17. But I guess there are
        other user-triggerable paths, so cc:stable is probably justified.
      
      Matthew added:
      
        We have around 250 calls to idr_remove() in the kernel today. Many of
        them pass an ID which is embedded in the object they're removing, so
        they're safe. Picking a few likely candidates:
      
        drivers/firewire/core-cdev.c looks unsafe; the ID comes from an ioctl.
        drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c is similar
        drivers/atm/nicstar.c could be taken down by a handcrafted packet
      
      Link: http://lkml.kernel.org/r/20180518175025.GD6361@bombadil.infradead.org
      Fixes: 0a835c4f ("Reimplement IDR and IDA using the radix tree")
      Reported-by: <syzbot+35666cba7f0a337e2e79@syzkaller.appspotmail.com>
      Debugged-by: NRoman Kagan <rkagan@virtuozzo.com>
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7a4deea1
  3. 27 2月, 2018 1 次提交
    • M
      idr: Fix handling of IDs above INT_MAX · 4b0ad076
      Matthew Wilcox 提交于
      Khalid reported that the kernel selftests are currently failing:
      
      selftests: test_bpf.sh
      ========================================
      test_bpf: [FAIL]
      not ok 1..8 selftests:  test_bpf.sh [FAIL]
      
      He bisected it to 6ce711f2 ("idr: Make
      1-based IDRs more efficient").
      
      The root cause is doing a signed comparison in idr_alloc_u32() instead
      of an unsigned comparison.  I went looking for any similar problems and
      found a couple (which would each result in the failure to warn in two
      situations that aren't supposed to happen).
      
      I knocked up a few test-cases to prove that I was right and added them
      to the test-suite.
      Reported-by: NKhalid Aziz <khalid.aziz@oracle.com>
      Tested-by: NKhalid Aziz <khalid.aziz@oracle.com>
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      4b0ad076
  4. 07 2月, 2018 4 次提交
    • M
      idr: Make 1-based IDRs more efficient · 6ce711f2
      Matthew Wilcox 提交于
      About 20% of the IDR users in the kernel want the allocated IDs to start
      at 1.  The implementation currently searches all the way down the left
      hand side of the tree, finds no free ID other than ID 0, walks all the
      way back up, and then all the way down again.  This patch 'rebases' the
      ID so we fill the entire radix tree, rather than leave a gap at 0.
      
      Chris Wilson says: "I did the quick hack of allocating index 0 of the
      idr and that eradicated idr_get_free() from being at the top of the
      profiles for the many-object stress tests. This improvement will be
      much appreciated."
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      6ce711f2
    • M
      idr: Remove idr_alloc_ext · 460488c5
      Matthew Wilcox 提交于
      It has no more users, so remove it.  Move idr_alloc() back into idr.c,
      move the guts of idr_alloc_cmn() into idr_alloc_u32(), remove the
      wrappers around idr_get_free_cmn() and rename it to idr_get_free().
      While there is now no interface to allocate IDs larger than a u32,
      the IDR internals remain ready to handle a larger ID should a need arise.
      
      These changes make it possible to provide the guarantee that, if the
      nextid pointer points into the object, the object's ID will be initialised
      before a concurrent lookup can find the object.
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      460488c5
    • M
      IDR test suite: Check handling negative end correctly · 6e6d3014
      Matthew Wilcox 提交于
      One of the charming quirks of the idr_alloc() interface is that you
      can pass a negative end and it will be interpreted as "maximum".  Ensure
      we don't break that.
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      6e6d3014
    • M
      idr test suite: Fix ida_test_random() · 490645d0
      Matthew Wilcox 提交于
      The test was checking the wrong errno; ida_get_new_above() returns
      EAGAIN, not ENOMEM on memory allocation failure.  Double the number of
      threads to increase the chance that we actually exercise this path
      during the test suite (it was a bit sporadic before).
      Signed-off-by: NMatthew Wilcox <mawilcox@microsoft.com>
      490645d0
  5. 08 3月, 2017 3 次提交
  6. 14 2月, 2017 3 次提交