net: sock: move ->sk_shutdown out of bitfields.
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Wed, 18 May 2016 16:19:27 +0000 (19:19 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 20 May 2016 22:05:32 +0000 (18:05 -0400)
commitfc64869c48494a401b1fb627c9ecc4e6c1d74b0d
tree8db60382773d8a27d29cf2270a9778641c8b6354
parent911f6b1f57c48c9f379e6658e2e5198d84acdab3
net: sock: move ->sk_shutdown out of bitfields.

->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 <aryabinin@virtuozzo.com>
Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h