Skip to content

Commit 0084712

Browse files
Florian Westphalgregkh
authored andcommitted
neigh: let neigh_xmit take skb ownership
[ Upstream commit 4438113 ] neigh_xmit always releases the skb, except when no neighbour table is found. But even the first added user of neigh_xmit (mpls) relied on neigh_xmit to release the skb (or queue it for tx). sashiko reported: If neigh_xmit() is called with an uninitialized neighbor table (for example, NEIGH_ND_TABLE when IPv6 is disabled), it returns -EAFNOSUPPORT and bypasses its internal out_kfree_skb error path. Because the return value of neigh_xmit() is ignored here, does this leak the SKB? Assume full ownership and remove the last code path that doesn't xmit or free skb. Fixes: 4fd3d7d ("neigh: Add helper function neigh_xmit") Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260424145843.74055-1-fw@strlen.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d02e2fb commit 0084712

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

net/core/neighbour.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,8 +3161,10 @@ int neigh_xmit(int index, struct net_device *dev,
31613161

31623162
rcu_read_lock();
31633163
tbl = rcu_dereference(neigh_tables[index]);
3164-
if (!tbl)
3165-
goto out_unlock;
3164+
if (!tbl) {
3165+
rcu_read_unlock();
3166+
goto out_kfree_skb;
3167+
}
31663168
if (index == NEIGH_ARP_TABLE) {
31673169
u32 key = *((u32 *)addr);
31683170

@@ -3178,7 +3180,6 @@ int neigh_xmit(int index, struct net_device *dev,
31783180
goto out_kfree_skb;
31793181
}
31803182
err = READ_ONCE(neigh->output)(neigh, skb);
3181-
out_unlock:
31823183
rcu_read_unlock();
31833184
}
31843185
else if (index == NEIGH_LINK_TABLE) {
@@ -3188,11 +3189,10 @@ int neigh_xmit(int index, struct net_device *dev,
31883189
goto out_kfree_skb;
31893190
err = dev_queue_xmit(skb);
31903191
}
3191-
out:
31923192
return err;
31933193
out_kfree_skb:
31943194
kfree_skb(skb);
3195-
goto out;
3195+
return err;
31963196
}
31973197
EXPORT_SYMBOL(neigh_xmit);
31983198

0 commit comments

Comments
 (0)