netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Ryabinin <aryabinin@virtuozzo.com>
To: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: Rainer Weikusat <rweikusat@mobileactivedefense.com>,
	Eric Dumazet <edumazet@google.com>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] net: af_unix: protect ->sk_shutdown change with lock_sock()
Date: Wed, 18 May 2016 14:23:27 +0300	[thread overview]
Message-ID: <573C50AF.6090301@virtuozzo.com> (raw)
In-Reply-To: <a070f6f7-ed85-c909-ce8b-748210402211@stressinduktion.org>



On 05/18/2016 01:38 PM, Hannes Frederic Sowa wrote:
> On 18.05.2016 12:14, Andrey Ryabinin wrote:
>> ->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 that by protecting writes to ->sk_shutdown with lock_sock()
> 
> Is it possible to move sk_shutdown out of the bitfields? Maybe a whole
> which suites is available somewhere?
> 

Agreed. I see two possible 16-bit holes - one after 'sk_gso_max_segs'
and one more after 'sk_tsflags'.


> af_unix doesn't depend on the socket locks anywhere and it would keep
> locking much easier if we only depend on the state lock.
> 
> Bye,
> Hannes
> 
> 

  reply	other threads:[~2016-05-18 11:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-18 10:14 [PATCH] net: af_unix: protect ->sk_shutdown change with lock_sock() Andrey Ryabinin
2016-05-18 10:38 ` Hannes Frederic Sowa
2016-05-18 11:23   ` Andrey Ryabinin [this message]
2016-05-18 12:03   ` [PATCH v2] net: sock: move ->sk_shutdown out of bitfields Andrey Ryabinin
2016-05-18 13:03     ` Eric Dumazet
2016-05-18 13:14       ` Andrey Ryabinin
2016-05-18 13:49         ` Eric Dumazet
2016-05-18 14:36       ` [PATCH v3] " Andrey Ryabinin
2016-05-18 15:31         ` Eric Dumazet
2016-05-18 16:19           ` [PATCH v4] " Andrey Ryabinin
2016-05-18 17:17             ` Eric Dumazet
2016-05-20 22:05             ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=573C50AF.6090301@virtuozzo.com \
    --to=aryabinin@virtuozzo.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hannes@stressinduktion.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rweikusat@mobileactivedefense.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).