[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZlZn/fcphsx8u/Ph@dread.disaster.area>
Date: Wed, 29 May 2024 09:25:49 +1000
From: Dave Chinner <david@...morbit.com>
To: "hch@...radead.org" <hch@...radead.org>
Cc: Jan Kara <jack@...e.cz>, Trond Myklebust <trondmy@...merspace.com>,
"chuck.lever@...cle.com" <chuck.lever@...cle.com>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"brauner@...nel.org" <brauner@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"alex.aring@...il.com" <alex.aring@...il.com>,
"cyphar@...har.com" <cyphar@...har.com>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
"jlayton@...nel.org" <jlayton@...nel.org>,
"amir73il@...il.com" <amir73il@...il.com>,
"linux-nfs@...r.kernel.org" <linux-nfs@...r.kernel.org>
Subject: Re: [PATCH RFC v2] fhandle: expose u64 mount id to
name_to_handle_at(2)
On Tue, May 28, 2024 at 03:56:43AM -0700, hch@...radead.org wrote:
> On Tue, May 28, 2024 at 12:11:52PM +0200, Jan Kara wrote:
> > So some fanotify users may use open_by_handle_at() and name_to_handle_at()
> > but we specifically designed fanotify to not depend on this mount id
> > feature of the API (because it wasn't really usable couple of years ago
> > when we were designing this with Amir). fanotify returns fsid + fhandle in
> > its events and userspace is expected to build a mapping of fsid ->
> > "whatever it needs to identify a filesystem" when placing fanotify marks.
> > If it wants to open file / directory where events happened, then this
> > usually means keeping fsid -> "some open fd on fs" mapping so that it can
> > then use open_by_handle_at() for opening.
>
> Which seems like another argument for my version of the handles to
> include the fsid. Although IIRC the fanotify fsid is only 64 bits which
> isn't really good entropy, so we might have to rev that as well.
I'm in agreement with Christoph that the filehandle needs to contain
the restricted scope information internally. I said that in response
to an earlier version of the patch here:
https://lore.kernel.org/linux-fsdevel/ZlPOd0p7AUn7JqLu@dread.disaster.area/
"If filehandles are going to be restricted to a specific container
(e.g. a single mount) so that less permissions are needed to open
the filehandle, then the filehandle itself needs to encode those
restrictions. Decoding the filehandle needs to ensure that the
opening context has permission to access whatever the filehandle
points to in a restricted environment. This will prevent existing
persistent, global filehandles from being used as restricted
filehandles and vice versa."
But no-one has bothered to reply or acknowledge my comments so I'll
point them out again and repeat: Filehandles generated by
the kernel for unprivileged use *must* be self describing and self
validating as the kernel must be able to detect and prevent
unprivelged users from generating custom filehandles that can be
used to access files outside the restricted scope of their
container.
-Dave.
--
Dave Chinner
david@...morbit.com
Powered by blists - more mailing lists