Received: by 10.192.165.148 with SMTP id m20csp992805imm; Sat, 5 May 2018 02:30:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZovGbMIt5VBwqy7mNgt6UilEeTZ/e+CRglvWa9OH7w3NmFIE2DWM9b3kOknfQAw/ScvEfGK X-Received: by 2002:a63:942:: with SMTP id 63-v6mr25005735pgj.103.1525512651581; Sat, 05 May 2018 02:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525512651; cv=none; d=google.com; s=arc-20160816; b=wDPWzxE6iKiVWIbrI0E3GUEgi+vs6lwQQEOrUUfOuzJ64vmMZJplZsvsJPABdYDbdJ O4p/l6/fYGqFhQTW/Q/edej1IvmEj9d1ERaY12sEz5My8JpzYHuZ8H8yJJUwGvPMLJzV QuIVL2pwIYCMUfEN6b/FpqOgs1BVTVYY46qknrxhvsVVIxjy1QR6m/Qo5FSX2o1Mg6ya OL0szWr8sKP66tPkKPtc7cTB4V15xZHR8ZqVxDyXpL7YWOaJyR4peAkRojtrm14oU70G F7axdVCaEhwkBB/3uwl5R9EFcq3Yw2gOEMesifNmjkk+qHE7s4Vtano+iwy2OU2glX/I woHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=Ls75L6RsnZCj0Tru7lFJrXQX0SaoBCboRcttTt5g5S0=; b=iiisVYlswq+vJEbHQ/8gJV0bCCRGVtgRhjpnzQQvauzemIf1z5UhQrLat/h5BvrL2T ZDUt/JtGQ9+SFPLXlI1PFx3tfoJWl8LveXqXneMsPmfrtJFHWsQvNDszycBzhQ/Mg9C1 bFGhgW2V8Mipgj7ifU/NwUV/EzaMalzz+ww5wqA9N9QiOZJ7+bncp32+wdVGnIhh0AaZ jglJ7KCjEe0vdd7uO0t15HhBMeyDJb/ZR4OS0niN0gkvZ20vCDkVyP3Gjwyn48457hs8 9mRo+O/FO0i2wZs/Q3by1YiNwMC5CrlJD5uabRgwjbdzaltG9dT4Co5H/NUvJuJ/L6O8 65nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s16-v6si2619011pgo.89.2018.05.05.02.30.36; Sat, 05 May 2018 02:30:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751796AbeEEJ3N (ORCPT + 99 others); Sat, 5 May 2018 05:29:13 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:35404 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751085AbeEEJ3M (ORCPT ); Sat, 5 May 2018 05:29:12 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1fEtV5-0001ni-Gd; Sat, 05 May 2018 17:29:07 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1fEtV5-0005z3-D1; Sat, 05 May 2018 17:29:07 +0800 Date: Sat, 5 May 2018 17:29:07 +0800 From: Herbert Xu To: NeilBrown Cc: Thomas Graf , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/8] rhashtable: fix race in nested_table_alloc() Message-ID: <20180505092907.2qa3scf6bzvubmtt@gondor.apana.org.au> References: <152540595840.18473.11298241115621799037.stgit@noble> <152540605432.18473.11813271279255176724.stgit@noble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152540605432.18473.11813271279255176724.stgit@noble> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 04, 2018 at 01:54:14PM +1000, NeilBrown wrote: > If two threads run nested_table_alloc() at the same time > they could both allocate a new table. > Best case is that one of them will never be freed, leaking memory. > Worst case is hat entry get stored there before it leaks, > and the are lost from the table. > > So use cmpxchg to detect the race and free the unused table. > > Fixes: da20420f83ea ("rhashtable: Add nested tables") > Cc: stable@vger.kernel.org # 4.11+ > Signed-off-by: NeilBrown What about the spinlock that's meant to be held around this operation? Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt