Skip to content

Commit 239d886

Browse files
TaeheeYooPaolo Abeni
authored andcommitted
amt: drop unexpected query message
AMT gateway interface should not receive unexpected query messages. In order to drop unexpected query messages, it checks nonce. And it also checks ready4 and ready6 variables to drop duplicated messages. Fixes: cbc21dc ("amt: add data plane of amt interface") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 40185f3 commit 239d886

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/net/amt.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,11 @@ static void amt_event_send_request(struct amt_dev *amt)
967967
goto out;
968968
}
969969

970-
if (!amt->req_cnt)
970+
if (!amt->req_cnt) {
971+
WRITE_ONCE(amt->ready4, false);
972+
WRITE_ONCE(amt->ready6, false);
971973
get_random_bytes(&amt->nonce, sizeof(__be32));
974+
}
972975

973976
amt_send_request(amt, false);
974977
amt_send_request(amt, true);
@@ -2353,6 +2356,9 @@ static bool amt_membership_query_handler(struct amt_dev *amt,
23532356
if (amtmq->reserved || amtmq->version)
23542357
return true;
23552358

2359+
if (amtmq->nonce != amt->nonce)
2360+
return true;
2361+
23562362
hdr_size -= sizeof(*eth);
23572363
if (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false))
23582364
return true;
@@ -2367,6 +2373,9 @@ static bool amt_membership_query_handler(struct amt_dev *amt,
23672373

23682374
iph = ip_hdr(skb);
23692375
if (iph->version == 4) {
2376+
if (READ_ONCE(amt->ready4))
2377+
return true;
2378+
23702379
if (!pskb_may_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS +
23712380
sizeof(*ihv3)))
23722381
return true;
@@ -2389,6 +2398,9 @@ static bool amt_membership_query_handler(struct amt_dev *amt,
23892398
struct mld2_query *mld2q;
23902399
struct ipv6hdr *ip6h;
23912400

2401+
if (READ_ONCE(amt->ready6))
2402+
return true;
2403+
23922404
if (!pskb_may_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS +
23932405
sizeof(*mld2q)))
23942406
return true;

0 commit comments

Comments
 (0)