From patchwork Fri Jun 16 17:47:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Wang X-Patchwork-Id: 776914 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 3wq7CZ1H0pz9s8N for ; Sat, 17 Jun 2017 03:48:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FpEQuQal"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752638AbdFPRs4 (ORCPT ); Fri, 16 Jun 2017 13:48:56 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:34653 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752595AbdFPRsy (ORCPT ); Fri, 16 Jun 2017 13:48:54 -0400 Received: by mail-pf0-f195.google.com with SMTP id d5so7560484pfe.1 for ; Fri, 16 Jun 2017 10:48:44 -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=FEgcO4bbkhe9Wtcs2ehKoH2s+Udej5g83Pnlf/r6yXU=; b=FpEQuQal4QIa3ia4u+sWUkIiL6ysuPhD58Lvm//wMTtzIFrz4lp9rZaPZotsXpxfS3 PINbX+uMqxYOP31Lu6A2H52/G139QlokquW00T6zAMKXzhZg1PIwaNxsyam1dwANDe5u bFKmTjpxUAciOM2C9ivKF+Aak73GySKpaZ7DWJf2sf3z5hk7TyAEK4UkqZUKunJbx0Ib yea+CLDuXufll98g9Q9se+fH95OnJuvZH39Z4eEGe87q/OhPTAcLHCgThVmjpcE3LFRK UOKPTtIppgFngTFfUaiaPXFS+8dt+knJl2+7yDouth8NdkxuJ2THqcsu3X7qEQNeQGN7 sthg== 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=FEgcO4bbkhe9Wtcs2ehKoH2s+Udej5g83Pnlf/r6yXU=; b=ugBpLuiynOCQ/82y8ZHrL1LalSLxCANihvmbgvRsdqYPgfx+4vziMKoSKXeRfUSbjF JK1si6tG6ro9cIvDojlOxXdHknPNAhCc1ymP4I3GAUylrWwlB8NrPcXurbVNE2BGj7hi dqFaktSxN84JgR04nZRlprQk7zAXr0gUMS9jcxsA+GZnmCzSpYaHHEtX/Arr1qHxAo7P lUwALuJ3Aa/lWvGZcXivjOS3/CY/dQlP/CUBFboCBEn2bkU/MazRc02NC6jYQ7nypZwz 9GQcmbuDiK10pHuMUEw63QBWGs6Iu86Fn1Jt7p0bp0Oj6X9i6QI86w+jgoguHrsqDnAY dnbw== X-Gm-Message-State: AKS2vOwItX9jpzbMf50dh3zNkOYsBfRq9bj+PCLrFWvefC5E7Ta5Kvsi Wi2yfATXDxYwng== X-Received: by 10.98.1.72 with SMTP id 69mr12285675pfb.124.1497635318590; Fri, 16 Jun 2017 10:48:38 -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.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jun 2017 10:48:37 -0700 (PDT) From: Wei Wang To: David Miller , netdev@vger.kernel.org Cc: Eric Dumazet , Martin KaFai Lau , Wei Wang Subject: [PATCH net-next 21/21] net: add debug atomic_inc_not_zero() in dst_hold() Date: Fri, 16 Jun 2017 10:47:44 -0700 Message-Id: <20170616174744.139688-22-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 This patch is meant to add a debug warning on the situation where dst is being held during its destroy phase. This could potentially cause double free issue on the dst. Signed-off-by: Wei Wang Acked-by: Martin KaFai Lau --- include/net/dst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/dst.h b/include/net/dst.h index d912b44d2dcb..f73611ec4017 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -251,7 +251,7 @@ static inline void dst_hold(struct dst_entry *dst) * __pad_to_align_refcnt declaration in struct dst_entry */ BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63); - atomic_inc(&dst->__refcnt); + WARN_ON(atomic_inc_not_zero(&dst->__refcnt) == 0); } static inline void dst_use(struct dst_entry *dst, unsigned long time)