android_kernel_motorola_sm6375/net/batman-adv
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pavel Skripkin 6422e84718 net: batman-adv: fix error handling
commit 6f68cd634856f8ca93bafd623ba5357e0f648c68 upstream.

Syzbot reported ODEBUG warning in batadv_nc_mesh_free(). The problem was
in wrong error handling in batadv_mesh_init().

Before this patch batadv_mesh_init() was calling batadv_mesh_free() in case
of any batadv_*_init() calls failure. This approach may work well, when
there is some kind of indicator, which can tell which parts of batadv are
initialized; but there isn't any.

All written above lead to cleaning up uninitialized fields. Even if we hide
ODEBUG warning by initializing bat_priv->nc.work, syzbot was able to hit
GPF in batadv_nc_purge_paths(), because hash pointer in still NULL. [1]

To fix these bugs we can unwind batadv_*_init() calls one by one.
It is good approach for 2 reasons: 1) It fixes bugs on error handling
path 2) It improves the performance, since we won't call unneeded
batadv_*_free() functions.

So, this patch makes all batadv_*_init() clean up all allocated memory
before returning with an error to no call correspoing batadv_*_free()
and open-codes batadv_mesh_free() with proper order to avoid touching
uninitialized fields.

Link: https://lore.kernel.org/netdev/[email protected]/ [1]
Reported-and-tested-by: [email protected]
Fixes: c6c8fea297 ("net: Add batman-adv meshing protocol")
Signed-off-by: Pavel Skripkin <[email protected]>
Acked-by: Sven Eckelmann <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
2021-11-02 19:46:14 +01:00
..
bat_algo.c
bat_algo.h
bat_iv_ogm.c batman-adv: Avoid WARN_ON timing related checks 2021-06-23 14:41:23 +02:00
bat_iv_ogm.h
bat_v.c
bat_v.h
bat_v_elp.c batman-adv: Revert "disable ethtool link speed detection when auto negotiation off" 2020-06-22 09:30:56 +02:00
bat_v_elp.h
bat_v_ogm.c batman-adv: Fix own OGM check in aggregated OGMs 2020-09-09 19:12:23 +02:00
bat_v_ogm.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c net: batman-adv: fix error handling 2021-11-02 19:46:14 +01:00
bridge_loop_avoidance.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-10-01 13:18:19 +02:00
debugfs.c
debugfs.h
distributed-arp-table.c
distributed-arp-table.h
fragmentation.c
fragmentation.h
gateway_client.c batman-adv: Avoid uninitialized chaddr when handling DHCP 2020-09-09 19:12:23 +02:00
gateway_client.h
gateway_common.c
gateway_common.h
hard-interface.c
hard-interface.h
hash.c
hash.h
icmp_socket.c
icmp_socket.h
Kconfig
log.c batman-adv: set .owner to THIS_MODULE 2020-12-02 08:49:50 +01:00
log.h
main.c net: batman-adv: fix error handling 2021-11-02 19:46:14 +01:00
main.h
Makefile
multicast.c batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2020-10-01 13:18:19 +02:00
multicast.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2020-10-01 13:18:19 +02:00
netlink.c
netlink.h
network-coding.c net: batman-adv: fix error handling 2021-11-02 19:46:14 +01:00
network-coding.h
originator.c
originator.h
routing.c batman-adv: mcast/TT: fix wrongly dropped or rerouted packets 2020-10-01 13:18:17 +02:00
routing.h
send.c
send.h
soft-interface.c batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-10-01 13:18:19 +02:00
soft-interface.h
sysfs.c batman-adv: Fix refcnt leak in batadv_store_throughput_override 2020-05-14 07:58:28 +02:00
sysfs.h
tp_meter.c
tp_meter.h
trace.c
trace.h
translation-table.c net: batman-adv: fix error handling 2021-11-02 19:46:14 +01:00
translation-table.h
tvlv.c
tvlv.h
types.h