From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AC83C43334 for ; Fri, 1 Jul 2022 16:51:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232561AbiGAQvK (ORCPT ); Fri, 1 Jul 2022 12:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232271AbiGAQvI (ORCPT ); Fri, 1 Jul 2022 12:51:08 -0400 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42AB044A0F for ; Fri, 1 Jul 2022 09:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1656694267; x=1688230267; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tfj3iGiIsWe7DKnvvvYFy455A0ToOsY6ZWgQoFdSE3M=; b=odRhUf1PcGYAzt+zE+/y99l6H6iwjfLPMW4K4W07fUIGH6dmykmmb6RR S3WwBApQzuZvi6SXOu1gK1ZgNaU1ny+GlD0CowVdcs+M95C8aVWORzmUm ethT+oB7qpnzqWukVPAefLgpPySPpk7X11p1fFqgpDB8tD24LvFt5OC/V E=; X-IronPort-AV: E=Sophos;i="5.92,237,1650931200"; d="scan'208";a="217291790" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-iad-1box-d-0e176545.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP; 01 Jul 2022 16:50:52 +0000 Received: from EX13MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan2.iad.amazon.com [10.40.163.34]) by email-inbound-relay-iad-1box-d-0e176545.us-east-1.amazon.com (Postfix) with ESMTPS id 34AA1817B7; Fri, 1 Jul 2022 16:50:49 +0000 (UTC) Received: from EX13D04ANC001.ant.amazon.com (10.43.157.89) by EX13MTAUWB001.ant.amazon.com (10.43.161.207) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 1 Jul 2022 16:50:49 +0000 Received: from 88665a182662.ant.amazon.com (10.43.160.157) by EX13D04ANC001.ant.amazon.com (10.43.157.89) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Fri, 1 Jul 2022 16:50:46 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , Subject: Re: [PATCH v1 net-next] af_unix: Put a named socket in the global hash table. Date: Fri, 1 Jul 2022 09:50:39 -0700 Message-ID: <20220701165039.96869-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.43.160.157] X-ClientProxiedBy: EX13D17UWC002.ant.amazon.com (10.43.162.61) To EX13D04ANC001.ant.amazon.com (10.43.157.89) Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Date: Fri, 1 Jul 2022 18:36:21 +0200 > On Fri, Jul 1, 2022 at 9:25 AM Kuniyuki Iwashima wrote: > > > > Commit cf2f225e2653 ("af_unix: Put a socket into a per-netns hash > > table.") accidentally broke user API for named sockets. A named > > socket was able to connect() to a peer in the same mount namespace > > even if they were in different network namespaces. > > > > The commit put all sockets into each per-netns hash table. As a > > result, connect() to a socket in a different netns failed to find > > the peer and returned -ECONNREFUSED even when they had the same > > mount namespace. > > > > We can reproduce this issue by > > > > Console A: > > > > # python3 > > >>> from socket import * > > >>> s = socket(AF_UNIX, SOCK_STREAM, 0) > > >>> s.bind('test') > > >>> s.listen(32) > > > > Console B: > > > > # ip netns add test > > # ip netns exec test sh > > # python3 > > >>> from socket import * > > >>> s = socket(AF_UNIX, SOCK_STREAM, 0) > > >>> s.connect('test') > > > > I think this deserves a new test perhaps... Exactly. I will add a selftest in v2. Thank you.