From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Richard Hughes <richard@hughsie.com>, linux-efi@vger.kernel.org
Subject: Re: efivarfs: fix error on write to new variable leaving remnants
Date: Wed, 26 Feb 2025 08:09:19 -0500 [thread overview]
Message-ID: <4c60f747aaffe1b0323ec5103cdb32ab19c3b04d.camel@HansenPartnership.com> (raw)
In-Reply-To: <CAMj1kXGsZVAWmG7NV+6fevvZy6RwEXrw2avT1EBRWjn5Kk_hvw@mail.gmail.com>
On Wed, 2025-02-26 at 12:30 +0100, Ard Biesheuvel wrote:
> On Tue, 25 Feb 2025 at 13:59, James Bottomley
> <James.Bottomley@hansenpartnership.com> wrote:
[...]
> > Reading the code in the fix, it looks like you were creating a file
> > in EFI (which is naturally zero length), then closing it (because
> > glib gio specifically has an API for this), then clearing the
> > immutable bit and then writing to it to actually create a variable?
> >
> > However, none of that dance is at all required. A newly created
> > file naturally allows writing on the file descriptor you used to
> > create it. It's only if you open it again that the entry becomes
> > immutable.
>
> Should we be doing this in the first place? It makes sense for
> efivarfs to mark variables that it doesn't know about as immutable if
> they are present at boot - the original rationale here was systems
> with buggy firmware, where an inadvertent 'rm -r
> /sys/firmware/efivars/*' would brick the device.
>
> But the fact that a newly created file becomes immutable once you
> close and reopen it seems unnecessarily strict to me.
>
> (I am aware that this is orthogonal to the issue at hand, but it is
> something we might fix nonetheless)
Well, I've always thought it was silly ever since it was introduced:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ed8b0de5a33d2a2557dce7f9429dca8cb5bc5879
The rationale it was because root could brick their system by doing rm
-fr never made any sense, since if root is going to do rm -fr they're
asking to become unbootable anyway.
All of us who have code that manipulates the variables simply added
remove immutable flag code like the above. If it does get removed,
efivarfs will still need to respond to get/setfsxattr though to make
sure that code keeps working, so it can't be a clean revert.
Regards,
James
next prev parent reply other threads:[~2025-02-26 13:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <SBFUY-p4-fI9JOrQa51x141vKHs_rbFLw4q9kfPGAK8Z76PQfgYl6zM3nUjlOeIPY6PgEhqLFaSJkW0vdBVzET3MDYUBZwzmYCJuNK4TaYU=@hughsie.com>
2025-02-25 12:59 ` efivarfs: fix error on write to new variable leaving remnants James Bottomley
2025-02-26 11:30 ` Ard Biesheuvel
2025-02-26 13:02 ` James Bottomley
2025-02-26 13:09 ` James Bottomley [this message]
2025-02-26 14:27 ` Richard Hughes
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=4c60f747aaffe1b0323ec5103cdb32ab19c3b04d.camel@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=richard@hughsie.com \
/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