alistair23-linux/net/batman-adv
Sven Eckelmann 4ba104f468 batman-adv: Reduce claim hash refcnt only for removed entry
The batadv_hash_remove is a function which searches the hashtable for an
entry using a needle, a hashtable bucket selection function and a compare
function. It will lock the bucket list and delete an entry when the compare
function matches it with the needle. It returns the pointer to the
hlist_node which matches or NULL when no entry matches the needle.

The batadv_bla_del_claim is not itself protected in anyway to avoid that
any other function is modifying the hashtable between the search for the
entry and the call to batadv_hash_remove. It can therefore happen that the
entry either doesn't exist anymore or an entry was deleted which is not the
same object as the needle. In such an situation, the reference counter (for
the reference stored in the hashtable) must not be reduced for the needle.
Instead the reference counter of the actually removed entry has to be
reduced.

Otherwise the reference counter will underflow and the object might be
freed before all its references were dropped. The kref helpers reported
this problem as:

  refcount_t: underflow; use-after-free.

Fixes: 23721387c4 ("batman-adv: add basic bridge loop avoidance code")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
2019-03-25 09:31:19 +01:00
..
bat_algo.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_algo.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_iv_ogm.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_iv_ogm.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_v.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_v.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_v_elp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
bat_v_elp.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_v_ogm.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bat_v_ogm.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bitarray.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bitarray.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
bridge_loop_avoidance.c batman-adv: Reduce claim hash refcnt only for removed entry 2019-03-25 09:31:19 +01:00
bridge_loop_avoidance.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
debugfs.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
debugfs.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
distributed-arp-table.c batman-adv: fix memory leak in in batadv_dat_put_dhcp 2019-02-06 19:42:52 +01:00
distributed-arp-table.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
fragmentation.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
fragmentation.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
gateway_client.c batman-adv: Add gateway mesh genl configuration 2019-02-09 14:28:14 +01:00
gateway_client.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
gateway_common.c batman-adv: Add gateway mesh genl configuration 2019-02-09 14:28:14 +01:00
gateway_common.h batman-adv: Add gateway mesh genl configuration 2019-02-09 14:28:14 +01:00
hard-interface.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-08 15:00:17 -08:00
hard-interface.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
hash.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
hash.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
icmp_socket.c This feature/cleanup patchset includes the following patches: 2019-02-01 11:04:13 -08:00
icmp_socket.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
Kconfig batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
log.c This feature/cleanup patchset includes the following patches: 2019-02-01 11:04:13 -08:00
log.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
main.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
main.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
Makefile batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
multicast.c This feature/cleanup patchset includes the following patches: 2019-02-01 11:04:13 -08:00
multicast.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
netlink.c batman-adv: Trigger genl notification on sysfs config change 2019-02-09 14:28:15 +01:00
netlink.h batman-adv: Trigger genl notification on sysfs config change 2019-02-09 14:28:15 +01:00
network-coding.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
network-coding.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
originator.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
originator.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
routing.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
routing.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
send.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
send.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
soft-interface.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-02-15 12:38:38 -08:00
soft-interface.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
sysfs.c batman-adv: Trigger genl notification on sysfs config change 2019-02-09 14:28:15 +01:00
sysfs.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
tp_meter.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
tp_meter.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
trace.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
trace.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
translation-table.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
translation-table.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
tvlv.c batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
tvlv.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00
types.h batman-adv: Update copyright years for 2019 2019-01-04 11:04:24 +01:00