af_unix: split 'u->readlock' into two: 'iolock' and 'bindlock'
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Sep 2016 21:43:53 +0000 (14:43 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Sep 2016 20:29:29 +0000 (13:29 -0700)
commit6e1ce3c3451291142a57c4f3f6f999a29fb5b3bc
tree44c5431d3f3ee9b9cffe3415f0b359091f52efff
parent38f7bd94a97b542de86a2be9229289717e33a7a4
af_unix: split 'u->readlock' into two: 'iolock' and 'bindlock'

Right now we use the 'readlock' both for protecting some of the af_unix
IO path and for making the bind be single-threaded.

The two are independent, but using the same lock makes for a nasty
deadlock due to ordering with regards to filesystem locking.  The bind
locking would want to nest outside the VSF pathname locking, but the IO
locking wants to nest inside some of those same locks.

We tried to fix this earlier with commit c845acb324aa ("af_unix: Fix
splice-bind deadlock") which moved the readlock inside the vfs locks,
but that caused problems with overlayfs that will then call back into
filesystem routines that take the lock in the wrong order anyway.

Splitting the locks means that we can go back to having the bind lock be
the outermost lock, and we don't have any deadlocks with lock ordering.

Acked-by: Rainer Weikusat <rweikusat@cyberadapt.com>
Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/af_unix.h
net/unix/af_unix.c