* [PATCH net] net: qdisc_pkt_len_init() should be more robust
@ 2018-01-19 3:59 Eric Dumazet
2018-01-19 12:40 ` Jason Wang
2018-01-22 21:00 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2018-01-19 3:59 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Willem de Bruijn, Jason Wang
From: Eric Dumazet <edumazet@google.com>
Without proper validation of DODGY packets, we might very well
feed qdisc_pkt_len_init() with invalid GSO packets.
tcp_hdrlen() might access out-of-bound data, so let's use
skb_header_pointer() and proper checks.
Whole story is described in commit d0c081b49137 ("flow_dissector:
properly cap thoff field")
We have the goal of validating DODGY packets earlier in the stack,
so we might very well revert this fix in the future.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: Jason Wang <jasowang@redhat.com>
Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com
---
net/core/dev.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 0e0ba36eeac9852b8df5ddd398dbc66ad6c83760..613fb4066be7bedbd3cd59ea9cf6eb7ef3100bd0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3151,10 +3151,21 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
/* + transport layer */
- if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
- hdr_len += tcp_hdrlen(skb);
- else
- hdr_len += sizeof(struct udphdr);
+ if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
+ const struct tcphdr *th;
+ struct tcphdr _tcphdr;
+
+ th = skb_header_pointer(skb, skb_transport_offset(skb),
+ sizeof(_tcphdr), &_tcphdr);
+ if (likely(th))
+ hdr_len += __tcp_hdrlen(th);
+ } else {
+ struct udphdr _udphdr;
+
+ if (skb_header_pointer(skb, skb_transport_offset(skb),
+ sizeof(_udphdr), &_udphdr))
+ hdr_len += sizeof(struct udphdr);
+ }
if (shinfo->gso_type & SKB_GSO_DODGY)
gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: qdisc_pkt_len_init() should be more robust
2018-01-19 3:59 [PATCH net] net: qdisc_pkt_len_init() should be more robust Eric Dumazet
@ 2018-01-19 12:40 ` Jason Wang
2018-01-22 21:00 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Jason Wang @ 2018-01-19 12:40 UTC (permalink / raw)
To: Eric Dumazet, David Miller; +Cc: netdev, Willem de Bruijn
On 2018年01月19日 11:59, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> Without proper validation of DODGY packets, we might very well
> feed qdisc_pkt_len_init() with invalid GSO packets.
>
> tcp_hdrlen() might access out-of-bound data, so let's use
> skb_header_pointer() and proper checks.
>
> Whole story is described in commit d0c081b49137 ("flow_dissector:
> properly cap thoff field")
>
> We have the goal of validating DODGY packets earlier in the stack,
> so we might very well revert this fix in the future.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com
> ---
> net/core/dev.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 0e0ba36eeac9852b8df5ddd398dbc66ad6c83760..613fb4066be7bedbd3cd59ea9cf6eb7ef3100bd0 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3151,10 +3151,21 @@ static void qdisc_pkt_len_init(struct sk_buff *skb)
> hdr_len = skb_transport_header(skb) - skb_mac_header(skb);
>
> /* + transport layer */
> - if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
> - hdr_len += tcp_hdrlen(skb);
> - else
> - hdr_len += sizeof(struct udphdr);
> + if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) {
> + const struct tcphdr *th;
> + struct tcphdr _tcphdr;
> +
> + th = skb_header_pointer(skb, skb_transport_offset(skb),
> + sizeof(_tcphdr), &_tcphdr);
> + if (likely(th))
> + hdr_len += __tcp_hdrlen(th);
> + } else {
> + struct udphdr _udphdr;
> +
> + if (skb_header_pointer(skb, skb_transport_offset(skb),
> + sizeof(_udphdr), &_udphdr))
> + hdr_len += sizeof(struct udphdr);
> + }
>
> if (shinfo->gso_type & SKB_GSO_DODGY)
> gso_segs = DIV_ROUND_UP(skb->len - hdr_len,
>
Acked-by: Jason Wang <jasowang@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: qdisc_pkt_len_init() should be more robust
2018-01-19 3:59 [PATCH net] net: qdisc_pkt_len_init() should be more robust Eric Dumazet
2018-01-19 12:40 ` Jason Wang
@ 2018-01-22 21:00 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-22 21:00 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, willemb, jasowang
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 18 Jan 2018 19:59:19 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> Without proper validation of DODGY packets, we might very well
> feed qdisc_pkt_len_init() with invalid GSO packets.
>
> tcp_hdrlen() might access out-of-bound data, so let's use
> skb_header_pointer() and proper checks.
>
> Whole story is described in commit d0c081b49137 ("flow_dissector:
> properly cap thoff field")
>
> We have the goal of validating DODGY packets earlier in the stack,
> so we might very well revert this fix in the future.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com
Applied and queued up for -stable, thanks Eric.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-22 21:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 3:59 [PATCH net] net: qdisc_pkt_len_init() should be more robust Eric Dumazet
2018-01-19 12:40 ` Jason Wang
2018-01-22 21:00 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.