Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to fix specific host security attributes #6204

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

hughsie
Copy link
Member

@hughsie hughsie commented Sep 25, 2023

The idea here is that rather than limiting ourselves to setting BIOS values to fix HSI attributes, we can do per-plugin actions such as setting kernel command line options.

Add two new:

  • flags for FwupdSecurityAttr
  • client helpers
  • PolicyKit rules
  • D-Bus methods and plugin vfuncs

Then teach the iommu and linux-lockdown plugins how to set kernel arguments.

This also benefits automation frameworks such as Ansible and puppet; the framework can call the repair functions with just the AppStream ID.

Heavily based on patches by Kate Hsuan hpa@redhat.com, many thanks.

Type of pull request:

libfwupdplugin/fu-kernel.c Outdated Show resolved Hide resolved
libfwupdplugin/fu-kernel.c Outdated Show resolved Hide resolved
libfwupdplugin/fu-plugin.c Outdated Show resolved Hide resolved
libfwupdplugin/fu-plugin.c Outdated Show resolved Hide resolved
src/fu-engine.c Outdated Show resolved Hide resolved
src/fu-util.c Show resolved Hide resolved
Comment on lines 319 to 489
/* check all the config files are writable */
for (guint i = 0; config_files[i] != NULL; i++) {
g_autoptr(GFile) file = g_file_new_for_path(config_files[i]);
g_autoptr(GFileInfo) info = NULL;
g_autoptr(GError) error_local = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't think a new helper for this that both could call could work? It seems like the same to me. Am I missing some nuance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had something like gboolean fu_common_file_is_writable(GFile *file, gboolean *is_writable, GError **error) and it felt much clumsier than just copy and pasting the ~8 lines of code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got something else I'm working on that may use this same function, so it will be 3 places that use the same 8 lines. Still copy/paste better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was struggling with was "should a file that doesn't exist be a GError" and "should a file that's not writeable be an error" -- the caller sometimes wants the former and sometimes wants the latter...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see... so maybe we want two checks? Check if it exists, and check if it is a writable location?

@hughsie hughsie force-pushed the wip/hughsie/fix-security branch 2 times, most recently from 43a00bb to 3225385 Compare September 26, 2023 14:19
libfwupdplugin/fu-kernel.c Outdated Show resolved Hide resolved
superm1
superm1 previously approved these changes Sep 26, 2023
Copy link
Member

@superm1 superm1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one error level thing and then LGTM.

@hughsie
Copy link
Member Author

hughsie commented Sep 26, 2023

@superm1 the only niggle I have is "unfix". Alternatives I have are:

  • unbreak
  • default
  • restore
  • revert
  • rollback
  • downgrade
  • revoke
  • undo

Or we stick to 'unfix'.

@superm1
Copy link
Member

superm1 commented Sep 26, 2023

@superm1 the only niggle I have is "unfix". Alternatives I have are:

  • unbreak
  • default
  • restore
  • revert

I don't like any of this

  • rollback

I like this

  • downgrade

only works if you rename 'fix' too

  • revoke

I don't like this

  • undo

I like this

Or we stick to 'unfix'.

@hughsie
Copy link
Member Author

hughsie commented Sep 26, 2023

@superm1 I've pushed "undo" -- does that make more sense?

@superm1
Copy link
Member

superm1 commented Sep 26, 2023

@superm1 I've pushed "undo" -- does that make more sense?

it does, but I think you need to plumb that through a lot of things that use unfix

The idea here is that rather than limiting ourselves to setting BIOS values
to fix HSI attributes, we can do per-plugin actions such as setting kernel
command line options.

Add two new:

 * flags for FwupdSecurityAttr
 * client helpers
 * PolicyKit rules
 * D-Bus methods and plugin vfuncs

Then teach the iommu and linux-lockdown plugins how to set kernel arguments.

This also benefits automation frameworks such as Ansible and Puppet; the
framework can call the repair functions with just the AppStream ID.

Heavily based on patches by Kate Hsuan <hpa@redhat.com>, many thanks.
@hughsie hughsie marked this pull request as ready for review September 26, 2023 20:30
@hughsie hughsie merged commit f0653af into main Sep 26, 2023
15 checks passed
@hughsie hughsie deleted the wip/hughsie/fix-security branch September 26, 2023 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants