netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
@ 2019-08-12 22:46 Stefano Brivio
  2019-08-12 23:08 ` Guillaume Nault
  2019-08-14 16:58 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Stefano Brivio @ 2019-08-12 22:46 UTC (permalink / raw)
  To: David Miller
  Cc: Guillaume Nault, Hangbin Liu, Eric Dumazet, Linus Lüssing, netdev

Commit ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and
ipv6_mc_check_mld() calls") replaces direct calls to pskb_may_pull()
in br_ipv6_multicast_mld2_report() with calls to ipv6_mc_may_pull(),
that returns -EINVAL on buffers too short to be valid IPv6 packets,
while maintaining the previous handling of the return code.

This leads to the direct opposite of the intended effect: if the
packet is malformed, -EINVAL evaluates as true, and we'll happily
proceed with the processing.

Return 0 if the packet is too short, in the same way as this was
fixed for IPv4 by commit 083b78a9ed64 ("ip: fix ip_mc_may_pull()
return value").

I don't have a reproducer for this, unlike the one referred to by
the IPv4 commit, but this is clearly broken.

Fixes: ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and ipv6_mc_check_mld() calls")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 include/net/addrconf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index becdad576859..3f62b347b04a 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -206,7 +206,7 @@ static inline int ipv6_mc_may_pull(struct sk_buff *skb,
 				   unsigned int len)
 {
 	if (skb_transport_offset(skb) + ipv6_transport_len(skb) < len)
-		return -EINVAL;
+		return 0;
 
 	return pskb_may_pull(skb, len);
 }
-- 
2.20.1


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

* Re: [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
  2019-08-12 22:46 [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets Stefano Brivio
@ 2019-08-12 23:08 ` Guillaume Nault
  2019-08-14 16:58 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Guillaume Nault @ 2019-08-12 23:08 UTC (permalink / raw)
  To: Stefano Brivio
  Cc: David Miller, Hangbin Liu, Eric Dumazet, Linus Lüssing, netdev

