DCCP protocol discussions
 help / color / mirror / Atom feed
* [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
@ 2016-11-28 14:26 Eric Dumazet
  2016-11-28 14:40 ` Arnaldo Carvalho de Melo
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Eric Dumazet @ 2016-11-28 14:26 UTC (permalink / raw)
  To: dccp

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>
---
 net/dccp/ipv4.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index b567c8725aea..edbe59d203ef 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -700,6 +700,7 @@ int dccp_invalid_packet(struct sk_buff *skb)
 {
 	const struct dccp_hdr *dh;
 	unsigned int cscov;
+	u8 dccph_doff;
 
 	if (skb->pkt_type != PACKET_HOST)
 		return 1;
@@ -721,18 +722,19 @@ int dccp_invalid_packet(struct sk_buff *skb)
 	/*
 	 * If P.Data Offset is too small for packet type, drop packet and return
 	 */
-	if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
-		DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff);
+	dccph_doff = dh->dccph_doff;
+	if (dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
+		DCCP_WARN("P.Data Offset(%u) too small\n", dccph_doff);
 		return 1;
 	}
 	/*
 	 * If P.Data Offset is too too large for packet, drop packet and return
 	 */
-	if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
-		DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff);
+	if (!pskb_may_pull(skb, dccph_doff * sizeof(u32))) {
+		DCCP_WARN("P.Data Offset(%u) too large\n", dccph_doff);
 		return 1;
 	}
-
+	dh = dccp_hdr(skb);
 	/*
 	 * If P.type is not Data, Ack, or DataAck and P.X = 0 (the packet
 	 * has short sequence numbers), drop packet and return



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
@ 2016-11-28 14:40 ` Arnaldo Carvalho de Melo
  2016-11-28 14:47 ` Eric Dumazet
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-11-28 14:40 UTC (permalink / raw)
  To: dccp

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;
 	}
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
  2016-11-28 14:40 ` Arnaldo Carvalho de Melo
@ 2016-11-28 14:47 ` Eric Dumazet
  2016-11-28 15:05 ` Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2016-11-28 14:47 UTC (permalink / raw)
  To: dccp

On Mon, 2016-11-28 at 11:40 -0300, Arnaldo Carvalho de Melo wrote:
> 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;
>  	}
>  


I do not see why this patch would be needed ?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
  2016-11-28 14:40 ` Arnaldo Carvalho de Melo
  2016-11-28 14:47 ` Eric Dumazet
@ 2016-11-28 15:05 ` Arnaldo Carvalho de Melo
  2016-11-28 15:20 ` Eric Dumazet
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-11-28 15:05 UTC (permalink / raw)
  To: dccp

Em Mon, Nov 28, 2016 at 06:47:14AM -0800, Eric Dumazet escreveu:
> On Mon, 2016-11-28 at 11:40 -0300, Arnaldo Carvalho de Melo wrote:
> > 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;
> >  	}
> >  
> 
> 
> I do not see why this patch would be needed ?

Where is iph being reloaded after that pskb_may_pull() and thus at line 1236 we
could use after free? The warning at line 1217?

1209         iph = ip_hdr(skb);
1210         ihl = iph->ihl * 4;
1211         if (ihl < sizeof(*iph))
1212                 goto out;
1213 
1214         id = ntohs(iph->id);
1215         proto = iph->protocol;
1216 
1217         /* Warning: after this point, iph might be no longer valid */
1218         if (unlikely(!pskb_may_pull(skb, ihl)))
1219                 goto out;
1220         __skb_pull(skb, ihl);
1221 
1222         encap = SKB_GSO_CB(skb)->encap_level > 0;
1223         if (encap)
1224                 features &= skb->dev->hw_enc_features;
1225         SKB_GSO_CB(skb)->encap_level += ihl;
1226 
1227         skb_reset_transport_header(skb);
1228 
1229         segs = ERR_PTR(-EPROTONOSUPPORT);
1230 
1231         if (!skb->encapsulation || encap) {
1232                 udpfrag = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP);
1233                 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
1234 
1235                 /* fixed ID is invalid if DF bit is not set */
1236                 if (fixedid && !(iph->frag_off & htons(IP_DF)))
1237                         goto out;
1238         }


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
                   ` (2 preceding siblings ...)
  2016-11-28 15:05 ` Arnaldo Carvalho de Melo
@ 2016-11-28 15:20 ` Eric Dumazet
  2016-11-28 15:36 ` Arnaldo Carvalho de Melo
  2016-11-30  1:38 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2016-11-28 15:20 UTC (permalink / raw)
  To: dccp

