android_kernel_motorola_sm6225/net/batman-adv
Sven Eckelmann 6957021da7 batman-adv: Reduce tt_local hash refcnt only for removed entry
[ Upstream commit 3d65b9accab4a7ed5038f6df403fbd5e298398c7 ]

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_tt_local_remove 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: ef72706a05 ("batman-adv: protect tt_local_entry from concurrent delete events")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-05-08 07:21:46 +02:00
..
bat_algo.c
bat_algo.h
bat_iv_ogm.c
bat_iv_ogm.h
bat_v.c
bat_v.h
bat_v_elp.c batman-adv: release station info tidstats 2019-03-13 14:02:34 -07:00
bat_v_elp.h
bat_v_ogm.c
bat_v_ogm.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c batman-adv: Reduce claim hash refcnt only for removed entry 2019-05-08 07:21:46 +02:00
bridge_loop_avoidance.h
debugfs.c
debugfs.h
distributed-arp-table.c
distributed-arp-table.h
fragmentation.c batman-adv: Expand merged fragment buffer for full packet 2018-12-13 09:16:10 +01:00
fragmentation.h
gateway_client.c batman-adv: Prevent duplicated gateway_node entry 2018-09-06 13:55:20 +02:00
gateway_client.h
gateway_common.c
gateway_common.h
hard-interface.c batman-adv: Avoid WARN on net_device without parent in netns 2019-02-15 08:10:13 +01:00
hard-interface.h
hash.c
hash.h
icmp_socket.c
icmp_socket.h
Kconfig
log.c
log.h
main.c
main.h batman-adv: Increase version number to 2018.3 2018-09-14 17:59:20 +02:00
Makefile
multicast.c
multicast.h
netlink.c
netlink.h
network-coding.c batman-adv: Prevent duplicated nc_node entry 2018-09-06 13:55:58 +02:00
network-coding.h
originator.c
originator.h
routing.c
routing.h
send.c
send.h
soft-interface.c batman-adv: fix uninit-value in batadv_interface_tx() 2019-02-27 10:08:58 +01:00
soft-interface.h
sysfs.c batman-adv: Fix segfault when writing to sysfs elp_interval 2018-09-06 13:54:48 +02:00
sysfs.h
tp_meter.c
tp_meter.h
translation-table.c batman-adv: Reduce tt_local hash refcnt only for removed entry 2019-05-08 07:21:46 +02:00
translation-table.h
tvlv.c batman-adv: Prevent duplicated tvlv handler 2018-09-06 14:37:13 +02:00
tvlv.h
types.h