Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20466C2B9F4 for ; Sat, 19 Jun 2021 03:48:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF408611CC for ; Sat, 19 Jun 2021 03:48:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231295AbhFSDuz (ORCPT ); Fri, 18 Jun 2021 23:50:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbhFSDuy (ORCPT ); Fri, 18 Jun 2021 23:50:54 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AEF5C061574 for ; Fri, 18 Jun 2021 20:48:39 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1luRyE-009qXt-0u; Sat, 19 Jun 2021 03:48:34 +0000 Date: Sat, 19 Jun 2021 03:48:34 +0000 From: Al Viro To: netdev@vger.kernel.org Cc: David Miller Subject: [PATCHSET] AF_UNIX bind(2) cleanup on failures after mknod Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Failures in unix_bind() coming after we'd created a socket node in filesystem are possible and can leave an unpleasant mess behind. That had been reported back in February by Denis Kirjanov, but his proposed solution had holes. This is a rebase of the series I'd ended up with back then; I'd prefer to have it go through the regular net.git path. 8 commits total, preliminary massage in the first 6, the fix is #7 and #8 is a minor followup cleanup. Branch is based at net.git/master, lives in vfs.git #misc.af_unix. Individual patches in followups. Al Viro (8): 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 net/unix/af_unix.c | 188 +++++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 92 deletions(-)