Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754760AbcJLMjF (ORCPT ); Wed, 12 Oct 2016 08:39:05 -0400 Received: from mail.kernel.org ([198.145.29.136]:42732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbcJLMfH (ORCPT ); Wed, 12 Oct 2016 08:35:07 -0400 From: lizf@kernel.org To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Eric Dumazet , "David S. Miller" , Zefan Li Subject: [PATCH 3.4 010/125] net: fix a race in dst_release() Date: Wed, 12 Oct 2016 20:32:06 +0800 Message-Id: <1476275641-4697-10-git-send-email-lizf@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476275600-4626-1-git-send-email-lizf@kernel.org> References: <1476275600-4626-1-git-send-email-lizf@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1147 Lines: 39 From: Eric Dumazet 3.4.113-rc1 review patch. If anyone has any objections, please let me know. ------------------ commit d69bbf88c8d0b367cf3e3a052f6daadf630ee566 upstream. Only cpu seeing dst refcount going to 0 can safely dereference dst->flags. Otherwise an other cpu might already have freed the dst. Fixes: 27b75c95f10d ("net: avoid RCU for NOCACHE dst") Reported-by: Greg Thelen Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller [lizf: Backported to 3.4: adjust context] Signed-off-by: Zefan Li --- net/core/dst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dst.c b/net/core/dst.c index 43d94ce..54ba1eb 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -272,7 +272,7 @@ void dst_release(struct dst_entry *dst) newrefcnt = atomic_dec_return(&dst->__refcnt); WARN_ON(newrefcnt < 0); - if (unlikely(dst->flags & DST_NOCACHE) && !newrefcnt) { + if (!newrefcnt && unlikely(dst->flags & DST_NOCACHE)) { dst = dst_destroy(dst); if (dst) __dst_free(dst); -- 1.9.1