From: Cong Wang <xiyou.wangcong@gmail.com>
To: Chinmay Agarwal <chinagar@codeaurora.org>
Cc: Jakub Kicinski <kuba@kernel.org>,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
David Miller <davem@davemloft.net>,
sharathv@codeaurora.org
Subject: Re: [PATCH] neighbour: Prevent a dead entry from updating gc_list
Date: Wed, 27 Jan 2021 18:34:16 -0800 [thread overview]
Message-ID: <CAM_iQpVvuHXiwdNn9NqU1M6UWGKTkQWqDQpPp7zuEA7zcGk-qw@mail.gmail.com> (raw)
In-Reply-To: <20210127165453.GA20514@chinagar-linux.qualcomm.com>
On Wed, Jan 27, 2021 at 8:55 AM Chinmay Agarwal <chinagar@codeaurora.org> wrote:
>
> Following race condition was detected:
> <CPU A, t0> - neigh_flush_dev() is under execution and calls
> neigh_mark_dead(n) marking the neighbour entry 'n' as dead.
>
> <CPU B, t1> - Executing: __netif_receive_skb() ->
> __netif_receive_skb_core() -> arp_rcv() -> arp_process().arp_process()
> calls __neigh_lookup() which takes a reference on neighbour entry 'n'.
>
> <CPU A, t2> - Moves further along neigh_flush_dev() and calls
> neigh_cleanup_and_release(n), but since reference count increased in t2,
> 'n' couldn't be destroyed.
>
> <CPU B, t3> - Moves further along, arp_process() and calls
> neigh_update()-> __neigh_update() -> neigh_update_gc_list(), which adds
> the neighbour entry back in gc_list(neigh_mark_dead(), removed it
> earlier in t0 from gc_list)
>
> <CPU B, t4> - arp_process() finally calls neigh_release(n), destroying
> the neighbour entry.
>
> This leads to 'n' still being part of gc_list, but the actual
> neighbour structure has been freed.
>
> The situation can be prevented from happening if we disallow a dead
> entry to have any possibility of updating gc_list. This is what the
> patch intends to achieve.
>
> Fixes: 9c29a2f55ec0 ("neighbor: Fix locking order for gc_list changes")
> Signed-off-by: Chinmay Agarwal <chinagar@codeaurora.org>
Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com>
Thanks.
next prev parent reply other threads:[~2021-01-28 2:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 16:54 [PATCH] neighbour: Prevent a dead entry from updating gc_list Chinmay Agarwal
2021-01-28 2:34 ` Cong Wang [this message]
2021-01-30 16:05 ` David Ahern
2021-02-02 1:09 ` Jakub Kicinski
-- strict thread matches above, loose matches on Subject: below --
2021-01-25 19:59 Chinmay Agarwal
2021-01-25 21:07 ` Cong Wang
2021-01-25 21:59 ` Jakub Kicinski
2021-01-25 19:49 Chinmay Agarwal
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=CAM_iQpVvuHXiwdNn9NqU1M6UWGKTkQWqDQpPp7zuEA7zcGk-qw@mail.gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=chinagar@codeaurora.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sharathv@codeaurora.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;
as well as URLs for NNTP newsgroup(s).