Re: [PATCH] net: af_unix: protect ->sk_shutdown change with lock_sock()
From: Hannes Frederic Sowa
Date: Wed May 18 2016 - 06:38:47 EST
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?
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