From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 381CD263F44; Sat, 30 May 2026 17:24:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161890; cv=none; b=BSp9V9SDsI/WUeU5akon7CKMZ9f6icBSchWaiCL+Gx0zo5aNh5rA73EPZUWNrp70B/B710T3iwVAUhjZ6pu+SqFWfKNuDvWtZnoGq8mIR6eFrgH6SufpHGNGJ9B2aGIeIhAODQ5RSxM22bIKho3L3qKaMLpAEjNcincHqPZKsvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780161890; c=relaxed/simple; bh=vPD+l/E8jwlVp0Owl5DHybdXQjnyIVLhqTDB7wtN02Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jlNBIaXaTnoWcBINo56SZyrHskc/NpZIDDyDaUsTAcbfkxh3qm9Y/bgXObgm5wclnCuw+xb9PMawzz9SwQdXgEhr4yCFj5/yMk3TqA18HtUuI9waCbZqf24FigmEYrW3LOuyWtVyNzKGsAqCrIIk34sUyEZKsYTANfIAOgsT29w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=DEokkD9J; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="DEokkD9J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C1C71F00893; Sat, 30 May 2026 17:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780161889; bh=9TEUybr3KeqXTgOR0t6pskcEPNcvouVCxO6aE5PkqzI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DEokkD9JIm3WNSMPkPNy0VNEfsKwDZxZQpQ/0iB2Z3gXz7NH7JHM2SeVeDHn/8W76 Orepj/WBQnpwcTXyM5atHJ0yWlpHDIb7KJVwsmj0+1actTllMu5a5+JB6/9MnCl45t HIUi/GnBsLqYO4iyee4FMHh9zoHKJl4oQ5pAdeiE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Westphal , Kuniyuki Iwashima , Ido Schimmel , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 757/969] neigh: let neigh_xmit take skb ownership Date: Sat, 30 May 2026 18:04:41 +0200 Message-ID: <20260530160321.469211142@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 4438113be604ee67a7bf4f81da6e1cca41332ce4 ] 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: 4fd3d7d9e868 ("neigh: Add helper function neigh_xmit") Signed-off-by: Florian Westphal Reviewed-by: Kuniyuki Iwashima Reviewed-by: Ido Schimmel Link: https://patch.msgid.link/20260424145843.74055-1-fw@strlen.de Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/core/neighbour.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index fe0e839972ba7..7bdb2b5a6e014 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -3154,8 +3154,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); @@ -3171,7 +3173,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) { @@ -3181,11 +3182,10 @@ int neigh_xmit(int index, struct net_device *dev, goto out_kfree_skb; err = dev_queue_xmit(skb); } -out: return err; out_kfree_skb: kfree_skb(skb); - goto out; + return err; } EXPORT_SYMBOL(neigh_xmit); -- 2.53.0