summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFerruh Yigit <ferruh.yigit@intel.com>2018-05-16 15:42:20 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-06-27 17:02:54 +0200
commitd67014c3d38b20ac4cfe103f5a7a2107feaa5acf (patch)
tree30096fb070fc78d7112cf9fd41f2044703e4e285 /kernel
parenta36b40dd8ecfb61648045e418551f75055ca77f9 (diff)
downloaddpdk-d67014c3d38b20ac4cfe103f5a7a2107feaa5acf.zip
dpdk-d67014c3d38b20ac4cfe103f5a7a2107feaa5acf.tar.gz
dpdk-d67014c3d38b20ac4cfe103f5a7a2107feaa5acf.tar.xz
igb_uio: fail and log if kernel lock down is enabled
When EFI secure boot is enabled, it is possible to lock down kernel and prevent accessing device BARs and this makes igb_uio unusable. Lock down patches are not part of the vanilla kernel but they are applied and used by some distros already [1]. It is not possible to fix this issue, but intention of this patch is to detect and log if kernel lock down enabled and don't insert the module for that case. The challenge is since this feature enabled by distros, they have different config options and APIs for it. This patch is done based on Fedora and Ubuntu kernel source, may needs to add more distro specific support. [1] kernel.ubuntu.com/git/ubuntu/ubuntu-artful.git/commit/?id=99f9ef18d5b6 And a few more patches too. Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com> Acked-by: Luca Boccassi <bluca@debian.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/linux/igb_uio/compat.h23
-rw-r--r--kernel/linux/igb_uio/igb_uio.c5
2 files changed, 24 insertions, 4 deletions
diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h
index b4131a5..e5df515 100644
--- a/kernel/linux/igb_uio/compat.h
+++ b/kernel/linux/igb_uio/compat.h
@@ -126,10 +126,6 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
#define HAVE_PCI_IS_BRIDGE_API 1
#endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-#define HAVE_ALLOC_IRQ_VECTORS 1
-#endif
-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
#define HAVE_MSI_LIST_IN_GENERIC_DEVICE 1
#endif
@@ -137,3 +133,22 @@ static bool pci_check_and_mask_intx(struct pci_dev *pdev)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
#define HAVE_PCI_MSI_MASK_IRQ 1
#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+#define HAVE_ALLOC_IRQ_VECTORS 1
+#endif
+
+static inline bool igbuio_kernel_is_locked_down(void)
+{
+#ifdef CONFIG_LOCK_DOWN_KERNEL
+#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT
+ return kernel_is_locked_down(NULL);
+#elif CONFIG_EFI_SECURE_BOOT_LOCK_DOWN
+ return kernel_is_locked_down();
+#else
+ return false;
+#endif
+#else
+ return false;
+#endif
+}
diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c
index cd9b7e7..b3233f1 100644
--- a/kernel/linux/igb_uio/igb_uio.c
+++ b/kernel/linux/igb_uio/igb_uio.c
@@ -621,6 +621,11 @@ igbuio_pci_init_module(void)
{
int ret;
+ if (igbuio_kernel_is_locked_down()) {
+ pr_err("Not able to use module, kernel lock down is enabled\n");
+ return -EINVAL;
+ }
+
ret = igbuio_config_intr_mode(intr_mode);
if (ret < 0)
return ret;