From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751247AbcETWFz (ORCPT ); Fri, 20 May 2016 18:05:55 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:53012 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbcETWFy (ORCPT ); Fri, 20 May 2016 18:05:54 -0400 Date: Fri, 20 May 2016 18:05:52 -0400 (EDT) Message-Id: <20160520.180552.293412690344388226.davem@davemloft.net> To: aryabinin@virtuozzo.com Cc: hannes@stressinduktion.org, rweikusat@mobileactivedefense.com, edumazet@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] net: sock: move ->sk_shutdown out of bitfields. From: David Miller In-Reply-To: <1463588367-16310-1-git-send-email-aryabinin@virtuozzo.com> References: <1463585471.18194.123.camel@edumazet-glaptop3.roam.corp.google.com> <1463588367-16310-1-git-send-email-aryabinin@virtuozzo.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, 20 May 2016 15:05:53 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Ryabinin Date: Wed, 18 May 2016 19:19:27 +0300 > ->sk_shutdown bits share one bitfield with some other bits in sock struct, > such as ->sk_no_check_[r,t]x, ->sk_userlocks ... > sock_setsockopt() may write to these bits, while holding the socket lock. > > In case of AF_UNIX sockets, we change ->sk_shutdown bits while holding only > unix_state_lock(). So concurrent setsockopt() and shutdown() may lead > to corrupting these bits. > > Fix this by moving ->sk_shutdown bits out of bitfield into a separate byte. > This will not change the 'struct sock' size since ->sk_shutdown moved into > previously unused 16-bit hole. > > Signed-off-by: Andrey Ryabinin > Suggested-by: Hannes Frederic Sowa Looks good, applied and queued up for -stable. Thanks.