Re: fs_context-related oops in mainline
From: Al Viro
Date: Fri Mar 15 2019 - 10:52:09 EST
On Fri, Mar 15, 2019 at 02:24:30PM +0000, David Howells wrote:
> Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> > - if (fc->user_ns)
> > - put_user_ns(fc->user_ns);
> > - fc->user_ns = get_user_ns(netns->user_ns);
> > + if (netns) {
> > + if (fc->user_ns)
> > + put_user_ns(fc->user_ns);
> > + fc->user_ns = get_user_ns(netns->user_ns);
> > + }
>
> This begs the question why is sysfs using the current network namespace's idea
> of the user namespace? Why not just use the one directly from current->cred?
Because it gives access to that netns guts, presumably. In a saner world sysfs
wouldn't _have_ netns-dependent bits; a separate per-netns filesystem would
contain those, and be mounted separately. And yes, we do have way too many
kinds of namespaces, along with filesystems that try to mix unrelated bits and
lead to something that looks like Cthulhu's arse after an unfortunate
accident with capsaicin suppository...