]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commit
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)
committerIshan Mittal <imittal@nvidia.com>
Fri, 6 Jan 2017 10:13:29 +0000 (15:43 +0530)
commit5ace8052348f5a8fb1b253150018b6a30b1c96b3
tree93518e5f861d1cf0822ff763ea2f6f6243631032
parent72566542176ebf4bb15c9bbc8134d4a809633e27
af_unix: split 'u->readlock' into two: 'iolock' and 'bindlock'

commit 6e1ce3c3451291142a57c4f3f6f999a29fb5b3bc upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/af_unix.h
net/unix/af_unix.c