Comment 12 for bug 1531747

Revision history for this message
Serge Hallyn (serge-hallyn) wrote : Re: [Bug 1531747] Re: overlay: mkdir fails if directory exists in lowerdir in a user namespace

Quoting Seth Forshee (<email address hidden>):
> I don't know why #2 is that much grosser than what's there now. It's

I didn't mean gross as in eeuw, I meant not fine-grained enough.

Because the capability will apply to inode permissions checks,
and we only want it to be used for the check authorizing the
writing of the trusted.overlay.opaque xattr.

> already only taking the cap for setting the xattr, and taking
> CAP_SYS_ADMIN in init_user_ns seems to be what it's really wanting to do

Maybe - that's what I'm not sure about. As you said earlier, in the
upstream code only an admin can do the actual mount. The fact that an
unpriv user can create the mount may change assumptions about the
underlying fs's.

> there. The difference now though is that before that capability would
> have been required to do the mount and now it isn't.

Right.

> If we were to use ns_capable, which namespace do we use?

I don't know. We're almost better off shipping a new version of
vfs_xattr() which is only for use by kernel writers.

If we had your patch we could maybe check against the sb->user_ns?

> current_user_ns? Then that check becomes worthless because any user can
> make a new namespace to bypass it. If we had the s_user_ns patches it

Quit saying in the next paragraph what I say in reply to the previous!

> might make sense to use that, but that probably doesn't solve the
> problem anyway since the lower mount was probably mounted in
> init_user_ns.

Good point, hadn't thought of that.