Re: [PATCH 3/4] proc: Point /proc/net at /proc/thread-self/net instead of /proc/self/net

From: Linus Torvalds
Date: Thu Sep 29 2022 - 15:01:53 EST


On Thu, Sep 29, 2022 at 11:50 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> What do you mean? Lookup on "net" in /proc returning what, exactly?

Returning the same directory as "thread-self/net", just not with a
symlink so that Apparmor doesn't get to mess things up..

> What would that dentry have for ->d_parent?

In a perfect world, I think it should act like a dynamic bind mount
(where the "dynamic" part is that thread-self part, and the parent
would be /proc.

That said, I think this is all a hack to deal with an Apparmor bug, so
I don't think we need perfect. Right now it's a symlink, so the parent
is the thread-self directory. I think that kind of magic jump would be
perfectly acceptable.

We have "magic jump" behavior in other /proc places, where the thing
*looks* like a symlink (ie readlink and friends just work), but the
lookup doesn't *actually* follow the symlink, it just looks things up
directly. IOW, all the /proc/<pid>/fd/<X> stuff.

So I think this would be just another case of that.

Linus