From: David Laight <David.Laight@ACULAB.COM>
To: "'Eric W. Biederman'" <ebiederm@xmission.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"Serge E. Hallyn" <serge@hallyn.com>
Subject: RE: [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace
Date: Tue, 4 Oct 2022 08:53:39 +0000 [thread overview]
Message-ID: <8be364fd938a4ac9959b4c01120cac97@AcuMS.aculab.com> (raw)
In-Reply-To: <87fsg4ygxc.fsf@email.froward.int.ebiederm.org>
From: Eric W. Biederman
> Sent: 03 October 2022 18:07
>
> David Laight <David.Laight@ACULAB.COM> 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)
next prev parent reply other threads:[~2022-10-04 8:53 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 15:22 [PATCH 3/4] proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net David Laight
2022-09-29 18:21 ` Linus Torvalds
2022-09-29 18:50 ` Al Viro
2022-09-29 19:00 ` Al Viro
2022-09-29 19:05 ` Linus Torvalds
2022-09-29 19:34 ` Al Viro
2022-09-29 21:13 ` Linus Torvalds
2022-09-29 21:21 ` Al Viro
2022-09-29 21:27 ` Al Viro
2022-09-29 21:31 ` Linus Torvalds
2022-09-29 21:15 ` Al Viro
2022-09-29 21:29 ` Linus Torvalds
2022-09-29 22:14 ` Eric W. Biederman
2022-09-29 22:48 ` [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Eric W. Biederman
2022-09-29 23:38 ` Al Viro
2022-09-30 3:19 ` kernel test robot
2022-09-30 6:07 ` kernel test robot
2022-09-30 9:30 ` David Laight
2022-09-30 16:17 ` Eric W. Biederman
2022-09-30 21:28 ` David Laight
2022-10-01 23:11 ` Al Viro
2022-10-03 9:36 ` David Laight
2022-10-03 14:03 ` Al Viro
2022-10-03 17:07 ` Eric W. Biederman
2022-10-03 18:49 ` Al Viro
2022-10-04 8:53 ` David Laight [this message]
2022-10-05 13:10 ` [proc] 5336f1902b: BUG:KASAN:global-out-of-bounds_in_memchr kernel test robot
2022-09-29 19:00 ` [PATCH 3/4] proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net Linus Torvalds
2022-09-30 14:01 [CFT][PATCH] proc: Update /proc/net to point at the accessing threads network namespace Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8be364fd938a4ac9959b4c01120cac97@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®