From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752032AbbIXTLs (ORCPT ); Thu, 24 Sep 2015 15:11:48 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:53275 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750799AbbIXTLq (ORCPT ); Thu, 24 Sep 2015 15:11:46 -0400 Date: Thu, 24 Sep 2015 12:11:42 -0700 (PDT) Message-Id: <20150924.121142.870602292135442487.davem@davemloft.net> To: herbert@gondor.apana.org.au Cc: tj@kernel.org, cwang@twopensource.com, tom@herbertland.com, kafai@fb.com, kernel-team@fb.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, torvalds@linux-foundation.org, jiri@resnulli.us, nicolas.dichtel@6wind.com, tgraf@suug.ch, sfeldma@gmail.com Subject: Re: [PATCH v2] netlink: Replace rhash_portid with bound From: David Miller In-Reply-To: <20150922033856.GA7851@gondor.apana.org.au> References: <20150921133415.GA1740@gondor.apana.org.au> <20150921182022.GB13263@mtj.duckdns.org> <20150922033856.GA7851@gondor.apana.org.au> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 24 Sep 2015 12:11:46 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Herbert Xu Date: Tue, 22 Sep 2015 11:38:56 +0800 > The commit 1f770c0a09da855a2b51af6d19de97fb955eca85 ("netlink: > Fix autobind race condition that leads to zero port ID") created > some new races that can occur due to inconcsistencies between the > two port IDs. > > Tejun is right that a barrier is unavoidable. Therefore I am > reverting to the original patch that used a boolean to indicate > that a user netlink socket has been bound. > > Barriers have been added where necessary to ensure that a valid > portid and the hashed socket is visible. > > I have also changed netlink_insert to only return EBUSY if the > socket is bound to a portid different to the requested one. This > combined with only reading nlk->bound once in netlink_bind fixes > a race where two threads that bind the socket at the same time > with different port IDs may both succeed. > > Fixes: 1f770c0a09da ("netlink: Fix autobind race condition that leads to zero port ID") > Reported-by: Tejun Heo > Reported-by: Linus Torvalds > Signed-off-by: Herbert Xu I've decided to apply this and queue it up for -stable. Thanks everyone.