Skip to content

Commit afa9a05

Browse files
Yang Yangkuba-moo
authored andcommitted
vxlan: validate ND option lengths in vxlan_na_create
vxlan_na_create() 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: 4b29dba ("vxlan: fix nonfunctional neigh_reduce()") 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-4-n05ec@lzu.edu.cn Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 8508379 commit afa9a05

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/net/vxlan/vxlan_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,12 +1965,14 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
19651965
ns_olen = request->len - skb_network_offset(request) -
19661966
sizeof(struct ipv6hdr) - sizeof(*ns);
19671967
for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) {
1968-
if (!ns->opt[i + 1]) {
1968+
if (!ns->opt[i + 1] || i + (ns->opt[i + 1] << 3) > ns_olen) {
19691969
kfree_skb(reply);
19701970
return NULL;
19711971
}
19721972
if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) {
1973-
daddr = ns->opt + i + sizeof(struct nd_opt_hdr);
1973+
if ((ns->opt[i + 1] << 3) >=
1974+
sizeof(struct nd_opt_hdr) + ETH_ALEN)
1975+
daddr = ns->opt + i + sizeof(struct nd_opt_hdr);
19741976
break;
19751977
}
19761978
}

0 commit comments

Comments
 (0)