public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Yang Yang <n05ec@lzu.edu.cn>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, razor@blackwall.org, idosch@nvidia.com
Cc: andrew+netdev@lunn.ch, horms@kernel.org,
	florian.fainelli@broadcom.com, roopa@cumulusnetworks.com,
	dlstevens@us.ibm.com, nb@tipi-net.de, netdev@vger.kernel.org,
	bridge@lists.linux.dev, linux-kernel@vger.kernel.org,
	yifanwucs@gmail.com, tomapufckgml@gmail.com,
	tanyuan98@outlook.com, bird@lzu.edu.cn, n05ec@lzu.edu.cn
Subject: [PATCH net 1/3] bridge: br_nd_send: linearize skb before parsing ND options
Date: Thu, 26 Mar 2026 03:44:39 +0000	[thread overview]
Message-ID: <20260326034441.2037420-2-n05ec@lzu.edu.cn> (raw)
In-Reply-To: <20260326034441.2037420-1-n05ec@lzu.edu.cn>

br_nd_send() parses neighbour discovery options from ns->opt[] and
assumes that these options are in the linear part of request.

Its callers only guarantee that the ICMPv6 header and target address
are available, so the option area can still be non-linear. Parsing
ns->opt[] in that case can access data past the linear buffer.

Linearize request before option parsing and derive ns from the linear
network header.

Fixes: ed842faeb2bd ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports")
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Tested-by: Ao Zhou <n05ec@lzu.edu.cn>
Co-developed-by: Yuan Tan <tanyuan98@outlook.com>
Signed-off-by: Yuan Tan <tanyuan98@outlook.com>
Suggested-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Yang Yang <n05ec@lzu.edu.cn>
---
 net/bridge/br_arp_nd_proxy.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c
index 1e2b51769eec8..af3d1e33f50b8 100644
--- a/net/bridge/br_arp_nd_proxy.c
+++ b/net/bridge/br_arp_nd_proxy.c
@@ -251,12 +251,12 @@ struct nd_msg *br_is_nd_neigh_msg(const struct sk_buff *skb, struct nd_msg *msg)
 
 static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
 		       struct sk_buff *request, struct neighbour *n,
-		       __be16 vlan_proto, u16 vlan_tci, struct nd_msg *ns)
+		       __be16 vlan_proto, u16 vlan_tci)
 {
 	struct net_device *dev = request->dev;
 	struct net_bridge_vlan_group *vg;
+	struct nd_msg *na, *ns;
 	struct sk_buff *reply;
-	struct nd_msg *na;
 	struct ipv6hdr *pip6;
 	int na_olen = 8; /* opt hdr + ETH_ALEN for target */
 	int ns_olen;
@@ -264,7 +264,7 @@ static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
 	u8 *daddr;
 	u16 pvid;
 
-	if (!dev)
+	if (!dev || skb_linearize(request))
 		return;
 
 	len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr) +
@@ -281,6 +281,8 @@ static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
 	skb_set_mac_header(reply, 0);
 
 	daddr = eth_hdr(request)->h_source;
+	ns = (struct nd_msg *)(skb_network_header(request) +
+			       sizeof(struct ipv6hdr));
 
 	/* Do we need option processing ? */
 	ns_olen = request->len - (skb_network_offset(request) +
@@ -472,9 +474,9 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
 				if (vid != 0)
 					br_nd_send(br, p, skb, n,
 						   skb->vlan_proto,
-						   skb_vlan_tag_get(skb), msg);
+						   skb_vlan_tag_get(skb));
 				else
-					br_nd_send(br, p, skb, n, 0, 0, msg);
+					br_nd_send(br, p, skb, n, 0, 0);
 				replied = true;
 			}
 
-- 
2.43.0


  reply	other threads:[~2026-03-26  3:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26  3:44 [PATCH net 0/3] bridge/vxlan: harden ND option parsing paths Yang Yang
2026-03-26  3:44 ` Yang Yang [this message]
2026-03-26 16:29   ` [PATCH net 1/3] bridge: br_nd_send: linearize skb before parsing ND options Ido Schimmel
2026-03-26  3:44 ` [PATCH net 2/3] bridge: br_nd_send: validate ND option lengths Yang Yang
2026-03-26 16:30   ` Ido Schimmel
2026-03-26  3:44 ` [PATCH net 3/3] vxlan: validate ND option lengths in vxlan_na_create Yang Yang
2026-03-26 16:30   ` Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260326034441.2037420-2-n05ec@lzu.edu.cn \
    --to=n05ec@lzu.edu.cn \
    --cc=andrew+netdev@lunn.ch \
    --cc=bird@lzu.edu.cn \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=dlstevens@us.ibm.com \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nb@tipi-net.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=roopa@cumulusnetworks.com \
    --cc=tanyuan98@outlook.com \
    --cc=tomapufckgml@gmail.com \
    --cc=yifanwucs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox