]> git.baikalelectronics.ru Git - kernel.git/commit
assoc_array: Fix a buggy node-splitting case
authorDavid Howells <dhowells@redhat.com>
Wed, 11 Oct 2017 22:32:27 +0000 (23:32 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 28 Oct 2017 17:31:07 +0000 (10:31 -0700)
commite9061553edb0f7d0d3ab0814170c6e7602e2c7b8
tree9f408e0680bd02140aaf7eb51447c366151d866b
parent96eed04fa8bdcc263709678b3f2a5006988f63c8
assoc_array: Fix a buggy node-splitting case

This fixes CVE-2017-12193.

Fix a case in the assoc_array implementation in which a new leaf is
added that needs to go into a node that happens to be full, where the
existing leaves in that node cluster together at that level to the
exclusion of new leaf.

What needs to happen is that the existing leaves get moved out to a new
node, N1, at level + 1 and the existing node needs replacing with one,
N0, that has pointers to the new leaf and to N1.

The code that tries to do this gets this wrong in two ways:

 (1) The pointer that should've pointed from N0 to N1 is set to point
     recursively to N0 instead.

 (2) The backpointer from N0 needs to be set correctly in the case N0 is
     either the root node or reached through a shortcut.

Fix this by removing this path and using the split_node path instead,
which achieves the same end, but in a more general way (thanks to Eric
Biggers for spotting the redundancy).

The problem manifests itself as:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
  IP: assoc_array_apply_edit+0x59/0xe5

Fixes: 152f2c7640a1 ("Add a generic associative array implementation.")
Reported-and-tested-by: WU Fan <u3536072@connect.hku.hk>
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: stable@vger.kernel.org [v3.13-rc1+]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/assoc_array.c