On Tue, Aug 13, 2019 at 12:46:01AM +0200, Stefano Brivio wrote:
> Commit ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and
> ipv6_mc_check_mld() calls") replaces direct calls to pskb_may_pull()
> in br_ipv6_multicast_mld2_report() with calls to ipv6_mc_may_pull(),
> that returns -EINVAL on buffers too short to be valid IPv6 packets,
> while maintaining the previous handling of the return code.
> 
> This leads to the direct opposite of the intended effect: if the
> packet is malformed, -EINVAL evaluates as true, and we'll happily
> proceed with the processing.
> 
> Return 0 if the packet is too short, in the same way as this was
> fixed for IPv4 by commit 083b78a9ed64 ("ip: fix ip_mc_may_pull()
> return value").
> 
> I don't have a reproducer for this, unlike the one referred to by
> the IPv4 commit, but this is clearly broken.
> 
> Fixes: ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and ipv6_mc_check_mld() calls")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>  include/net/addrconf.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> index becdad576859..3f62b347b04a 100644
> --- a/include/net/addrconf.h
> +++ b/include/net/addrconf.h
> @@ -206,7 +206,7 @@ static inline int ipv6_mc_may_pull(struct sk_buff *skb,
>  				   unsigned int len)
>  {
>  	if (skb_transport_offset(skb) + ipv6_transport_len(skb) < len)
> -		return -EINVAL;
> +		return 0;
>  
>  	return pskb_may_pull(skb, len);
>  }

Acked-by: Guillaume Nault <gnault@redhat.com>

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

* Re: [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
  2019-08-12 22:46 [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets Stefano Brivio
  2019-08-12 23:08 ` Guillaume Nault
@ 2019-08-14 16:58 ` David Miller
  2019-08-14 18:26   ` Linus Lüssing
  2019-08-19 10:12   ` Stefano Brivio
  1 sibling, 2 replies; 6+ messages in thread
From: David Miller @ 2019-08-14 16:58 UTC (permalink / raw)
  To: sbrivio; +Cc: gnault, haliu, edumazet, linus.luessing, netdev

From: Stefano Brivio <sbrivio@redhat.com>
Date: Tue, 13 Aug 2019 00:46:01 +0200

> Commit ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and
> ipv6_mc_check_mld() calls") replaces direct calls to pskb_may_pull()
> in br_ipv6_multicast_mld2_report() with calls to ipv6_mc_may_pull(),
> that returns -EINVAL on buffers too short to be valid IPv6 packets,
> while maintaining the previous handling of the return code.
> 
> This leads to the direct opposite of the intended effect: if the
> packet is malformed, -EINVAL evaluates as true, and we'll happily
> proceed with the processing.
> 
> Return 0 if the packet is too short, in the same way as this was
> fixed for IPv4 by commit 083b78a9ed64 ("ip: fix ip_mc_may_pull()
> return value").
> 
> I don't have a reproducer for this, unlike the one referred to by
> the IPv4 commit, but this is clearly broken.
> 
> Fixes: ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and ipv6_mc_check_mld() calls")
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Applied and queued up for -stable.

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

* Re: [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
  2019-08-14 16:58 ` David Miller
@ 2019-08-14 18:26   ` Linus Lüssing
  2019-08-19 10:12   ` Stefano Brivio
  1 sibling, 0 replies; 6+ messages in thread
From: Linus Lüssing @ 2019-08-14 18:26 UTC (permalink / raw)
  To: David Miller; +Cc: bridge, sbrivio, gnault, haliu, edumazet, netdev

On Wed, Aug 14, 2019 at 12:58:58PM -0400, David Miller wrote:
> From: Stefano Brivio <sbrivio@redhat.com>
> Date: Tue, 13 Aug 2019 00:46:01 +0200
> 
> > Commit ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and
> > ipv6_mc_check_mld() calls") replaces direct calls to pskb_may_pull()
> > in br_ipv6_multicast_mld2_report() with calls to ipv6_mc_may_pull(),
> > that returns -EINVAL on buffers too short to be valid IPv6 packets,
> > while maintaining the previous handling of the return code.
> > 
> > This leads to the direct opposite of the intended effect: if the
> > packet is malformed, -EINVAL evaluates as true, and we'll happily
> > proceed with the processing.
> > 
> > Return 0 if the packet is too short, in the same way as this was
> > fixed for IPv4 by commit 083b78a9ed64 ("ip: fix ip_mc_may_pull()
> > return value").
> > 
> > I don't have a reproducer for this, unlike the one referred to by
> > the IPv4 commit, but this is clearly broken.
> > 
> > Fixes: ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and ipv6_mc_check_mld() calls")
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> 
> Applied and queued up for -stable.

Urgh, sorry... and thanks for the fix(es), absolutely right...

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

* Re: [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
  2019-08-14 16:58 ` David Miller
  2019-08-14 18:26   ` Linus Lüssing
@ 2019-08-19 10:12   ` Stefano Brivio
  2019-08-20  0:20     ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Stefano Brivio @ 2019-08-19 10:12 UTC (permalink / raw)
  To: David Miller; +Cc: gnault, haliu, edumazet, linus.luessing, netdev

Hi,

On Wed, 14 Aug 2019 12:58:58 -0400 (EDT)
David Miller <davem@davemloft.net> wrote:

> From: Stefano Brivio <sbrivio@redhat.com>
> Date: Tue, 13 Aug 2019 00:46:01 +0200
> 
> > Commit ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and
> > ipv6_mc_check_mld() calls") replaces direct calls to pskb_may_pull()
> > in br_ipv6_multicast_mld2_report() with calls to ipv6_mc_may_pull(),
> > that returns -EINVAL on buffers too short to be valid IPv6 packets,
> > while maintaining the previous handling of the return code.
> > 
> > This leads to the direct opposite of the intended effect: if the
> > packet is malformed, -EINVAL evaluates as true, and we'll happily
> > proceed with the processing.
> > 
> > Return 0 if the packet is too short, in the same way as this was
> > fixed for IPv4 by commit 083b78a9ed64 ("ip: fix ip_mc_may_pull()
> > return value").
> > 
> > I don't have a reproducer for this, unlike the one referred to by
> > the IPv4 commit, but this is clearly broken.
> > 
> > Fixes: ba5ea614622d ("bridge: simplify ip_mc_check_igmp() and ipv6_mc_check_mld() calls")
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>  
> 
> Applied and queued up for -stable.

I don't see this on net.git, but it's in your stable bundle on
Patchwork. Should I resend? Thanks.

-- 
Stefano

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

* Re: [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets
  2019-08-19 10:12   ` Stefano Brivio
@ 2019-08-20  0:20     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2019-08-20  0:20 UTC (permalink / raw)
  To: sbrivio; +Cc: gnault, haliu, edumazet, linus.luessing, netdev

From: Stefano Brivio <sbrivio@redhat.com>
Date: Mon, 19 Aug 2019 12:12:52 +0200

> I don't see this on net.git, but it's in your stable bundle on
> Patchwork. Should I resend? Thanks.

I applied it on my laptop while travelling and never pushed it out so it
just rot there, sorry.

Fixed, should be in 'net' now.

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

end of thread, other threads:[~2019-08-20  0:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-12 22:46 [PATCH net] ipv6: Fix return value of ipv6_mc_may_pull() for malformed packets Stefano Brivio
2019-08-12 23:08 ` Guillaume Nault
2019-08-14 16:58 ` David Miller
2019-08-14 18:26   ` Linus Lüssing
2019-08-19 10:12   ` Stefano Brivio
2019-08-20  0:20     ` 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).