From: David Ahern <dsa@cumulusnetworks.com>
To: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
Mahesh Bandewar <maheshb@google.com>,
Eric Dumazet <edumazet@google.com>,
David Miller <davem@davemloft.net>,
Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
James Morris <jmorris@namei.org>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
Patrick McHardy <kaber@trash.net>,
netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Cong Wang <xiyou.wangcong@gmail.com>,
syzkaller <syzkaller@googlegroups.com>
Subject: Re: net: heap out-of-bounds in fib6_clean_node/rt6_fill_node/fib6_age/fib6_prune_clone
Date: Mon, 6 Mar 2017 16:41:02 -0700 [thread overview]
Message-ID: <14c01aea-6c2f-6ba5-6aee-52c55f410da7@cumulusnetworks.com> (raw)
In-Reply-To: <CACT4Y+Z1MvKbb35-jhaY=jEoR+t2u2TiUpkCR_oG3=VNmKjqvQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
On 3/6/17 11:51 AM, Dmitry Vyukov wrote:
> We hit it several thousand times, but we get only several dozens of
> crashes per day on ~80 VMs. So if you try to reproduce it on a single
> machine it can take days for a single crash.
> If you are ready to go that route, here are some instructions on
> setting up syzkaller:
> https://github.com/google/syzkaller
> You also need kernel built with CONFIG_KASAN.
ack and I have it setup on ubuntu 16.10 which has a fairly new compiler.
> I am ready to help with resolving any issues.
>
> Another possible route is if you give me a patch with some additional
> WARNINGs. Then I can deploy it to bots and collect stacks.
try the attached.
[-- Attachment #2: ipv6-debug.patch --]
[-- Type: text/plain, Size: 3273 bytes --]
diff --git a/include/net/dst.h b/include/net/dst.h
index 049af33da3b6..d164eb8ceab8 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -58,6 +58,7 @@ struct dst_entry {
#define DST_XFRM_TUNNEL 0x0080
#define DST_XFRM_QUEUE 0x0100
#define DST_METADATA 0x0200
+#define DST_IN_FIB 0x0400
short error;
diff --git a/net/core/dst.c b/net/core/dst.c
index 960e503b5a52..c98447fe8510 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -232,6 +232,9 @@ void __dst_free(struct dst_entry *dst)
{
spin_lock_bh(&dst_garbage.lock);
___dst_free(dst);
+if (dst->flags & DST_IN_FIB)
+ pr_warn("dst %p is marked as in fib\n", dst);
+//WARN_ON(dst->flags & DST_IN_FIB);
dst->next = dst_garbage.list;
dst_garbage.list = dst;
if (dst_garbage.timer_inc > DST_GC_INC) {
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index e4266746e4a2..a4d55ba00a43 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -155,6 +155,7 @@ static void node_free(struct fib6_node *fn)
static void rt6_rcu_free(struct rt6_info *rt)
{
+WARN_ON(rt->dst.flags & DST_IN_FIB);
call_rcu(&rt->dst.rcu_head, dst_rcu_free);
}
@@ -878,6 +879,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
return err;
rt->dst.rt6_next = iter;
+ rt->dst.flags |= DST_IN_FIB;
*ins = rt;
rt->rt6i_node = fn;
atomic_inc(&rt->rt6i_ref);
@@ -907,6 +909,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt,
*ins = rt;
rt->rt6i_node = fn;
rt->dst.rt6_next = iter->dst.rt6_next;
+ rt->dst.flags |= DST_IN_FIB;
atomic_inc(&rt->rt6i_ref);
if (!info->skip_notify)
inet6_rt_notify(RTM_NEWROUTE, rt, info, NLM_F_REPLACE);
@@ -974,6 +977,20 @@ int fib6_add(struct fib6_node *root, struct rt6_info *rt,
!atomic_read(&rt->dst.__refcnt)))
return -EINVAL;
+if (rt->dst.ops->family != AF_INET6) {
+ pr_warn("fib6_add: adding rt with family is %d dst flags %x\n",
+ rt->dst.ops->family, rt->dst.flags);
+
+ WARN_ON(1);
+}
+/* dst.next really should not be set at this point */
+if (rt->dst.next && rt->dst.next->ops->family != AF_INET6) {
+ pr_warn("fib6_add: adding rt with bad next -- family %d dst flags %x\n",
+ rt->dst.next->ops->family, rt->dst.next->flags);
+
+ WARN_ON(1);
+}
+
if (info->nlh) {
if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
allow_create = 0;
@@ -1444,6 +1461,7 @@ static void fib6_del_route(struct fib6_node *fn, struct rt6_info **rtp,
read_unlock(&net->ipv6.fib6_walker_lock);
rt->dst.rt6_next = NULL;
+ rt->dst.flags &= ~DST_IN_FIB;
/* If it was last route, expunge its radix tree node */
if (!fn->leaf) {
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 229bfcc451ef..e91d7871ccfc 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1135,6 +1135,8 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
dst_hold(&uncached_rt->dst);
+ uncached_rt->dst.flags &= ~DST_IN_FIB;
+
trace_fib6_table_lookup(net, uncached_rt, table->tb6_id, fl6);
return uncached_rt;
@@ -1160,6 +1162,7 @@ struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
dst_release(&rt->dst);
}
+ pcpu_rt->dst.flags &= ~DST_IN_FIB;
trace_fib6_table_lookup(net, pcpu_rt, table->tb6_id, fl6);
return pcpu_rt;
next prev parent reply other threads:[~2017-03-06 23:50 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-03 14:39 Dmitry Vyukov
2017-03-03 19:12 ` David Ahern
2017-03-03 19:14 ` Dmitry Vyukov
2017-03-04 18:57 ` Dmitry Vyukov
2017-03-04 19:00 ` Dmitry Vyukov
2017-03-04 20:15 ` Eric Dumazet
2017-03-05 10:53 ` Dmitry Vyukov
2017-03-06 17:31 ` David Ahern
2017-03-06 18:51 ` Dmitry Vyukov
2017-03-06 23:41 ` David Ahern [this message]
2017-03-07 8:43 ` Dmitry Vyukov
2017-03-07 9:21 ` Dmitry Vyukov
2017-03-07 18:03 ` David Ahern
2017-03-07 18:13 ` Dmitry Vyukov
2017-03-07 18:43 ` David Ahern
2017-03-07 19:02 ` Dmitry Vyukov
2017-03-07 19:30 ` Dmitry Vyukov
2017-03-07 20:00 ` Dmitry Vyukov
2017-03-08 11:55 ` Dmitry Vyukov
2017-03-27 12:42 ` Dmitry Vyukov
2017-03-27 13:57 ` David Ahern
2017-03-27 14:23 ` Dmitry Vyukov
2017-04-18 20:43 ` Andrey Konovalov
2017-04-18 23:20 ` David Ahern
2017-04-19 1:09 ` Andrey Konovalov
2017-04-19 16:09 ` David Ahern
2017-04-19 16:12 ` Andrey Konovalov
2017-04-19 16:29 ` David Ahern
2017-04-19 23:47 ` Cong Wang
2017-04-19 23:51 ` David Ahern
2017-04-20 8:35 ` Dmitry Vyukov
2017-04-20 12:10 ` Andrey Konovalov
2017-04-20 15:28 ` Andrey Konovalov
2017-04-20 15:29 ` Andrey Konovalov
2017-04-20 15:35 ` David Ahern
2017-04-20 15:39 ` Andrey Konovalov
2017-04-20 16:09 ` Andrey Konovalov
2017-04-21 14:27 ` David Ahern
2017-04-21 16:47 ` Eric Dumazet
2017-04-21 18:25 ` David Ahern
2017-04-25 15:51 ` David Ahern
2017-04-25 15:57 ` David Ahern
2017-03-07 17:17 ` David Ahern
2017-03-07 17:45 ` Dmitry Vyukov
2017-03-07 17:57 ` David Ahern
2017-04-25 15:56 ` David Ahern
2017-04-25 16:36 ` Andrey Konovalov
2017-04-25 16:38 ` Andrey Konovalov
2017-04-25 16:40 ` David Ahern
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=14c01aea-6c2f-6ba5-6aee-52c55f410da7@cumulusnetworks.com \
--to=dsa@cumulusnetworks.com \
--cc=davem@davemloft.net \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=jmorris@namei.org \
--cc=kaber@trash.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=maheshb@google.com \
--cc=netdev@vger.kernel.org \
--cc=syzkaller@googlegroups.com \
--cc=xiyou.wangcong@gmail.com \
--cc=yoshfuji@linux-ipv6.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®