Skip to content

Commit 8508379

Browse files
Yang Yangkuba-moo
authored andcommitted
bridge: br_nd_send: validate ND option lengths
br_nd_send() walks ND options according to option-provided lengths. A malformed option can make the parser advance beyond the computed option span or use a too-short source LLADDR option payload. Validate option lengths against the remaining NS option area before advancing, and only read source LLADDR when the option is large enough for an Ethernet address. Fixes: ed842fa ("bridge: suppress nd pkts on BR_NEIGH_SUPPRESS ports") Cc: stable@vger.kernel.org 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> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Acked-by: Nikolay Aleksandrov <razor@blackwall.org> Link: https://patch.msgid.link/20260326034441.2037420-3-n05ec@lzu.edu.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a01aee7 commit 8508379

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/bridge/br_arp_nd_proxy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,14 @@ static void br_nd_send(struct net_bridge *br, struct net_bridge_port *p,
288288
ns_olen = request->len - (skb_network_offset(request) +
289289
sizeof(struct ipv6hdr)) - sizeof(*ns);
290290
for (i = 0; i < ns_olen - 1; i += (ns->opt[i + 1] << 3)) {
291-
if (!ns->opt[i + 1]) {
291+
if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) {
292292
kfree_skb(reply);
293293
return;
294294
}
295295
if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) {
296-
daddr = ns->opt + i + sizeof(struct nd_opt_hdr);
296+
if ((ns->opt[i + 1] << 3) >=
297+
sizeof(struct nd_opt_hdr) + ETH_ALEN)
298+
daddr = ns->opt + i + sizeof(struct nd_opt_hdr);
297299
break;
298300
}
299301
}

0 commit comments

Comments
 (0)