Re: [PATCH v4] net: sock: move ->sk_shutdown out of bitfields.

From: Eric Dumazet
Date: Wed May 18 2016 - 13:17:29 EST


On Wed, 2016-05-18 at 19:19 +0300, 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 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@xxxxxxxxxxxxx>
> Suggested-by: Hannes Frederic Sowa <hannes@xxxxxxxxxxxxxxxxxxx>
> ---

Acked-by: Eric Dumazet <edumazet@xxxxxxxxxx>