From patchwork Sat Jun 17 17:42:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Wang X-Patchwork-Id: 777348 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wql3K1byGz9s7M for ; Sun, 18 Jun 2017 03:43:57 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dOK5feX1"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbdFQRnr (ORCPT ); Sat, 17 Jun 2017 13:43:47 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34443 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbdFQRnn (ORCPT ); Sat, 17 Jun 2017 13:43:43 -0400 Received: by mail-pf0-f195.google.com with SMTP id d5so11095011pfe.1 for ; Sat, 17 Jun 2017 10:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y96nHcLRvldN1RA6j/B0IhoOwRVv9LPv/7FZXS7t0VE=; b=dOK5feX1K1Zpbg68VTYizzRG6AnQ6jEv3UfclueMOYQtMWOArMpt65Ht37wOGpx6RD daHC/agfBusguhheB9VKIAsYxsPln50fZ+xhCUdkOBDnWP/FWiK2VWgQ4mlKkmosj7u7 mC+skiFAeizqLI+sXzL8mR2vIeCa5djgpjaArn1VZ6g7e8VmEnKkLbISKyqbL1oFqQDU Pjy9XGb0v/DqyMNf7KL8dGdrW/MLa36O5dd8CFIc2cN7T2ZJUbNBhpA6lvcxs3nT5Fgv UEz9SaEnneYyL6hlSuIPy5WS/1V99njdJStum4Vc0+K3Lhxff2wnU3iJa9rCCNM1tIFt iihw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y96nHcLRvldN1RA6j/B0IhoOwRVv9LPv/7FZXS7t0VE=; b=Vp00DWczKP3UJud1fivS16Y01INXT6y0yM4FG4h4gqotufmweVBPkeMGXFdIrz80ZH FdmuIurTMbbNXQuWfZr6KG/kPwvMTzEIs2ZaTYzIDIbXjK3EPLTgn0ELcYUg1va5bs/q e6cumGf0FdWTxn41sppqsfc0TgmwzJmOWa71xD52vVjRYethxhQ8h+nhK5K0pu2Ljct2 Ui8t8JBF7tTpryO1nyin0ZFeJeNWGfQvH7ckqjwuoFBQHFFl9dL5UcvRFIas/kMUXehJ 4yR6Nm8AeINYUCnysTmojglXz9Tzvw2jP/gS4A6Q/TYGGQid2iatu8xSWbQGAAps0jd5 xn/Q== X-Gm-Message-State: AKS2vOysZ2xQt49xKz5PFWynuGY7fYD9Uvm8YeSrH9C55LGYsheNK2EC luYOK+3fO+kcGg== X-Received: by 10.98.90.199 with SMTP id o190mr17345177pfb.185.1497721422671; Sat, 17 Jun 2017 10:43:42 -0700 (PDT) Received: from weiwan0.mtv.corp.google.com ([100.123.230.66]) by smtp.gmail.com with ESMTPSA id h7sm11352777pfc.97.2017.06.17.10.43.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Jun 2017 10:43:41 -0700 (PDT) From: Wei Wang To: David Miller , netdev@vger.kernel.org Cc: Eric Dumazet , Martin KaFai Lau , Wei Wang Subject: [PATCH v2 net-next 12/21] ipv6: call dst_hold_safe() properly Date: Sat, 17 Jun 2017 10:42:35 -0700 Message-Id: <20170617174244.132862-13-tracywwnj@gmail.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170617174244.132862-1-tracywwnj@gmail.com> References: <20170617174244.132862-1-tracywwnj@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Wei Wang Similar as ipv4, ipv6 path also needs to call dst_hold_safe() when necessary to avoid double free issue on the dst. Signed-off-by: Wei Wang Acked-by: Martin KaFai Lau --- net/ipv6/addrconf.c | 4 ++-- net/ipv6/route.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 0aa36b093013..2a6397714d70 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -5576,8 +5576,8 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) ip6_del_rt(rt); } if (ifp->rt) { - dst_hold(&ifp->rt->dst); - ip6_del_rt(ifp->rt); + if (dst_hold_safe(&ifp->rt->dst)) + ip6_del_rt(ifp->rt); } rt_genid_bump_ipv6(net); break; diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 908b71188c57..c52c51908881 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1366,8 +1366,8 @@ static void ip6_link_failure(struct sk_buff *skb) rt = (struct rt6_info *) skb_dst(skb); if (rt) { if (rt->rt6i_flags & RTF_CACHE) { - dst_hold(&rt->dst); - ip6_del_rt(rt); + if (dst_hold_safe(&rt->dst)) + ip6_del_rt(rt); } else if (rt->rt6i_node && (rt->rt6i_flags & RTF_DEFAULT)) { rt->rt6i_node->fn_sernum = -1; }