public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: linux-fsdevel@vger.kernel.org, linux-efi@vger.kernel.org,
	Ard Biesheuvel <ardb@kernel.org>, Jeremy Kerr <jk@ozlabs.org>,
	Christian Brauner <brauner@kernel.org>
Subject: Re: [PATCH v2 6/6] efivarfs: fix error on write to new variable leaving remnants
Date: Thu, 16 Jan 2025 18:59:50 +0000	[thread overview]
Message-ID: <20250116185950.GL1977892@ZenIV> (raw)
In-Reply-To: <1d9e199d1b518a6661dee197bc767b2272acb318.camel@HansenPartnership.com>

On Thu, Jan 16, 2025 at 01:54:44PM -0500, James Bottomley wrote:
> On Thu, 2025-01-16 at 18:45 +0000, Al Viro wrote:
> > On Mon, Jan 06, 2025 at 06:35:25PM -0800, James Bottomley wrote:
> > 
> > > +       inode_lock(inode);
> > > +       if (d_unhashed(file->f_path.dentry)) {
> > > +               /*
> > > +                * file got removed; don't allow a set.  Caused by
> > > an
> > > +                * unsuccessful create or successful delete write
> > > +                * racing with us.
> > > +                */
> > > +               bytes = -EIO;
> > > +               goto out;
> > > +       }
> > 
> > Wouldn't the check for zero ->i_size work here?  Would be easier to
> > follow...
> 
> Unfortunately not.  The pathway for creating a variable involves a call
> to efivarfs_create() (create inode op) first, which would in itself
> create a zero length file, then a call to efivarfs_file_write(), so if
> we key here on zero length we'd never be able to create new variables.
> 
> The idea behind the check is that delete could race with write and if
> so, we can't resurrect the variable once it's been unhashed from the
> directory, so we need to error out at that point.

D'oh...  Point, but it still feels as if you are misplacing the object
state here ;-/

OK, so we have
	* created, open but yet to be written into
	* live
	* removed

Might be better off with explicit state in efivar_entry...

  reply	other threads:[~2025-01-16 18:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-07  2:35 [PATCH v2 0/6] convert efivarfs to manage object data correctly James Bottomley
2025-01-07  2:35 ` [PATCH v2 1/6] efivarfs: remove unused efi_varaible.Attributes and .kobj James Bottomley
2025-01-07  2:35 ` [PATCH v2 2/6] efivarfs: add helper to convert from UC16 name and GUID to utf8 name James Bottomley
2025-01-07  2:35 ` [PATCH v2 3/6] efivarfs: make variable_is_present use dcache lookup James Bottomley
2025-01-07  2:35 ` [PATCH v2 4/6] efivarfs: move freeing of variable entry into evict_inode James Bottomley
2025-01-16 18:36   ` Al Viro
2025-01-16 19:05     ` James Bottomley
2025-01-16 22:13       ` James Bottomley
2025-01-19 14:50         ` Ard Biesheuvel
2025-01-19 14:57           ` James Bottomley
2025-01-19 16:31             ` Ard Biesheuvel
2025-01-19 16:46               ` James Bottomley
2025-01-07  2:35 ` [PATCH v2 5/6] efivarfs: remove unused efivarfs_list James Bottomley
2025-01-16 18:42   ` Al Viro
2025-01-16 18:55     ` James Bottomley
2025-01-07  2:35 ` [PATCH v2 6/6] efivarfs: fix error on write to new variable leaving remnants James Bottomley
2025-01-16 18:45   ` Al Viro
2025-01-16 18:54     ` James Bottomley
2025-01-16 18:59       ` Al Viro [this message]
2025-01-16 19:04         ` James Bottomley
2025-01-09  9:50 ` [PATCH v2 0/6] convert efivarfs to manage object data correctly Ard Biesheuvel
2025-01-09 14:24   ` Ard Biesheuvel
2025-01-09 15:50   ` James Bottomley
2025-01-09 16:11     ` Ard Biesheuvel
2025-01-18 13:53   ` 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=20250116185950.GL1977892@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=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 \
    /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