From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B5ADC43381 for ; Fri, 8 Mar 2019 18:51:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53DA320857 for ; Fri, 8 Mar 2019 18:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbfCHSv0 (ORCPT ); Fri, 8 Mar 2019 13:51:26 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:38250 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726821AbfCHSvZ (ORCPT ); Fri, 8 Mar 2019 13:51:25 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::d71]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 61C6514A87CEC; Fri, 8 Mar 2019 10:51:25 -0800 (PST) Date: Fri, 08 Mar 2019 10:51:22 -0800 (PST) Message-Id: <20190308.105122.656526755979170615.davem@davemloft.net> To: lucien.xin@gmail.com Cc: netdev@vger.kernel.org, dsahern@gmail.com, 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 From: David Miller In-Reply-To: <42a31507d9b1d4874bb9a8570bd9f17225aaa553.1552027854.git.lucien.xin@gmail.com> References: <42a31507d9b1d4874bb9a8570bd9f17225aaa553.1552027854.git.lucien.xin@gmail.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 08 Mar 2019 10:51:25 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Xin Long Date: Fri, 8 Mar 2019 14:50:54 +0800 > 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. I did "s/thinks/thanks/" here. > 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 > Signed-off-by: Xin Long Applied and queues up for -stable, thank you.