netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Xin Long <lucien.xin@gmail.com>, network dev <netdev@vger.kernel.org>
Cc: davem@davemloft.net, Jon Maxwell <jmaxwell37@gmail.com>,
	jmaxwell@redhat.com
Subject: Re: [PATCH net] route: set the deleted fnhe fnhe_daddr to 0 in ip_del_fnhe to fix a race
Date: Fri, 8 Mar 2019 08:33:04 -0700	[thread overview]
Message-ID: <e0c5f95f-518d-ba07-a3bb-99f14515fc6d@gmail.com> (raw)
In-Reply-To: <42a31507d9b1d4874bb9a8570bd9f17225aaa553.1552027854.git.lucien.xin@gmail.com>

On 3/7/19 11:50 PM, Xin Long wrote:
> The race occurs in __mkroute_output() when 2 threads lookup a dst:
> 
>   CPU A                 CPU B
>   find_exception()
>                         find_exception() [fnhe expires]
>                         ip_del_fnhe() [fnhe is deleted]
>   rt_bind_exception()
> 
> In rt_bind_exception() it will bind a deleted fnhe with the new dst, and
> this dst will get no chance to be freed. It causes a dev defcnt leak and
> consecutive dmesg warnings:
> 
>   unregister_netdevice: waiting for ethX to become free. Usage count = 1
> 
> Especially thinks Jon to identify the issue.
> 
> This patch fixes it by setting fnhe_daddr to 0 in ip_del_fnhe() to stop
> binding the deleted fnhe with a new dst when checking fnhe's fnhe_daddr
> and daddr in rt_bind_exception().
> 
> It works as both ip_del_fnhe() and rt_bind_exception() are protected by
> fnhe_lock and the fhne is freed by kfree_rcu().
> 
> Fixes: deed49df7390 ("route: check and remove route cache when we get route")
> Signed-off-by: Jon Maxwell <jmaxwell37@gmail.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
>  net/ipv4/route.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 

Reviewed-by: David Ahern <dsahern@gmail.com>



  reply	other threads:[~2019-03-08 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-08  6:50 [PATCH net] route: set the deleted fnhe fnhe_daddr to 0 in ip_del_fnhe to fix a race Xin Long
2019-03-08 15:33 ` David Ahern [this message]
2019-03-08 18:51 ` 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=e0c5f95f-518d-ba07-a3bb-99f14515fc6d@gmail.com \
    --to=dsahern@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jmaxwell37@gmail.com \
    --cc=jmaxwell@redhat.com \
    --cc=lucien.xin@gmail.com \
    --cc=netdev@vger.kernel.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).