• Al Viro's avatar
    unix_bind_bsd(): move done_path_create() call after dealing with ->bindlock · 56c1731b
    Al Viro authored
    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: default avatarAl Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    56c1731b
af_unix.c 68.4 KB