From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-efi@vger.kernel.org,
Jeremy Kerr <jk@ozlabs.org>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 1/2] efivarfs: prevent setting of zero size on the inodes in the cache
Date: Sun, 19 Jan 2025 11:48:03 -0500 [thread overview]
Message-ID: <e4e0dc96752c33c6ff0e07165467c35a350b23c5.camel@HansenPartnership.com> (raw)
In-Reply-To: <CAMj1kXEQVJ6kqGFqXT9sqdNX9Juc7CiWa-4q+J7D=YucFimrqA@mail.gmail.com>
On Sun, 2025-01-19 at 17:32 +0100, Ard Biesheuvel wrote:
> On Sun, 19 Jan 2025 at 16:00, James Bottomley
> <James.Bottomley@hansenpartnership.com> wrote:
> >
> > Current efivarfs uses simple_setattr which allows the setting of
> > any
> > size in the inode cache. This is wrong because a zero size file is
> > used to indicate an "uncommitted" variable, so by simple means of
> > truncating the file (as root) any variable may be turned to look
> > like
> > it's uncommitted. Fix by adding an efivarfs_setattr routine which
> > does not allow updating of the cached inode size (which now only
> > comes
> > from the underlying variable).
> >
> > Signed-off-by: James Bottomley
> > <James.Bottomley@HansenPartnership.com>
> > ---
> > fs/efivarfs/inode.c | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> > index ec23da8405ff..a4a6587ecd2e 100644
> > --- a/fs/efivarfs/inode.c
> > +++ b/fs/efivarfs/inode.c
> > @@ -187,7 +187,24 @@ efivarfs_fileattr_set(struct mnt_idmap *idmap,
> > return 0;
> > }
> >
> > +/* copy of simple_setattr except that it doesn't do i_size updates
> > */
> > +static int efivarfs_setattr(struct mnt_idmap *idmap, struct dentry
> > *dentry,
> > + struct iattr *iattr)
> > +{
> > + struct inode *inode = d_inode(dentry);
> > + int error;
> > +
> > + error = setattr_prepare(idmap, dentry, iattr);
> > + if (error)
> > + return error;
> > +
> > + setattr_copy(idmap, inode, iattr);
> > + mark_inode_dirty(inode);
> > + return 0;
> > +}
> > +
> > static const struct inode_operations
> > efivarfs_file_inode_operations = {
> > .fileattr_get = efivarfs_fileattr_get,
> > .fileattr_set = efivarfs_fileattr_set,
> > + .setattr = efivarfs_setattr,
> > };
>
> Is it sufficient to just ignore inode size changes?
Yes, as far as my testing goes.
> Should we complain about this instead?
I don't think so because every variable write (at least from the shell)
tends to start off with a truncation so we'd get a lot of spurious
complaints.
Regards,
James
next prev parent reply other threads:[~2025-01-19 16:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-19 14:59 [PATCH 0/2] efivarfs: fix ability to mimic uncommitted variables James Bottomley
2025-01-19 14:59 ` [PATCH 1/2] efivarfs: prevent setting of zero size on the inodes in the cache James Bottomley
2025-01-19 16:32 ` Ard Biesheuvel
2025-01-19 16:48 ` James Bottomley [this message]
2025-01-19 16:52 ` Ard Biesheuvel
2025-01-19 14:59 ` [PATCH 2/2] selftests/efivarfs: add check for disallowing file truncation James Bottomley
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=e4e0dc96752c33c6ff0e07165467c35a350b23c5.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=jk@ozlabs.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--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