From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: dccp@vger.kernel.org
Subject: Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
Date: Mon, 28 Nov 2016 14:40:01 +0000 [thread overview]
Message-ID: <20161128144001.GE16426@kernel.org> (raw)
In-Reply-To: <1480343209.18162.50.camel@edumazet-glaptop3.roam.corp.google.com>
Em Mon, Nov 28, 2016 at 06:26:49AM -0800, Eric Dumazet escreveu:
> From: Eric Dumazet <edumazet@google.com>
>
> pskb_may_pull() can reallocate skb->head, we need to reload dh pointer
> in dccp_invalid_packet() or risk use after free.
>
> Bug found by Andrey Konovalov using syzkaller.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
I was about to send exactly this patch, and while looking at it I think
the patch below needs to go in as well, no? To follow the advice of that
Warning line there :-)
From: Arnaldo Carvalho de Melo <acme@redhat.com>
pskb_may_pull() can reallocate skb->head, so we can't access
iph->frag_off or risk use after free, save it to a variable and us that
later.
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 5ddf5cda07f4..9462070561a3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1198,6 +1198,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
struct iphdr *iph;
int proto, tot_len;
int nhoff;
+ u16 frag_off;
int ihl;
int id;
@@ -1213,6 +1214,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
id = ntohs(iph->id);
proto = iph->protocol;
+ frag_off = iph->frag_off;
/* Warning: after this point, iph might be no longer valid */
if (unlikely(!pskb_may_pull(skb, ihl)))
@@ -1233,7 +1235,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
/* fixed ID is invalid if DF bit is not set */
- if (fixedid && !(iph->frag_off & htons(IP_DF)))
+ if (fixedid && !(frag_off & htons(IP_DF)))
goto out;
}
WARNING: multiple messages have this Message-ID (diff)
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Andrey Konovalov <andreyknvl@google.com>,
Gerrit Renker <gerrit@erg.abdn.ac.uk>,
"David S. Miller" <davem@davemloft.net>,
dccp@vger.kernel.org, netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Dmitry Vyukov <dvyukov@google.com>,
Kostya Serebryany <kcc@google.com>,
Eric Dumazet <edumazet@google.com>,
syzkaller <syzkaller@googlegroups.com>
Subject: Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
Date: Mon, 28 Nov 2016 11:40:01 -0300 [thread overview]
Message-ID: <20161128144001.GE16426@kernel.org> (raw)
In-Reply-To: <1480343209.18162.50.camel@edumazet-glaptop3.roam.corp.google.com>
Em Mon, Nov 28, 2016 at 06:26:49AM -0800, Eric Dumazet escreveu:
> From: Eric Dumazet <edumazet@google.com>
>
> pskb_may_pull() can reallocate skb->head, we need to reload dh pointer
> in dccp_invalid_packet() or risk use after free.
>
> Bug found by Andrey Konovalov using syzkaller.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
I was about to send exactly this patch, and while looking at it I think
the patch below needs to go in as well, no? To follow the advice of that
Warning line there :-)
From: Arnaldo Carvalho de Melo <acme@redhat.com>
pskb_may_pull() can reallocate skb->head, so we can't access
iph->frag_off or risk use after free, save it to a variable and us that
later.
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 5ddf5cda07f4..9462070561a3 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1198,6 +1198,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
struct iphdr *iph;
int proto, tot_len;
int nhoff;
+ u16 frag_off;
int ihl;
int id;
@@ -1213,6 +1214,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
id = ntohs(iph->id);
proto = iph->protocol;
+ frag_off = iph->frag_off;
/* Warning: after this point, iph might be no longer valid */
if (unlikely(!pskb_may_pull(skb, ihl)))
@@ -1233,7 +1235,7 @@ struct sk_buff *inet_gso_segment(struct sk_buff *skb,
fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
/* fixed ID is invalid if DF bit is not set */
- if (fixedid && !(iph->frag_off & htons(IP_DF)))
+ if (fixedid && !(frag_off & htons(IP_DF)))
goto out;
}
next prev parent reply other threads:[~2016-11-28 14:40 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
2016-11-28 14:26 ` Eric Dumazet
2016-11-28 14:40 ` Arnaldo Carvalho de Melo [this message]
2016-11-28 14:40 ` Arnaldo Carvalho de Melo
2016-11-28 14:47 ` Eric Dumazet
2016-11-28 14:47 ` Eric Dumazet
2016-11-28 15:05 ` Arnaldo Carvalho de Melo
2016-11-28 15:05 ` Arnaldo Carvalho de Melo
2016-11-28 15:20 ` Eric Dumazet
2016-11-28 15:20 ` Eric Dumazet
2016-11-28 15:36 ` Arnaldo Carvalho de Melo
2016-11-28 15:36 ` Arnaldo Carvalho de Melo
2016-11-30 1:38 ` David Miller
2016-11-30 1:38 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2016-11-28 13:22 net/dccp: " Andrey Konovalov
2016-11-28 13:22 ` Andrey Konovalov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161128144001.GE16426@kernel.org \
--to=acme@kernel.org \
--cc=dccp@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.