neighbour: neigh_xmit needs to release skb on -EAFNOSUPPORT
Subsystems (3)
Pablo Neira Ayuso
maintainerPATCH 1/1 neighbour: neigh_xmit needs to release skb on -EAFNOSUPPORT
Sashiko reports:
"... if the target neighbor table is NULL (for example, for NEIGH_ND_TABLE when IPv6 is disabled), the code takes the out_unlock path and bypasses the out_kfree_skb cleanup"
Fix this skb memleak by releasing the skb in case of -EAFNOSUPPORT.
Fixes f8f2eb9de69a ("neighbour: add RCU protection to neigh_tables[]")
Signed-off-by Pablo Neira Ayuso <[email protected]>
--- net/core/neighbour.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/core/neighbour.c +4 -3
@@ -3210,8 +3210,10 @@ int neigh_xmit(int index, struct net_device *dev,rcu_read_lock (); tbl =rcu_dereference (neigh_tables[index]); -if (!tbl) - goto out_unlock; +if (!tbl) { +rcu_read_unlock (); + goto out_kfree_skb; + }if (index ==NEIGH_ARP_TABLE ) {u32 key = *((u32 *)addr);
@@ -3227,7 +3229,6 @@ int neigh_xmit(int index, struct net_device *dev, goto out_kfree_skb; } err =READ_ONCE (neigh->output)(neigh, skb); -out_unlock:rcu_read_unlock (); }else if (index ==NEIGH_LINK_TABLE ) {
Signature · 1 line
2.47.3
Pablo Neira Ayuso
maintainerQuoted 7 lines · Pablo Neira Ayuso
Sashiko reports:
"... if the target neighbor table is NULL (for example, for
NEIGH_ND_TABLEwhen IPv6 is disabled), the code takes theout_unlockpath and bypasses theout_kfree_skbcleanup"Fix this skb memleak by releasing the skb in case of
-EAFNOSUPPORT.
Please, withdraw.
Florian Westphal already posted a similar fix that is already in net.git
Thanks.
Quoted 2 lines
Fixes f8f2eb9de69a ("neighbour: add RCU protection to neigh_tables[]")Signed-off-by Pablo Neira Ayuso <[email protected]>