On Mon, 2016-11-28 at 12:05 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Nov 28, 2016 at 06:47:14AM -0800, Eric Dumazet escreveu:
> > On Mon, 2016-11-28 at 11:40 -0300, Arnaldo Carvalho de Melo wrote:
> > > 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;
> > >  	}
> > >  
> > 
> > 
> > I do not see why this patch would be needed ?
> 
> Where is iph being reloaded after that pskb_may_pull() and thus at line 1236 we
> could use after free? The warning at line 1217?
> 
> 1209         iph = ip_hdr(skb);
> 1210         ihl = iph->ihl * 4;
> 1211         if (ihl < sizeof(*iph))
> 1212                 goto out;
> 1213 
> 1214         id = ntohs(iph->id);
> 1215         proto = iph->protocol;
> 1216 
> 1217         /* Warning: after this point, iph might be no longer valid */
> 1218         if (unlikely(!pskb_may_pull(skb, ihl)))
> 1219                 goto out;
> 1220         __skb_pull(skb, ihl);
> 1221 
> 1222         encap = SKB_GSO_CB(skb)->encap_level > 0;
> 1223         if (encap)
> 1224                 features &= skb->dev->hw_enc_features;
> 1225         SKB_GSO_CB(skb)->encap_level += ihl;
> 1226 
> 1227         skb_reset_transport_header(skb);
> 1228 
> 1229         segs = ERR_PTR(-EPROTONOSUPPORT);
> 1230 
> 1231         if (!skb->encapsulation || encap) {
> 1232                 udpfrag = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP);
> 1233                 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
> 1234 
> 1235                 /* fixed ID is invalid if DF bit is not set */
> 1236                 if (fixedid && !(iph->frag_off & htons(IP_DF)))
> 1237                         goto out;
> 1238         }
> 

Arg, I was looking at an old tree.

Please then add

Fixes: cbc53e08a793b ("GSO: Add GSO type for fixed IPv4 ID")

To ease stable backports.

Also, it looks comments are not read, we might kill this one and reload
iph.

( Saving 3 fields is now more expensive than simply reloading iph )

Thanks.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
                   ` (3 preceding siblings ...)
  2016-11-28 15:20 ` Eric Dumazet
@ 2016-11-28 15:36 ` Arnaldo Carvalho de Melo
  2016-11-30  1:38 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-11-28 15:36 UTC (permalink / raw)
  To: dccp

Em Mon, Nov 28, 2016 at 07:20:58AM -0800, Eric Dumazet escreveu:
> On Mon, 2016-11-28 at 12:05 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Nov 28, 2016 at 06:47:14AM -0800, Eric Dumazet escreveu:
> > > On Mon, 2016-11-28 at 11:40 -0300, Arnaldo Carvalho de Melo wrote:
> > > > 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;
> > > >  	}
> > > >  
> > > 
> > > 
> > > I do not see why this patch would be needed ?
> > 
> > Where is iph being reloaded after that pskb_may_pull() and thus at line 1236 we
> > could use after free? The warning at line 1217?
> > 
> > 1209         iph = ip_hdr(skb);
> > 1210         ihl = iph->ihl * 4;
> > 1211         if (ihl < sizeof(*iph))
> > 1212                 goto out;
> > 1213 
> > 1214         id = ntohs(iph->id);
> > 1215         proto = iph->protocol;
> > 1216 
> > 1217         /* Warning: after this point, iph might be no longer valid */
> > 1218         if (unlikely(!pskb_may_pull(skb, ihl)))
> > 1219                 goto out;
> > 1220         __skb_pull(skb, ihl);
> > 1221 
> > 1222         encap = SKB_GSO_CB(skb)->encap_level > 0;
> > 1223         if (encap)
> > 1224                 features &= skb->dev->hw_enc_features;
> > 1225         SKB_GSO_CB(skb)->encap_level += ihl;
> > 1226 
> > 1227         skb_reset_transport_header(skb);
> > 1228 
> > 1229         segs = ERR_PTR(-EPROTONOSUPPORT);
> > 1230 
> > 1231         if (!skb->encapsulation || encap) {
> > 1232                 udpfrag = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP);
> > 1233                 fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID);
> > 1234 
> > 1235                 /* fixed ID is invalid if DF bit is not set */
> > 1236                 if (fixedid && !(iph->frag_off & htons(IP_DF)))
> > 1237                         goto out;
> > 1238         }
> > 
> 
> Arg, I was looking at an old tree.
> 
> Please then add
> 
> Fixes: cbc53e08a793b ("GSO: Add GSO type for fixed IPv4 ID")
> 
> To ease stable backports.
> 
> Also, it looks comments are not read, we might kill this one and reload
> iph.
> 
> ( Saving 3 fields is now more expensive than simply reloading iph )

Ok, I instead used ip_hdr(skb)->frag_off at that place, as it is the
only use after the pskb_may_pull(), right after that use it will reload
iph in another fashion anyway, sending the patch in another message,
holler if you disagree, i.e. nacking that ack 8-)

- Arnaldo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet
  2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
                   ` (4 preceding siblings ...)
  2016-11-28 15:36 ` Arnaldo Carvalho de Melo
@ 2016-11-30  1:38 ` David Miller
  5 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-11-30  1:38 UTC (permalink / raw)
  To: dccp

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 28 Nov 2016 06:26:49 -0800

> 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>

Applied and queued up for -stable, thanks Eric.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-30  1:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-28 14:26 [PATCH net] net/dccp: fix use-after-free in dccp_invalid_packet Eric Dumazet
2016-11-28 14:40 ` Arnaldo Carvalho de Melo
2016-11-28 14:47 ` Eric Dumazet
2016-11-28 15:05 ` Arnaldo Carvalho de Melo
2016-11-28 15:20 ` Eric Dumazet
2016-11-28 15:36 ` Arnaldo Carvalho de Melo
2016-11-30  1:38 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox