netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE
@ 2019-06-10 22:27 Stefano Brivio
  2019-06-10 22:27 ` [PATCH net 1/2] vxlan: Don't assume linear buffers in error handler Stefano Brivio
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stefano Brivio @ 2019-06-10 22:27 UTC (permalink / raw)
  To: David Miller; +Cc: Guillaume Nault, Eric Dumazet, netdev

Guillaume noticed the same issue fixed by commit 26fc181e6cac ("fou, fou6:
do not assume linear skbs") for fou and fou6 is also present in VXLAN and
GENEVE error handlers: we can't assume linear buffers there, we need to
use pskb_may_pull() instead.

Stefano Brivio (2):
  vxlan: Don't assume linear buffers in error handler
  geneve: Don't assume linear buffers in error handler

 drivers/net/geneve.c | 2 +-
 drivers/net/vxlan.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.20.1


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

* [PATCH net 1/2] vxlan: Don't assume linear buffers in error handler
  2019-06-10 22:27 [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Stefano Brivio
@ 2019-06-10 22:27 ` Stefano Brivio
  2019-06-10 22:27 ` [PATCH net 2/2] geneve: " Stefano Brivio
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2019-06-10 22:27 UTC (permalink / raw)
  To: David Miller; +Cc: Guillaume Nault, Eric Dumazet, netdev

In commit c3a43b9fec8a ("vxlan: ICMP error lookup handler") I wrongly
assumed buffers from icmp_socket_deliver() would be linear. This is not
the case: icmp_socket_deliver() only guarantees we have 8 bytes of linear
data.

Eric fixed this same issue for fou and fou6 in commits 26fc181e6cac
("fou, fou6: do not assume linear skbs") and 5355ed6388e2 ("fou, fou6:
avoid uninit-value in gue_err() and gue6_err()").

Use pskb_may_pull() instead of checking skb->len, and take into account
the fact we later access the VXLAN header with udp_hdr(), so we also
need to sum skb_transport_header() here.

Reported-by: Guillaume Nault <gnault@redhat.com>
Fixes: c3a43b9fec8a ("vxlan: ICMP error lookup handler")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 drivers/net/vxlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 5994d5415a03..4c9bc29fe3d5 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1766,7 +1766,7 @@ static int vxlan_err_lookup(struct sock *sk, struct sk_buff *skb)
 	struct vxlanhdr *hdr;
 	__be32 vni;
 
-	if (skb->len < VXLAN_HLEN)
+	if (!pskb_may_pull(skb, skb_transport_offset(skb) + VXLAN_HLEN))
 		return -EINVAL;
 
 	hdr = vxlan_hdr(skb);
-- 
2.20.1


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

* [PATCH net 2/2] geneve: Don't assume linear buffers in error handler
  2019-06-10 22:27 [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Stefano Brivio
  2019-06-10 22:27 ` [PATCH net 1/2] vxlan: Don't assume linear buffers in error handler Stefano Brivio
@ 2019-06-10 22:27 ` Stefano Brivio
  2019-06-10 22:59 ` [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Guillaume Nault
  2019-06-11 19:07 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Stefano Brivio @ 2019-06-10 22:27 UTC (permalink / raw)
  To: David Miller; +Cc: Guillaume Nault, Eric Dumazet, netdev

In commit a07966447f39 ("geneve: ICMP error lookup handler") I wrongly
assumed buffers from icmp_socket_deliver() would be linear. This is not
the case: icmp_socket_deliver() only guarantees we have 8 bytes of linear
data.

Eric fixed this same issue for fou and fou6 in commits 26fc181e6cac
("fou, fou6: do not assume linear skbs") and 5355ed6388e2 ("fou, fou6:
avoid uninit-value in gue_err() and gue6_err()").

Use pskb_may_pull() instead of checking skb->len, and take into account
the fact we later access the GENEVE header with udp_hdr(), so we also
need to sum skb_transport_header() here.

Reported-by: Guillaume Nault <gnault@redhat.com>
Fixes: a07966447f39 ("geneve: ICMP error lookup handler")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 drivers/net/geneve.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 98d1a45c0606..25770122c219 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -395,7 +395,7 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)
 	u8 zero_vni[3] = { 0 };
 	u8 *vni = zero_vni;
 
-	if (skb->len < GENEVE_BASE_HLEN)
+	if (!pskb_may_pull(skb, skb_transport_offset(skb) + GENEVE_BASE_HLEN))
 		return -EINVAL;
 
 	geneveh = geneve_hdr(skb);
-- 
2.20.1


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

* Re: [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE
  2019-06-10 22:27 [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Stefano Brivio
  2019-06-10 22:27 ` [PATCH net 1/2] vxlan: Don't assume linear buffers in error handler Stefano Brivio
  2019-06-10 22:27 ` [PATCH net 2/2] geneve: " Stefano Brivio
@ 2019-06-10 22:59 ` Guillaume Nault
  2019-06-11 19:07 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Guillaume Nault @ 2019-06-10 22:59 UTC (permalink / raw)
  To: Stefano Brivio; +Cc: David Miller, Eric Dumazet, netdev

On Tue, Jun 11, 2019 at 12:27:04AM +0200, Stefano Brivio wrote:
> Guillaume noticed the same issue fixed by commit 26fc181e6cac ("fou, fou6:
> do not assume linear skbs") for fou and fou6 is also present in VXLAN and
> GENEVE error handlers: we can't assume linear buffers there, we need to
> use pskb_may_pull() instead.
> 
Acked-by: Guillaume Nault <gnault@redhat.com>

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

* Re: [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE
  2019-06-10 22:27 [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Stefano Brivio
                   ` (2 preceding siblings ...)
  2019-06-10 22:59 ` [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Guillaume Nault
@ 2019-06-11 19:07 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2019-06-11 19:07 UTC (permalink / raw)
  To: sbrivio; +Cc: gnault, edumazet, netdev

From: Stefano Brivio <sbrivio@redhat.com>
Date: Tue, 11 Jun 2019 00:27:04 +0200

> Guillaume noticed the same issue fixed by commit 26fc181e6cac ("fou, fou6:
> do not assume linear skbs") for fou and fou6 is also present in VXLAN and
> GENEVE error handlers: we can't assume linear buffers there, we need to
> use pskb_may_pull() instead.

Series applied and queued up for -stable, thanks for fixing this.

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

end of thread, other threads:[~2019-06-11 19:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-10 22:27 [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Stefano Brivio
2019-06-10 22:27 ` [PATCH net 1/2] vxlan: Don't assume linear buffers in error handler Stefano Brivio
2019-06-10 22:27 ` [PATCH net 2/2] geneve: " Stefano Brivio
2019-06-10 22:59 ` [PATCH net 0/2] Don't assume linear buffers in error handlers for VXLAN and GENEVE Guillaume Nault
2019-06-11 19:07 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).