OSDN Git Service

unix_bind_bsd(): move done_path_create() call after dealing with ->bindlock
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 19 Jun 2021 03:50:31 +0000 (03:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jun 2021 19:28:49 +0000 (12:28 -0700)
commit56c1731b280dc71febf5df80fcac1923ea973ab8
treeed136ef1746c3fa21591d55acff0ef36c4c84294
parent71e6be6f7d2bada7099d79205779c4452d4fd35b
unix_bind_bsd(): move done_path_create() call after dealing with ->bindlock

Final preparations for doing unlink on failure past the successful
mknod.  We can't hold ->bindlock over ->mknod() or ->unlink(), since
either might do sb_start_write() (e.g. on overlayfs).  However, we
can do it while holding filesystem and VFS locks - doing
kern_path_create()
vfs_mknod()
grab ->bindlock
if u->addr had been set
drop ->bindlock
done_path_create
return -EINVAL
else
assign the address to socket
drop ->bindlock
done_path_create
return 0
would be deadlock-free.  Here we massage unix_bind_bsd() to that
form.  We are still doing equivalent transformations.

Next commit will *not* be an equivalent transformation - it will
add a call of vfs_unlink() before done_path_create() in "alread bound"
case.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/af_unix.c