efivarfs: Add uid/gid mount options
Subsystems (3)
PATCH v5 1/1 efivarfs: Add uid/gid mount options
Allow UEFI variables to be modified by non-root processes in order to run sandboxed code. This doesn't change the behavior of mounting efivarfs unless uid/gid are specified;
by default both are set to root.
Signed-off-by Jiao Zhou <[email protected]>
Acked-by Matthew Garrett <[email protected]>
---
Changelog since v1:
- Add missing sentinel entry in fs_parameter_spec[] array.
- Fix a NULL pointer dereference.
Changelog since v2:
- Format the patch description.
Changelog since v3:
- Add gid and uid check to make sure that ids are valid.
- Drop the indentation for one block.
- Use sizeof(*sfi) to allocate memory to avoids future problems if sfi ever changes type.
Changelog since v4:
- Fix the use of sizeof.
--- fs/efivarfs/inode.c | 4 +++ fs/efivarfs/internal.h | 9 +++++ fs/efivarfs/super.c | 74 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 3 deletions(-)
fs/efivarfs/inode.c +4 -0
@@ -20,9 +20,13 @@ struct inode *efivarfs_get_inode(struct super_block *sb, const struct inode *dir, int mode, dev_t dev, bool is_removable) { + struct efivarfs_fs_info *fsi = sb->s_fs_info;struct inode *inode =new_inode (sb); +struct efivarfs_mount_opts *opts = &fsi->mount_opts;if (inode) { + inode->i_uid = opts->uid; + inode->i_gid = opts->gid; inode->i_ino =get_next_ino (); inode->i_mode = mode; inode->i_atime = inode->i_mtime =inode_set_ctime_current (inode);
fs/efivarfs/internal.h +9 -0
@@ -9,6 +9,15 @@#include <linux/list.h> #include <linux/efi.h> +struct efivarfs_mount_opts { +kuid_t uid; +kgid_t gid; +}; + +struct efivarfs_fs_info { +struct efivarfs_mount_opts mount_opts; +}; +struct efi_variable {efi_char16_t VariableName[EFI_VAR_NAME_LEN /sizeof (efi_char16_t)];efi_guid_t VendorGuid;
fs/efivarfs/super.c +71 -3
116 lines not on this page · raw message
Signature · 1 line
2.42.0.283.g2d96d420d3-goog