* [PATCH net] udp: consistently apply ufo or fragmentation
@ 2017-08-14 11:31 Vasily Averin
2017-08-14 14:53 ` Willem de Bruijn
0 siblings, 1 reply; 4+ messages in thread
From: Vasily Averin @ 2017-08-14 11:31 UTC (permalink / raw)
To: Linux Kernel Network Developers, Willem de Bruijn,
David S. Miller, Andrey Konovalov
Dear Willem,
ip*_ufo_append_data() is called now for each skb_is_gso() packet.
Before the patch it was called for UDP packets only.
Could you please clarify, is it correct?
Thank you,
Vasily Averin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] udp: consistently apply ufo or fragmentation
2017-08-14 11:31 [PATCH net] udp: consistently apply ufo or fragmentation Vasily Averin
@ 2017-08-14 14:53 ` Willem de Bruijn
0 siblings, 0 replies; 4+ messages in thread
From: Willem de Bruijn @ 2017-08-14 14:53 UTC (permalink / raw)
To: Vasily Averin
Cc: Linux Kernel Network Developers, Willem de Bruijn,
David S. Miller, Andrey Konovalov
> ip*_ufo_append_data() is called now for each skb_is_gso() packet.
> Before the patch it was called for UDP packets only.
>
> Could you please clarify, is it correct?
__ip_append_data is called for udp, raw, icmp and ping sockets.
Of these, only udp packets have a path to get skb_is_gso() set:
when __ip_append_data has been called before on this packet
(using MSG_MORE) and the path entered ip_ufo_append_data
in that call through the other conditions in the branch, which
include sk->sk_type == SOCK_DGRAM.
This function is not reached from other segmentable protocols
like tcp, which call ip_queue_xmit in the ip layer. The exceptions
are sending in ip_send_unicast_reply, but those will not have gso.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net] udp: consistently apply ufo or fragmentation
@ 2017-08-10 16:29 Willem de Bruijn
2017-08-10 16:52 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Willem de Bruijn @ 2017-08-10 16:29 UTC (permalink / raw)
To: netdev; +Cc: davem, andreyknvl, Willem de Bruijn
From: Willem de Bruijn <willemb@google.com>
When iteratively building a UDP datagram with MSG_MORE and that
datagram exceeds MTU, consistently choose UFO or fragmentation.
Once skb_is_gso, always apply ufo. Conversely, once a datagram is
split across multiple skbs, do not consider ufo.
Sendpage already maintains the first invariant, only add the second.
IPv6 does not have a sendpage implementation to modify.
A gso skb must have a partial checksum, do not follow sk_no_check_tx
in udp_send_skb.
Found by syzkaller.
Fixes: e89e9cf539a2 ("[IPv4/IPv6]: UFO Scatter-gather approach")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
net/ipv4/ip_output.c | 8 +++++---
net/ipv4/udp.c | 2 +-
net/ipv6/ip6_output.c | 7 ++++---
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 50c74cd890bc..e153c40c2436 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -965,11 +965,12 @@ static int __ip_append_data(struct sock *sk,
csummode = CHECKSUM_PARTIAL;
cork->length += length;
- if ((((length + (skb ? skb->len : fragheaderlen)) > mtu) ||
- (skb && skb_is_gso(skb))) &&
+ if ((skb && skb_is_gso(skb)) ||
+ (((length + (skb ? skb->len : fragheaderlen)) > mtu) &&
+ (skb_queue_len(queue) <= 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) &&
- (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx) {
+ (sk->sk_type == SOCK_DGRAM) && !sk->sk_no_check_tx)) {
err = ip_ufo_append_data(sk, queue, getfrag, from, length,
hh_len, fragheaderlen, transhdrlen,
maxfraglen, flags);
@@ -1288,6 +1289,7 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page,
return -EINVAL;
if ((size + skb->len > mtu) &&
+ (skb_queue_len(&sk->sk_write_queue) == 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO)) {
if (skb->ip_summed != CHECKSUM_PARTIAL)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index e6276fa3750b..a7c804f73990 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -802,7 +802,7 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4)
if (is_udplite) /* UDP-Lite */
csum = udplite_csum(skb);
- else if (sk->sk_no_check_tx) { /* UDP csum disabled */
+ else if (sk->sk_no_check_tx && !skb_is_gso(skb)) { /* UDP csum off */
skb->ip_summed = CHECKSUM_NONE;
goto send;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 162efba0d0cd..2dfe50d8d609 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1381,11 +1381,12 @@ static int __ip6_append_data(struct sock *sk,
*/
cork->length += length;
- if ((((length + (skb ? skb->len : headersize)) > mtu) ||
- (skb && skb_is_gso(skb))) &&
+ if ((skb && skb_is_gso(skb)) ||
+ (((length + (skb ? skb->len : headersize)) > mtu) &&
+ (skb_queue_len(queue) <= 1) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO) && !dst_xfrm(&rt->dst) &&
- (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk)) {
+ (sk->sk_type == SOCK_DGRAM) && !udp_get_no_check6_tx(sk))) {
err = ip6_ufo_append_data(sk, queue, getfrag, from, length,
hh_len, fragheaderlen, exthdrlen,
transhdrlen, mtu, flags, fl6);
--
2.14.0.434.g98096fd7a8-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] udp: consistently apply ufo or fragmentation
2017-08-10 16:29 Willem de Bruijn
@ 2017-08-10 16:52 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-10 16:52 UTC (permalink / raw)
To: willemdebruijn.kernel; +Cc: netdev, andreyknvl, willemb
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Thu, 10 Aug 2017 12:29:19 -0400
> From: Willem de Bruijn <willemb@google.com>
>
> When iteratively building a UDP datagram with MSG_MORE and that
> datagram exceeds MTU, consistently choose UFO or fragmentation.
>
> Once skb_is_gso, always apply ufo. Conversely, once a datagram is
> split across multiple skbs, do not consider ufo.
>
> Sendpage already maintains the first invariant, only add the second.
> IPv6 does not have a sendpage implementation to modify.
>
> A gso skb must have a partial checksum, do not follow sk_no_check_tx
> in udp_send_skb.
>
> Found by syzkaller.
>
> Fixes: e89e9cf539a2 ("[IPv4/IPv6]: UFO Scatter-gather approach")
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-14 14:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-14 11:31 [PATCH net] udp: consistently apply ufo or fragmentation Vasily Averin
2017-08-14 14:53 ` Willem de Bruijn
-- strict thread matches above, loose matches on Subject: below --
2017-08-10 16:29 Willem de Bruijn
2017-08-10 16:52 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox