Commit 9c28f1be authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Khalid Elmously

efi/efi_test: Lock down /dev/efi_test and require CAP_SYS_ADMIN

BugLink: https://bugs.launchpad.net/bugs/1884159

The driver exposes EFI runtime services to user-space through an IOCTL
interface, calling the EFI services function pointers directly without
using the efivar API.

Disallow access to the /dev/efi_test character device when the kernel is
locked down to prevent arbitrary user-space to call EFI runtime services.

Also require CAP_SYS_ADMIN to open the chardev to prevent unprivileged
users to call the EFI runtime services, instead of just relying on the
chardev file mode bits for this.

The main user of this driver is the fwts [0] tool that already checks if
the effective user ID is 0 and fails otherwise. So this change shouldn't
cause any regression to this tool.

[0]: https://wiki.ubuntu.com/FirmwareTestSuite/Reference/uefivarinfoSigned-off-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: default avatarLaszlo Ersek <lersek@redhat.com>
Acked-by: default avatarMatthew Garrett <mjg59@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191029173755.27149-7-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
(backported from commit 359efcc2)
Signed-off-by: default avatarSeth Forshee <seth.forshee@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarAndrea Righi <andrea.righi@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 2b092cf3
...@@ -696,6 +696,13 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd, ...@@ -696,6 +696,13 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd,
static int efi_test_open(struct inode *inode, struct file *file) static int efi_test_open(struct inode *inode, struct file *file)
{ {
bool locked_down = secure_modules();
if (locked_down)
return -EPERM;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
/* /*
* nothing special to do here * nothing special to do here
* We do accept multiple open files at the same time as we * We do accept multiple open files at the same time as we
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment