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

From: Al Viro
Date: Thu Sep 29 2022 - 15:35:08 EST


On Thu, Sep 29, 2022 at 12:05:32PM -0700, Linus Torvalds wrote:
> On Thu, Sep 29, 2022 at 12:00 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> >
> > Which is insane, especially since the entire problem is due to wanting
> > that directory to be different for different threads...
>
> Absolutely. This is all due to Apparmor (a) basing things on pathnames
> and (b) then getting those pathnames wrong.
>
> Which is why I'm just suggesting we short-circuit the path-name part,
> and not make this be a real symlink that actually walks a real path.
>
> The proc <pid> handling uses "readlink" to make it *look* like a
> symlink, but then "get_link" to actually look it up (and never walk it
> as a path).
>
> Something similar?

Apparmor takes mount+dentry and turns that into pathname. Then acts
upon the resulting string. *AFTER* the original had been resolved.
IOW, it doesn't see the symlink contents - only the location where the
entire thing ends up.

AFAICS, the only way to make it STFU is either
* fix the idiotic policy
or
* make the per-thread directory show up as /proc/<something>/net

As in "../.. from there lands you in /proc". Because that's what
apparmor does to generate the string it treats as the pathname...