On Tue, Feb 16, 2021 at 06:00:34PM +0000, Al Viro wrote: > Sigh... OK, so we want something like > user_path_create() > vfs_mknod() > created = true > grab bindlock > .... > drop bindlock > if failed && created > vfs_unlink() > done_path_create() > in unix_bind()... That would push ->bindlock all way down in the hierarchy, > so that should be deadlock-free, but it looks like that'll be fucking ugly ;-/ > > Let me try and play with that a bit, maybe it can be massaged to something > relatively sane... OK... Completely untested series follows. Preliminary massage in first 6 patches, then actual "add cleanup on failure", then minor followup cleanup. af_unix: take address assignment/hash insertion into a new helper unix_bind(): allocate addr earlier unix_bind(): separate BSD and abstract cases unix_bind(): take BSD and abstract address cases into new helpers fold unix_mknod() into unix_bind_bsd() unix_bind_bsd(): move done_path_create() call after dealing with ->bindlock unix_bind_bsd(): unlink if we fail after successful mknod __unix_find_socket_byname(): don't pass hash and type separately Branch is in git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git #misc.af_unix, individual patches in followups