From patchwork Fri Jun 16 17:47: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: 776920 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 3wq7D51W0Dz9s8Y for ; Sat, 17 Jun 2017 03:49:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cGzZ58ui"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668AbdFPRtX (ORCPT ); Fri, 16 Jun 2017 13:49:23 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35027 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511AbdFPRsa (ORCPT ); Fri, 16 Jun 2017 13:48:30 -0400 Received: by mail-pf0-f196.google.com with SMTP id s66so7558058pfs.2 for ; Fri, 16 Jun 2017 10:48:30 -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=cGzZ58uifAqZDrBLdwKeJMA5r9X8goZrq/4XHoegpC/G+fjbVxldvQFyI8OK2hF6SQ OO/pcPGbkgDhT73/F54BqlTeifbcMqw3HB9Lul7pUVY/4XmC19V3ZzGI8r3WXigZcxOO VXltxvt/7q+7HFMicR5tbsQhWuZLM2eTCmIAdFniYtil5+mXlPwySiulfBlZC+De2gI0 zIyHTYjVRSbKCscgy4cPg7TjYRyIqxmZXmqcmFOf7xNs/R4A/Fb9ZUBDXJEGtm1xHfyO BAt1ACb8SQ/bj1uGOT48A5yRgzjj6rFdocUyEtpRD5BCF1AKzcBjubCYfZLBz+Srmydo vr7w== 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=gPDNKXGaqOEl5k6Dz8ilBAvTEtEY8LnjB32akgX6Jpow5lFz9wDeQb7xavJytWSD49 A/l/TSezBvsH9AO5dLvZwvRfHssgg+5hIZtfw+LAs70RTl5wcNdSoi1m7/W2nQc2uB8n 8u3uQSIUOTMldJTJGjs+x78gXtNCbiw+u5A/grCHSibpqiOcnKlE2BOcYOu4+LgxqSUE iObCvLmCMMid1o3vERjgPMmBzrhSik8s9A8wAGb6aPi+XZmk6KXXAtrmvst4Uy8QWKNt yfkYkj5wzKxVmD+hCEugX9iUhII9ug+3HfKpH18JzQe417JB8hjxsfXGVcfBBJdRVpkq J4HA== X-Gm-Message-State: AKS2vOx3rf6Z6ziwEwDfGnfYhmuX+rI69AjjKMrS+LnadVAoSn3YFYuk wPYBlbqx/km7TWZr3U0= X-Received: by 10.84.208.102 with SMTP id f35mr14001200plh.53.1497635309806; Fri, 16 Jun 2017 10:48:29 -0700 (PDT) Received: from weiwan0.mtv.corp.google.com ([100.123.230.66]) by smtp.gmail.com with ESMTPSA id v62sm5292290pfb.124.2017.06.16.10.48.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 10:48:29 -0700 (PDT) From: Wei Wang To: David Miller , netdev@vger.kernel.org Cc: Eric Dumazet , Martin KaFai Lau , Wei Wang Subject: [PATCH net-next 12/21] ipv6: call dst_hold_safe() properly Date: Fri, 16 Jun 2017 10:47:35 -0700 Message-Id: <20170616174744.139688-13-tracywwnj@gmail.com> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170616174744.139688-1-tracywwnj@gmail.com> References: <20170616174744.139688-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; }