From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
lsf-pc@lists.linux-foundation.org,
"Christian Brauner" <christian@brauner.io>,
"Stéphane Graber" <stgraber@stgraber.org>
Subject: Re: [LSF TOPIC] beyond uidmapping, & towards a better security model
Date: Tue, 20 Feb 2024 22:53:58 -0500 [thread overview]
Message-ID: <bfbb1e9b521811b234f4f603c2616a9840da9ece.camel@HansenPartnership.com> (raw)
In-Reply-To: <qlmv2hjwzgnkmtvjpyn6zdnnmja3a35tx4nh6ldl23tkzh5reb@r3dseusgs3x6>
On Tue, 2024-02-20 at 19:25 -0500, Kent Overstreet wrote:
> On Mon, Feb 19, 2024 at 09:26:25AM -0500, James Bottomley wrote:
> > I would have to say that changing kuid for a string doesn't really
> > buy us anything except a load of complexity for no very real gain.
> > However, since the current kuid is u32 and exposed uid is u16 and
> > there is already a proposal to make use of this somewhat in the way
> > you envision,
>
> Got a link to that proposal?
I think this is the latest presentation on it:
https://fosdem.org/2024/schedule/event/fosdem-2024-3217-converting-filesystems-to-support-idmapped-mounts/
>
> > there might be a possibility to re-express kuid as an array
> > of u16s without much disruption. Each adjacent pair could
> > represent the owner at the top and the userns assigned uid
> > underneath. That would neatly solve the nesting problem the
> > current upper 16 bits proposal has.
>
> At a high level, there's no real difference between a variable length
> integer, or a variable length array of integers, or a string.
Right, so the advantage is the kernel already does an integer
comparison all over the place.
> But there's real advantages to getting rid of the string <-> integer
> identifier mapping and plumbing strings all the way through:
>
> - creating a new sub-user can be done with nothing more than the new
> username version of setuid(); IOW, we can start a new named
> subuser
> for e.g. firefox without mucking with _any_ system state or tables
>
> - sharing filesystems between machines is always a pita because
> usernames might be the same but uids never are - let's kill that
> off,
> please
>
> Doing anything as big as an array of integers is going to be a major
> compatibiltiy break anyways, so we might as well do it right.
I'm not really convinced it's right. Strings are trickier to handle
and compare than integer arrays and all of the above can be done by
either.
> Either way we're going to need a mapping to 16 bit uids for
> compatibility; doing this right gives userspace an incentive to get
> _off_ that compatibility layer so we're not dealing with that
> impedence mismatch forever.
Fundamentally we have a load of integer to pretty name things we use in
the kernel (protocol, port, ...). The point though is the kernel
doesn't need to know the pretty name, it deals with integers and user
space does the conversion.
> > However, neither proposal would get us out of the problem of mount
> > mapping because we'd have to keep the filesystem permission check
> > on the owning uid unless told otherwise.
>
> Not sure I follow?
Mounting a filesystem inside a userns can cause huge security problems
if we map fs root to inner root without the admin blessing it. Think
of binding /bin into the userns and then altering one of the root owned
binaries as inner root: if the permission check passes, the change
appears in system /bin.
> We're always going to need mount mapping, but if the mount mapping is
> just "usernames here get mapped to this subtree of the system
> username namespace", then that potentially simplifies things quite a
> bit - the mount mapping is no longer a _table_.
But what then is it? If you allow the user arbitrarily to assign
subuids, you can't trust them for the mapping to the fs uid. The
current newidmap/newgidmap are somewhat nasty but at least they're
controlled.
I did try a prototype where all we cared about was the root<->root
mapping, but a unix system has other uids that are privileged as well,
so it didn't solve the security problem.
> And it wouldn't have to be administrator assigned. Some administrator
> assignment might be required for the username <-> 16 bit uid mapping,
> but if those mappings are ephemeral (i.e. if we get filesystems
> persistently storing usernames, which is easy enough with xattrs)
> then that just becomes "reserve x range of the 16 bit uid space for
> ephemeral translations".
*if* the user names you're dealing with are all unprivileged. When we
have a mix of privileged and unprivileged users owning the files, the
problems begin.
James
next prev parent reply other threads:[~2024-02-21 3:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-17 20:56 Kent Overstreet
2024-02-17 22:31 ` Matthew Wilcox
2024-02-17 22:54 ` Kent Overstreet
2024-02-19 14:26 ` James Bottomley
2024-02-21 0:25 ` Kent Overstreet
2024-02-21 0:56 ` Stéphane Graber
2024-02-21 1:01 ` Kent Overstreet
2024-02-21 1:22 ` Matthew Wilcox
2024-02-21 2:07 ` Kent Overstreet
2024-02-21 2:15 ` NeilBrown
2024-02-29 8:51 ` Shyam Prasad N
2024-02-21 3:53 ` James Bottomley [this message]
2024-02-21 23:01 ` Kent Overstreet
2024-02-22 0:33 ` James Bottomley
2024-02-22 3:37 ` Kent Overstreet
2024-02-22 8:45 ` James Bottomley
2024-02-22 11:53 ` Kent Overstreet
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=bfbb1e9b521811b234f4f603c2616a9840da9ece.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=christian@brauner.io \
--cc=kent.overstreet@linux.dev \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsf-pc@lists.linux-foundation.org \
--cc=stgraber@stgraber.org \
/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®