aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2018-06-19 12:47:52 -0400
committerDavid S. Miller <davem@davemloft.net>2018-06-20 01:41:04 -0400
commit9887cba19978a5f288100ef90a37684cc8d5e0a6 (patch)
tree83db207b79f71d6473321623b64cb10901e5c668
parentb6cfffa7ad923c73f317ea50fd4ebcb3b4b6669c (diff)
ip: limit use of gso_size to udp
The ipcm(6)_cookie field gso_size is set only in the udp path. The ip layer copies this to cork only if sk_type is SOCK_DGRAM. This check proved too permissive. Ping and l2tp sockets have the same type. Limit to sockets of type SOCK_DGRAM and protocol IPPROTO_UDP to exclude ping sockets. v1 -> v2 - remove irrelevant whitespace changes Fixes: bec1f6f69736 ("udp: generate gso with UDP_SEGMENT") Reported-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/ip_output.c3
-rw-r--r--net/ipv6/ip6_output.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index af5a830ff6ad..b3308e9d9762 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1145,7 +1145,8 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
1145 cork->fragsize = ip_sk_use_pmtu(sk) ? 1145 cork->fragsize = ip_sk_use_pmtu(sk) ?
1146 dst_mtu(&rt->dst) : rt->dst.dev->mtu; 1146 dst_mtu(&rt->dst) : rt->dst.dev->mtu;
1147 1147
1148 cork->gso_size = sk->sk_type == SOCK_DGRAM ? ipc->gso_size : 0; 1148 cork->gso_size = sk->sk_type == SOCK_DGRAM &&
1149 sk->sk_protocol == IPPROTO_UDP ? ipc->gso_size : 0;
1149 cork->dst = &rt->dst; 1150 cork->dst = &rt->dst;
1150 cork->length = 0; 1151 cork->length = 0;
1151 cork->ttl = ipc->ttl; 1152 cork->ttl = ipc->ttl;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 021e5aef6ba3..a14fb4fcdf18 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1219,7 +1219,8 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
1219 if (mtu < IPV6_MIN_MTU) 1219 if (mtu < IPV6_MIN_MTU)
1220 return -EINVAL; 1220 return -EINVAL;
1221 cork->base.fragsize = mtu; 1221 cork->base.fragsize = mtu;
1222 cork->base.gso_size = sk->sk_type == SOCK_DGRAM ? ipc6->gso_size : 0; 1222 cork->base.gso_size = sk->sk_type == SOCK_DGRAM &&
1223 sk->sk_protocol == IPPROTO_UDP ? ipc6->gso_size : 0;
1223 1224
1224 if (dst_allfrag(xfrm_dst_path(&rt->dst))) 1225 if (dst_allfrag(xfrm_dst_path(&rt->dst)))
1225 cork->base.flags |= IPCORK_ALLFRAG; 1226 cork->base.flags |= IPCORK_ALLFRAG;