From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754099AbdEZSYI (ORCPT ); Fri, 26 May 2017 14:24:08 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:43194 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753907AbdEZSYH (ORCPT ); Fri, 26 May 2017 14:24:07 -0400 Date: Fri, 26 May 2017 14:24:05 -0400 (EDT) Message-Id: <20170526.142405.1523981438362847832.davem@davemloft.net> To: xiaolou4617@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: llc: add lock_sock in llc_ui_bind to avoid a race condition From: David Miller In-Reply-To: <1495692438-9781-1-git-send-email-xiaolou4617@gmail.com> References: <1495692438-9781-1-git-send-email-xiaolou4617@gmail.com> 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]); Fri, 26 May 2017 10:42:32 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lin Zhang Date: Thu, 25 May 2017 14:07:18 +0800 > There is a race condition in llc_ui_bind if two or more processes/threads > try to bind a same socket. > > If more processes/threads bind a same socket success that will lead to > two problems, one is this action is not what we expected, another is > will lead to kernel in unstable status or oops(in my simple test case, > cause llc2.ko can't unload). > > The current code is test SOCK_ZAPPED bit to avoid a process to > bind a same socket twice but that is can't avoid more processes/threads > try to bind a same socket at the same time. > > So, add lock_sock in llc_ui_bind like others, such as llc_ui_connect. > > Signed-off-by: Lin Zhang Applied, thank you.