public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Dave Jones <davej@redhat.com>, David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: Re: oops in udpv6_sendmsg
Date: Wed, 26 Jun 2013 04:15:07 -0700	[thread overview]
Message-ID: <1372245307.3301.171.camel@edumazet-glaptop> (raw)
In-Reply-To: <1372238996.3301.149.camel@edumazet-glaptop>

From: Eric Dumazet <edumazet@google.com>

On Wed, 2013-06-26 at 02:29 -0700, Eric Dumazet wrote:
> On Wed, 2013-06-26 at 02:22 -0700, Eric Dumazet wrote:
> > ip6_rt_put
> > 
> > Oh well...
> > 
> > It sounds we mix ipv4/ipv6 dst on an IPV6 socket.
> > 
> > So an IPV4 actor thinks he got a "struct rtable" pointer and messes
> > critical fields which overlay struct rt6_info components, for example
> > rt6i_node
> > 
> > rt6_inode  shares the same storage with : 
> > 
> > rt_type/rt_is_input/rt_uses_gateway/rt_iif
> > 
> > In my case, rt_iif is 0
> > 
> > CC Steffen Klassert, because of commit
> > 8141ed9fcedb278f4a3a78680591bef1e55f75fb
> > ("ipv4: Add a socket release callback for datagram sockets")
> 
> ip6_sk_dst_lookup_flow()/ip6_sk_dst_check() look buggy, they assume the
> socket dst is an IPv6 one.
> 
> But its not true if ip4_datagram_connect() was called before.

Following patch fixes the problem for me :

[PATCH] ipv6: ip6_sk_dst_check() must not assume ipv6 dst

It's possible to use AF_INET6 sockets and to connect to an IPv4
destination. After this, socket dst cache is a pointer to a rtable,
not rt6_info.

ip6_sk_dst_check() should check the socket dst cache is IPv6, or else
various corruptions/crashes can happen.

Dave Jones can reproduce immediate crash with 
trinity -q -l off -n -c sendmsg -c connect

With help from Hannes Frederic Sowa

Reported-by: Dave Jones <davej@redhat.com>
Reported-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv6/ip6_output.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 95703ba..d5d20cd 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -821,11 +821,17 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk,
 					  const struct flowi6 *fl6)
 {
 	struct ipv6_pinfo *np = inet6_sk(sk);
-	struct rt6_info *rt = (struct rt6_info *)dst;
+	struct rt6_info *rt;
 
 	if (!dst)
 		goto out;
 
+	if (dst->ops->family != AF_INET6) {
+		dst_release(dst);
+		return NULL;
+	}
+
+	rt = (struct rt6_info *)dst;
 	/* Yes, checking route validity in not connected
 	 * case is not very simple. Take into account,
 	 * that we do not support routing by source, TOS,

  reply	other threads:[~2013-06-26 11:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-29 18:40 oops in udpv6_sendmsg Dave Jones
2013-03-29 18:49 ` Eric Dumazet
2013-04-02  1:23   ` Eric Dumazet
2013-04-11  0:29     ` Dave Jones
2013-04-17  1:02     ` Dave Jones
2013-04-17  2:02       ` Eric Dumazet
2013-04-17 14:11         ` Dave Jones
2013-04-17 14:27           ` Eric Dumazet
2013-04-17 16:05             ` Eric Dumazet
2013-06-25 21:28               ` Hannes Frederic Sowa
2013-06-26  9:22                 ` Eric Dumazet
2013-06-26  9:29                   ` Eric Dumazet
2013-06-26 11:15                     ` Eric Dumazet [this message]
2013-06-26 13:07                       ` Hannes Frederic Sowa
2013-06-26 22:15                         ` David Miller

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=1372245307.3301.171.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davej@redhat.com \
    --cc=davem@davemloft.net \
    --cc=hannes@stressinduktion.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox