From: Dave Chinner <david@fromorbit.com>
To: Jan Kara <jack@suse.cz>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Hongbo Li <lihongbo22@huawei.com>,
viro@zeniv.linux.org.uk, gnoack@google.com, mic@digikod.net,
linux-fsdevel@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: Re: [RFC PATCH] fs: obtain the inode generation number from vfs directly
Date: Thu, 29 Aug 2024 23:34:50 +1000 [thread overview]
Message-ID: <ZtB4+sMr8Vbcs9VD@dread.disaster.area> (raw)
In-Reply-To: <20240828155528.77lz5l7pmwj5sgsc@quack3>
On Wed, Aug 28, 2024 at 05:55:28PM +0200, Jan Kara wrote:
> On Wed 28-08-24 15:38:49, Dave Chinner wrote:
> > > instead of using name_to_handle_at, which is why it's dangerous to
> > > implement GETVERSION for everyone without checking if i_generation makes
> > > sense.
> >
> > Yup. If you have predictable generation numbers then it's trivial to
> > guess filehandles once you know the inode number. Exposing
> > generation numbers to unprivileged users allows them to determine if
> > the generation numbers are predictable. Determining patterns is
> > often as simple as a loop doing open(create); get inode number +
> > generation; unlink().
>
> As far as VFS goes, we have always assumed that a valid file handles can be
> easily forged by unpriviledged userspace and hence all syscalls taking file
> handle are gated by CAP_DAC_READ_SEARCH capability check. That means
> userspace can indeed create a valid file handle but unless the process has
> sufficient priviledges to crawl the whole filesystem, VFS will not allow it
> to do anything special with it.
Yup.
The issue that was raised back in ~2008 was to do with rogue
machines on the network being able to trivially spoof NFS
filehandles to bypass directory access permission checks on the
server side. Once the generation numbers are randomised, this sort
of attack is easily detected as the ESTALE counter on the server
side goes through the roof...
> I don't know what XFS interfaces use file handles and what are the
> permission requirements there but effectively relying on a 32-bit cookie
> value for security seems like a rather weak security these days to me...
It's always been CAP_SYS_ADMIN for local filehandle interfaces.
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-08-29 13:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 1:41 [RFC PATCH] fs: obtain the inode generation number from vfs directly Hongbo Li
2024-08-27 2:13 ` Darrick J. Wong
2024-08-27 2:32 ` Hongbo Li
2024-08-27 5:37 ` Darrick J. Wong
2024-08-27 9:22 ` Christian Brauner
2024-08-27 17:11 ` Darrick J. Wong
2024-08-28 2:16 ` Hongbo Li
2024-08-28 3:44 ` Theodore Ts'o
2024-08-28 5:38 ` Dave Chinner
2024-08-28 15:55 ` Jan Kara
2024-08-29 1:46 ` Darrick J. Wong
2024-08-29 13:34 ` Dave Chinner [this message]
2024-08-27 2:53 ` Matthew Wilcox
2024-08-27 3:07 ` Hongbo Li
2024-08-28 4:27 ` Dave Chinner
2024-08-28 16:36 ` Tavian Barnes
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=ZtB4+sMr8Vbcs9VD@dread.disaster.area \
--to=david@fromorbit.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=lihongbo22@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=viro@zeniv.linux.org.uk \
/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