From: Dave Chinner <david@fromorbit.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Christoph Hellwig <hch@infradead.org>,
Eric Sandeen <sandeen@redhat.com>,
"linux-xfs@vger.kernel.org" <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs: allow SECURE namespace xattrs to use reserved pool
Date: Tue, 23 Jul 2024 08:45:43 +1000 [thread overview]
Message-ID: <Zp7hF6hjonHBt7wp@dread.disaster.area> (raw)
In-Reply-To: <da41c7f5-8542-4b8e-9e98-2c33a74ca1a9@sandeen.net>
On Mon, Jul 22, 2024 at 10:05:03AM -0500, Eric Sandeen wrote:
> On 7/22/24 9:41 AM, Christoph Hellwig wrote:
> > On Fri, Jul 19, 2024 at 05:48:53PM -0500, Eric Sandeen wrote:
> >> xfs_attr_sethash(args);
> >>
> >> - return xfs_attr_set(args, op, args->attr_filter & XFS_ATTR_ROOT);
> >> + rsvd = args->attr_filter & (XFS_ATTR_ROOT | XFS_ATTR_SECURE);
> >> + return xfs_attr_set(args, op, rsvd);
> >
> > This looks fine, although I'd probably do without the extra local
> > variable. More importantly though, please write a comment documenting
> > why we are dipping into the reserved pool here. We should have had that
> > since the beginning, but this is a better time than never.
> >
> >
>
> Ok, I thought the local var was a little prettier but *shrug* can do it
> either way.
>
> To be honest I'm not sure why it was done for ROOT; dchinnner mentioned
> something about DMAPI requirements, long ago...
Because the xattrs created with inode allocation are not atomic
(which they could be now because parent pointers added the
infrastructure to add xattrs atomically in the create transaction),
stuff like ACLs, security xattrs and, historically, DMAPI xattrs
could fail to be created when the inode was allocated.
For DMAPI/DMF, this was a big issue if the xattr creation got ENOSPC
or the system crashed between inode creation (i.e the DMAPI CREATE
notification being processed by DMF) and the xattr being written on
the newly allocated inode. This would leave leave "untracked" inodes
in the filesystem, and the only way DMF could discover inodes
lacking in DMAPI xattrs was to run a full filesystem DMAPI-bulkstat
scan to synchronise the filesystem state with the DMF database held
in userspace. When you're tracking hundreds of millions to billions
of inodes, being forced to do a full fs inode scan after crashes or
ENOSPC before everything works properly again is, well, kinda
annoying.
Similar issues afflicted Trix (Trusted Irix) where security xattrs
(such as ACLs) went missing on crash or ENOSPC. On Irix, they were
stored in the XFS_ATTR_ROOT namespace, and the use of reserved block
space for XFS_ATTR_ROOT was introduced in 1997 on Irix.
commit 32d7e9a0d0fbca91a3d036c8518a87e10abfafb3
Author: gnuss <gnuss>
Date: Fri Dec 19 19:35:42 1997 +0000
pv: 553766 rv: lord@cray.com
Add reserved flag param to routines in block allocation call sequence
This commit contains just the addition of XFS_TRANS_RESERVE for
XFS_ATTR_ROOT xattrs. Nothing else used it - this was specically a
fix for ACL/DMAPI xattr creation at ENOSPC....
However, ACL support on linux, and hence XFS_ATTR_SECURE, didn't
exist until 2004:
commit af80e14283d9475582dfb2d91395b674b9827fa8
Author: Nathan Scott <nathans@sgi.com>
Date: Thu Jan 29 03:56:41 2004 +0000
Add the security extended attributes namespace.
This added the XFS_ATTR_SECURE namespace because ACLs are in a
different xattr namespace in Linux (i.e. TRUSTED -> XFS_ATTR_ROOT,
SECURITY -> XFS_ATTR_SECURE), but the xattr set/change code never
added the XFS_ATTR_SECURE flag to the XFS_TRANS_RESERVE case.
It wasn't until 2007 that we started to use the reserve block pool
for other ENOSPC avoidance cases (like indirect delalloc BMBT block
reservation exhaustion in writeback) here:
commit bdebc6a4aca2ac056b8174f5b6a3bf27b28f6a5d
Author: Dave Chinner <dgc@sgi.com>
Date: Fri Jun 8 16:03:59 2007 +0000
Prevent ENOSPC from aborting transactions that need to succeed
So, essentially, for the first 10 years of it's life,
XFS_TRANS_RESERVE was used supposed to be to prevent ENOSPC at inode
creation for security and trusted xattrs....
> It seems reasonable, and it's been there forever but also not
> obviously required, AFAICT.
In hindsight, it looks to me like this was an oversight made back
in 2004 when XFS_ATTR_SECURE was added to linux for security
xattrs. As Christoph says: "it should have been there since the
beginning".
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2024-07-22 22:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 22:48 [PATCH] xfs: allow SECURE namespace xattrs to use reserved pool Eric Sandeen
2024-07-22 14:41 ` Christoph Hellwig
2024-07-22 15:05 ` Eric Sandeen
2024-07-22 15:11 ` Christoph Hellwig
2024-07-22 16:43 ` [External] : " mark.tinguely
2024-07-22 22:45 ` Dave Chinner [this message]
2024-07-22 19:25 ` [PATCH V2] xfs: allow SECURE namespace xattrs to use reserved block pool Eric Sandeen
2024-07-22 23:05 ` Dave Chinner
2024-07-23 14:59 ` [PATCH V3] " Eric Sandeen
2024-07-23 16:52 ` Darrick J. Wong
2024-07-23 16:56 ` Christoph Hellwig
2024-07-23 17:26 ` [PATCH V4] " Eric Sandeen
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=Zp7hF6hjonHBt7wp@dread.disaster.area \
--to=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=sandeen@sandeen.net \
/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