linux/tools/testing/radix-tree
Matthew Wilcox 7a4deea1aa idr: fix invalid ptr dereference on item delete
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: 0a835c4f09 ("Reimplement IDR and IDA using the radix tree")
Reported-by: <syzbot+35666cba7f0a337e2e79@syzkaller.appspotmail.com>
Debugged-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-05-25 18:12:10 -07:00
..
generated radix tree test suite: Remove obsolete CONFIG 2017-02-13 16:09:43 -05:00
linux radix tree: use GFP_ZONEMASK bits of gfp_t for flags 2018-04-11 10:28:39 -07:00
.gitignore radix tree test suite: Add config option for map shift 2017-02-13 21:44:10 -05:00
Makefile radix tree test suite: fix mapshift build target 2018-05-18 17:17:12 -07:00
benchmark.c radix tree test suite: Add performance test for radix_tree_join() 2017-03-07 13:18:21 -05:00
idr-test.c idr: fix invalid ptr dereference on item delete 2018-05-25 18:12:10 -07:00
iteration_check.c radix tree test suite: Dial down verbosity with -v 2017-02-13 21:44:04 -05:00
linux.c radix tree test suite: Fix build 2018-02-25 06:00:11 -05:00
main.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
multiorder.c radix tree test suite: multi-order iteration race 2018-05-18 17:17:12 -07:00
regression.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
regression1.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
regression2.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
regression3.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tag_check.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test.c radix tree test suite: add item_delete_rcu() 2018-05-18 17:17:12 -07:00
test.h radix tree test suite: multi-order iteration race 2018-05-18 17:17:12 -07:00