Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp175814rwb; Tue, 4 Oct 2022 02:21:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM431ylMVcqp2lqUWIvIw9CAueDwdWXTVaz1B0OnC+jZh+qOClek7+X9EBX7Zb+yudFRYpQ7 X-Received: by 2002:a17:903:11c7:b0:178:afa2:43fd with SMTP id q7-20020a17090311c700b00178afa243fdmr26143987plh.126.1664875273769; Tue, 04 Oct 2022 02:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664875273; cv=none; d=google.com; s=arc-20160816; b=YrkV7Sojgds6N6YQGpdm8kS4o7RKGeYdWcwJZDEaFoQahIN2BuKF619JlfXXHMfU6+ nDLU5H7Z09/2nHlYsdMjysb1w5Uza6mqvgHi4KUV32Pma+byvaaptfPlru8EeidxEUQ2 H9mqT+RIcdBLrudjY4mXsfaCyze4ttIOAev4CqElEuDbeSLWvO7v8Z7C21QyZW9Yhct3 cxqw5kJgURTZ3fa4PfHGukDEHd6cc/E+4X2WJE5Pr8o8iZj0awGJNzm5yltxucx2b/Iq kPv2NRVwfWc/iE3x2dQ57FobE9iy5PG/JVQFuUwso/htn+02ObIobU3stVi9IEFW1yFv XjZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=mndqGqXh8QzilV+FPAzVMNDmbBBEcjG4oeNzFFQ5KlE=; b=GMwdqLI9kcLOaABLGPH95howDDdTbTVm1C2mrumb4NrGNKoZn1W+y7DZPgkrb7y3mu lzSlVGpox9YAQVfH3AutE4XGdjUsC1NDiUvKWGKrthGFRN//5kk7LrN50VsdV1e8HKY7 8lsgQ8ApMLP0MlMTZtidvdcV3AnEf01Ex4O9TVzBq7bZqAODpWWjUvkEeFd7ARjKrKUY nHc74GyT/lQ8tR/h1ozeYZsYqZIDTj6UeZ2FOfESnoXCSOrVRRiOshrvMNmCtIA8bumX /Moc+xTlK18Y/o3K3njpORVPosyGhx/KIW6UABMdtnBmx5gKjn+JtqoV5jhB6Fmy7EtI rtAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170903124b00b00176b7b8cf2esi13223622plh.586.2022.10.04.02.20.39; Tue, 04 Oct 2022 02:21:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbiJDIxx convert rfc822-to-8bit (ORCPT + 99 others); Tue, 4 Oct 2022 04:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230337AbiJDIxv (ORCPT ); Tue, 4 Oct 2022 04:53:51 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80866140F4 for ; Tue, 4 Oct 2022 01:53:50 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-190-cqLT9I1YPuuRISROdDhghw-1; Tue, 04 Oct 2022 09:53:41 +0100 X-MC-Unique: cqLT9I1YPuuRISROdDhghw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Tue, 4 Oct 2022 09:53:39 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.040; Tue, 4 Oct 2022 09:53:39 +0100 From: David Laight To: "'Eric W. Biederman'" CC: Linus Torvalds , Al Viro , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "Serge E. Hallyn" Subject: RE: [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Thread-Topic: [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Thread-Index: AQHY10qd381Lc0KOOEGaF1/0a4qSLq397Oxw Date: Tue, 4 Oct 2022 08:53:39 +0000 Message-ID: <8be364fd938a4ac9959b4c01120cac97@AcuMS.aculab.com> References: <871qrt4ymg.fsf@email.froward.int.ebiederm.org> <87ill53igy.fsf_-_@email.froward.int.ebiederm.org> <87a66g25wm.fsf@email.froward.int.ebiederm.org> <9bf5e96b383e4a979618cb0f729cb833@AcuMS.aculab.com> <87fsg4ygxc.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87fsg4ygxc.fsf@email.froward.int.ebiederm.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric W. Biederman > Sent: 03 October 2022 18:07 > > David Laight writes: > > > From: Eric W. Biederman ... > > Part of the problem is that changing the net namespace isn't > > enough, you also have to remount /sys - which isn't entirely > > trivial. > > Yes. That is actually a much more maintainable model. But it is still > imperfect. I was thinking about the proc/net directories when > I made my comment. Unlike proc where we have task ids there is nothing > in /proc that can do anything. > > > It might be possibly to mount a network namespace version > > of /sys on a different mountpoint - I've not tried very > > hard to do that. > > It is a bug if that doesn't work. The difficultly is picking the 'spell'. I think you need to run mount after switching to the namespace. But you don't want the unshare() that 'ip netns exec' does. So I think it needs a silly wrapper program. > >> > Notwithstanding the apparmor issues, /proc/net could actuall be > >> > a symlink to (say) /proc/net_namespaces/namespace_name with > >> > readlink returning the name based on the threads actual namespace. > >> > >> There really aren't good names for namespaces at the kernel level. As > >> one of their use cases is to make process migration possible between > >> machines. So any kernel level name would need to be migrated as well. > >> So those kernel level names would need a name in another namespace, > >> or an extra namespace would have to be created for those names. > > > > Network namespaces do seem to have names. > > Although I gave up working out how to change to a named network > > namespace from within the kernel (especially in a non-GPL module). > > Network namespaces have mount points. The mount points have names. > > It is just a matter of finding the right filesystem and calling > sys_rename(). I wanted to lookup a net namespace by name - so I could create a kernel socket in a namespace specified in configuration data. Not change the name of a namespace. I ended up only giving a few options - basically saving the namespace of code that called into the driver. (Harder in a non-gpl driver since you can't directly hold/release the namespace itself - fortunately you can create a socket!) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)