]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
lib/rhashtable: fix race between rhashtable_lookup_compare and hashtable resize
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fri, 26 Jun 2015 10:48:17 +0000 (13:48 +0300)
committerSasha Levin <sasha.levin@oracle.com>
Wed, 1 Jul 2015 19:33:16 +0000 (15:33 -0400)
commitfcd7e9af33132c0ca397bba35b8ca58d54548127
tree51b6ea215af16c0eba7b214c8450dbd331dca5ed
parentb038a2030b947dbe3cd1e16e116a8fc2b7c54d3d
lib/rhashtable: fix race between rhashtable_lookup_compare and hashtable resize

Hash value passed as argument into rhashtable_lookup_compare could be
computed using different hash table than rhashtable_lookup_compare sees.

This patch passes key into rhashtable_lookup_compare() instead of hash and
compures hash value right in place using the same table as for lookup.

Also it adds comment for rhashtable_hashfn and rhashtable_obj_hashfn:
user must prevent concurrent insert/remove otherwise returned hash value
could be invalid.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: e341694e3eb5 ("netlink: Convert netlink_lookup() to use RCU protected hash table")
Link: http://lkml.kernel.org/r/20150514042151.GA5482@gondor.apana.org.au
Cc: Stable <stable@vger.kernel.org> (v3.17 .. v3.19)
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
include/linux/rhashtable.h
lib/rhashtable.c
net/netlink/af_netlink.c