From: Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
Cc: linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/2] efi: Make efivarfs entries immutable by default.
Date: Thu, 18 Feb 2016 14:25:39 -0500 [thread overview]
Message-ID: <20160218192539.GB1515@redhat.com> (raw)
In-Reply-To: <20160218145650.GJ2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
On Thu, Feb 18, 2016 at 02:56:50PM +0000, Matt Fleming wrote:
> On Tue, 16 Feb, at 11:09:43AM, Peter Jones wrote:
> > "rm -rf" is bricking some peoples' laptops because of variables being
> > used to store non-reinitializable firmware driver data that's required
> > to POST the hardware.
> >
> > These are 100% bugs, and they need to be fixed, but in the mean time it
> > shouldn't be easy to *accidentally* brick machines.
> >
> > We have to have delete working, and picking which variables do and don't
> > work for deletion is quite intractable, so instead make everything
> > immutable by default (except for a whitelist), and make tools that
> > aren't quite so broad-spectrum unset the immutable flag.
> >
> > Signed-off-by: Peter Jones <pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > ---
> > Documentation/filesystems/efivarfs.txt | 7 ++
> > drivers/firmware/efi/vars.c | 115 ++++++++++++++++++++-----
> > fs/efivarfs/file.c | 70 +++++++++++++++
> > fs/efivarfs/inode.c | 30 ++++---
> > fs/efivarfs/internal.h | 3 +-
> > fs/efivarfs/super.c | 9 +-
> > include/linux/efi.h | 4 +-
> > tools/testing/selftests/efivarfs/efivarfs.sh | 19 +++-
> > tools/testing/selftests/efivarfs/open-unlink.c | 72 +++++++++++++++-
> > 9 files changed, 287 insertions(+), 42 deletions(-)
>
> [...]
>
> > @@ -193,17 +195,59 @@ static const struct variable_validate variable_validate[] = {
> > { EFI_GLOBAL_VARIABLE_GUID, "ErrOut", validate_device_path },
> > { EFI_GLOBAL_VARIABLE_GUID, "ErrOutDev", validate_device_path },
> > { EFI_GLOBAL_VARIABLE_GUID, "Lang", validate_ascii_string },
> > + { EFI_GLOBAL_VARIABLE_GUID, "OsIndications", NULL },
> > { EFI_GLOBAL_VARIABLE_GUID, "PlatformLang", validate_ascii_string },
> > { EFI_GLOBAL_VARIABLE_GUID, "Timeout", validate_uint16 },
> > + { LINUX_EFI_CRASH_GUID, "*", NULL },
> > { NULL_GUID, "", NULL },
> > };
> >
>
> You don't need to fold in patches that can be applied verbatim from
> upstream. It makes validation of backports harder and the git history
> bizarre.
Fair enough.
> > +static bool
> > +variable_matches(const efi_char16_t *ucs2_name, const char *var_name,
> > + size_t len, const char *match_name, int *match)
> > +{
> > + for (*match = 0; ; (*match)++) {
> > + char c = match_name[*match];
> > + char u = var_name[*match];
> > +
> > + /* Wildcard in the matching name means we've matched */
> > + if (c == '*')
> > + return true;
> > +
> > + /* All special variables are plain ascii unless they were
> > + * wildcards. */
> > + if (ucs2_name[*match] > 127)
> > + return false;
> > +
>
> This caught my eye. You've inverted the check from here,
>
> [...]
>
> > - /* All special variables are plain ascii */
> > - if (u > 127)
> > - return true;
>
> Was that intentional?
Yes - the original one (the bottom here) the return is "is the variable
valid", and we're declaring that anything outside of our list does not
/need/ to be validated, and is thus valid.
In the new one (top), the function is "does the variable match this
entry in the table", and we're saying any case that isn't ASCII does not
match, except by globbing. The calling function, efivar_validate(),
then never runs a ->validate() method on the variable data, eventually
exits the loop having matched nothing, and returns true.
Do you want me to resend with the crash guid one line fix as its own
separate patch?
--
Peter
next prev parent reply other threads:[~2016-02-18 19:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 16:09 [PATCH 0/2] make efivarfs files immutable by default (for stable) Peter Jones
[not found] ` <1455638983-30455-1-git-send-email-pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-16 16:09 ` [PATCH 1/2] efi: make our variable validation list include the guid Peter Jones
2016-02-16 16:09 ` [PATCH 2/2] efi: Make efivarfs entries immutable by default Peter Jones
[not found] ` <1455638983-30455-3-git-send-email-pjones-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-18 14:56 ` Matt Fleming
[not found] ` <20160218145650.GJ2651-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-02-18 19:25 ` Peter Jones [this message]
[not found] ` <20160218192539.GB1515-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-02-20 11:54 ` Matt Fleming
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=20160218192539.GB1515@redhat.com \
--to=pjones-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.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;
as well as URLs for NNTP newsgroup(s).