Netdev List
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	David Miller <davem@davemloft.net>,
	dsahern@kernel.org
Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com, dsahern@gmail.com
Subject: Re: [PATCH v2 net-next] neighbor: Improve garbage collection
Date: Mon, 10 Dec 2018 09:55:44 +0100	[thread overview]
Message-ID: <5c0e2a107caee_16112ae4fe0d10d42b@olga.notmuch> (raw)
In-Reply-To: <54aa78ec-9a5b-b798-d93d-7daf2e6b1a96@gmail.com>

Eric Dumazet wrote:
> 
> 
> On 12/07/2018 04:03 PM, David Miller wrote:
> > From: David Ahern <dsahern@kernel.org>
> > Date: Fri,  7 Dec 2018 12:24:57 -0800
> > 
> >> From: David Ahern <dsahern@gmail.com>
> >>
> >> The existing garbage collection algorithm has a number of problems:
> >  ...
> >> This patch addresses these problems as follows:
> >>
> >> 1. Use of a separate list_head to track entries that can be garbage
> >>    collected along with a separate counter. PERMANENT entries are not
> >>    added to this list.
> >>
> >>    The gc_thresh parameters are only compared to the new counter, not the
> >>    total entries in the table. The forced_gc function is updated to only
> >>    walk this new gc_list looking for entries to evict.
> >>
> >> 2. Entries are added to the list head at the tail and removed from the
> >>    front.
> >>
> >> 3. Entries are only evicted if they were last updated more than 5 seconds
> >>    ago, adhering to the original intent of gc_thresh2.
> >>
> >> 4. Forced gc is stopped once the number of gc_entries drops below
> >>    gc_thresh2.
> >>
> >> 5. Since gc checks do not apply to PERMANENT entries, gc levels are skipped
> >>    when allocating a new neighbor for a PERMANENT entry. By extension this
> >>    means there are no explicit limits on the number of PERMANENT entries
> >>    that can be created, but this is no different than FIB entries or FDB
> >>    entries.
> >>
> >> Signed-off-by: David Ahern <dsahern@gmail.com>
> >> ---
> >> v2
> >> - remove on_gc_list boolean in favor of !list_empty
> >> - fix neigh_alloc to add new entry to tail of list_head
> > 
> > Again, looks great, applied.
> > 
> 
> What protects gc_list linkage ?
> 
> We can not use list_del_init(&n->gc_list);                    or 
>                list_add_tail(&n->gc_list, &n->tbl->gc_list);
> 
> if tbl->lock is not held.
> 
> It seems to me this patch needs more care.
> 

This seems to be problematic in neigh_create() which uses neigh_alloc()
before grabbing the lock (which uses list_add_tail()), as seen in the
syzbot traces:
-> KASAN: use-after-free Read in ___neigh_create
   syzbot+e4d42eb35f6a27b0a628@syzkaller.appspotmail.com
-> KASAN: slab-out-of-bounds Read in ___neigh_create
   syzbot+3ddead5619658537909b@syzkaller.appspotmail.com
-> BUG: corrupted list in ___neigh_create
   syzbot+b354d1fb59091ea73c37@syzkaller.appspotmail.com

  parent reply	other threads:[~2018-12-10  9:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-07 20:24 [PATCH v2 net-next] neighbor: Improve garbage collection David Ahern
2018-12-08  0:03 ` David Miller
2018-12-10  5:12   ` Eric Dumazet
2018-12-10  5:14     ` Eric Dumazet
2018-12-10  8:55     ` Wolfgang Bumiller [this message]
2018-12-10 14:38     ` 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=5c0e2a107caee_16112ae4fe0d10d42b@olga.notmuch \
    --to=w.bumiller@proxmox.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=roopa@cumulusnetworks.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