Skip to content

Commit 4372339

Browse files
zx2c4davem330
authored andcommitted
net: always use icmp{,v6}_ndo_send from ndo_start_xmit
There were a few remaining tunnel drivers that didn't receive the prior conversion to icmp{,v6}_ndo_send. Knowing now that this could lead to memory corrution (see ee576c4 ("net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending") for details), there's even more imperative to have these all converted. So this commit goes through the remaining cases that I could find and does a boring translation to the ndo variety. The Fixes: line below is the merge that originally added icmp{,v6}_ ndo_send and converted the first batch of icmp{,v6}_send users. The rationale then for the change applies equally to this patch. It's just that these drivers were left out of the initial conversion because these network devices are hiding in net/ rather than in drivers/net/. Cc: Florian Westphal <[email protected]> Cc: Willem de Bruijn <[email protected]> Cc: David S. Miller <[email protected]> Cc: Hideaki YOSHIFUJI <[email protected]> Cc: David Ahern <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Steffen Klassert <[email protected]> Fixes: 803381f ("Merge branch 'icmp-account-for-NAT-when-sending-icmps-from-ndo-layer'") Signed-off-by: Jason A. Donenfeld <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9eb8bc5 commit 4372339

File tree

6 files changed

+22
-23
lines changed

6 files changed

+22
-23
lines changed

net/ipv4/ip_tunnel.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
502502
if (!skb_is_gso(skb) &&
503503
(inner_iph->frag_off & htons(IP_DF)) &&
504504
mtu < pkt_size) {
505-
memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
506-
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
505+
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
507506
return -E2BIG;
508507
}
509508
}
@@ -527,7 +526,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
527526

528527
if (!skb_is_gso(skb) && mtu >= IPV6_MIN_MTU &&
529528
mtu < pkt_size) {
530-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
529+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
531530
return -E2BIG;
532531
}
533532
}

net/ipv4/ip_vti.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,13 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
238238
if (skb->len > mtu) {
239239
skb_dst_update_pmtu_no_confirm(skb, mtu);
240240
if (skb->protocol == htons(ETH_P_IP)) {
241-
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
242-
htonl(mtu));
241+
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
242+
htonl(mtu));
243243
} else {
244244
if (mtu < IPV6_MIN_MTU)
245245
mtu = IPV6_MIN_MTU;
246246

247-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
247+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
248248
}
249249

250250
dst_release(dst);

net/ipv6/ip6_gre.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
678678

679679
tel = (struct ipv6_tlv_tnl_enc_lim *)&skb_network_header(skb)[offset];
680680
if (tel->encap_limit == 0) {
681-
icmpv6_send(skb, ICMPV6_PARAMPROB,
682-
ICMPV6_HDR_FIELD, offset + 2);
681+
icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
682+
ICMPV6_HDR_FIELD, offset + 2);
683683
return -1;
684684
}
685685
*encap_limit = tel->encap_limit - 1;
@@ -805,8 +805,8 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
805805
if (err != 0) {
806806
/* XXX: send ICMP error even if DF is not set. */
807807
if (err == -EMSGSIZE)
808-
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
809-
htonl(mtu));
808+
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
809+
htonl(mtu));
810810
return -1;
811811
}
812812

@@ -837,7 +837,7 @@ static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
837837
&mtu, skb->protocol);
838838
if (err != 0) {
839839
if (err == -EMSGSIZE)
840-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
840+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
841841
return -1;
842842
}
843843

@@ -1063,10 +1063,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
10631063
/* XXX: send ICMP error even if DF is not set. */
10641064
if (err == -EMSGSIZE) {
10651065
if (skb->protocol == htons(ETH_P_IP))
1066-
icmp_send(skb, ICMP_DEST_UNREACH,
1067-
ICMP_FRAG_NEEDED, htonl(mtu));
1066+
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
1067+
ICMP_FRAG_NEEDED, htonl(mtu));
10681068
else
1069-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
1069+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
10701070
}
10711071

10721072
goto tx_err;

net/ipv6/ip6_tunnel.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,8 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
13321332

13331333
tel = (void *)&skb_network_header(skb)[offset];
13341334
if (tel->encap_limit == 0) {
1335-
icmpv6_send(skb, ICMPV6_PARAMPROB,
1336-
ICMPV6_HDR_FIELD, offset + 2);
1335+
icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
1336+
ICMPV6_HDR_FIELD, offset + 2);
13371337
return -1;
13381338
}
13391339
encap_limit = tel->encap_limit - 1;
@@ -1385,11 +1385,11 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
13851385
if (err == -EMSGSIZE)
13861386
switch (protocol) {
13871387
case IPPROTO_IPIP:
1388-
icmp_send(skb, ICMP_DEST_UNREACH,
1389-
ICMP_FRAG_NEEDED, htonl(mtu));
1388+
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
1389+
ICMP_FRAG_NEEDED, htonl(mtu));
13901390
break;
13911391
case IPPROTO_IPV6:
1392-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
1392+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
13931393
break;
13941394
default:
13951395
break;

net/ipv6/ip6_vti.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,10 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
521521
if (mtu < IPV6_MIN_MTU)
522522
mtu = IPV6_MIN_MTU;
523523

524-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
524+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
525525
} else {
526-
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
527-
htonl(mtu));
526+
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
527+
htonl(mtu));
528528
}
529529

530530
err = -EMSGSIZE;

net/ipv6/sit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
987987
skb_dst_update_pmtu_no_confirm(skb, mtu);
988988

989989
if (skb->len > mtu && !skb_is_gso(skb)) {
990-
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
990+
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
991991
ip_rt_put(rt);
992992
goto tx_error;
993993
}

0 commit comments

Comments
 (0)