* [PATCH 0/2] lockdown: Prevent booting with lockdown enabled but IOMMU disabled
@ 2026-11-02 14:00 Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 1/2] iommu: Add iommu_is_available() API Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 2/2] security: lockdown: Prevent boot with lockdown but no IOMMU Mario Limonciello (AMD)
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello (AMD) @ 2026-11-02 14:00 UTC (permalink / raw)
To: Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Nicolas Bouchinet, Xiu Jianfeng,
Paul Moore, James Morris, Serge E. Hallyn
Cc: iommu, linux-kernel, linux-security-module, Mario Limonciello (AMD)
Lockdown is a kernel LSM that restricts access to sensitive kernel
resources (e.g. /dev/mem, kernel modules, perf, tracing, kprobes,
BPF access to kernel memory). However, without IOMMU, any PCI/PCIe
device can perform DMA to arbitrary physical memory, effectively
bypassing all lockdown protections.
A malicious or compromised device can:
- Read kernel memory directly (encryption keys, credentials, secrets)
- Write to kernel memory directly (code patches, rootkits, backdoors)
- Circumvent all lockdown LSM checks (which run inside the kernel)
This series adds a two-phase check to prevent booting with lockdown
enabled and IOMMU disabled:
1. Early check (in lockdown_lsm_init()): On x86, check the no_iommu
flag, which is set early by the "iommu=off" kernel cmdline option.
If lockdown is active and no_iommu is set, panic with a clear error.
2. Late check (late_initcall): On all architectures, check
iommu_is_available() which returns true if any IOMMU driver
registered successfully. This catches cases where:
- IOMMU hardware is absent on the platform
- IOMMU was disabled by driver initialization failure
- IOMMU was not detected (broken firmware, missing ACPI tables)
This follows the precedent set by s390 UV code which panics when
security cannot be guaranteed ("System security cannot be guaranteed
unless the system panics now").
This also adds a generic iommu_is_available() API in the IOMMU
subsystem, which is used by the lockdown check. Any IOMMU driver
that successfully registers will automatically call
iommu_set_available() from iommu_device_register().
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
Mario Limonciello (AMD) (2):
iommu: Add iommu_is_available() API
security: lockdown: Prevent boot with lockdown but no IOMMU
drivers/iommu/iommu.c | 48 ++++++++++++++++++++++++++++++++
include/linux/iommu.h | 14 ++++++++++
security/lockdown/lockdown.c | 65 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 127 insertions(+)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261014-lockdown-iommu-08c763d9f91dd
Best regards,
--
Mario Limonciello <superm1@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] iommu: Add iommu_is_available() API
2026-11-02 14:00 [PATCH 0/2] lockdown: Prevent booting with lockdown enabled but IOMMU disabled Mario Limonciello (AMD)
@ 2026-11-02 14:00 ` Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 2/2] security: lockdown: Prevent boot with lockdown but no IOMMU Mario Limonciello (AMD)
1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello (AMD) @ 2026-11-02 14:00 UTC (permalink / raw)
To: Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Nicolas Bouchinet, Xiu Jianfeng,
Paul Moore, James Morris, Serge E. Hallyn
Cc: iommu, linux-kernel, linux-security-module, Mario Limonciello (AMD)
Add a generic API to query whether IOMMU subsystem is available on the
platform. This returns true if at least one IOMMU driver has been
registered and successfully probed, meaning hardware IOMMU support is
available on the platform.
The iommu_set_available() function is called from iommu_device_register()
when an IOMMU driver successfully registers, marking IOMMU as available.
This will be used by security subsystems (e.g. lockdown) that require
IOMMU isolation to provide meaningful security guarantees. Without IOMMU,
PCI/PCIe devices can perform DMA to arbitrary physical memory, bypassing
all software-level security protections.
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
drivers/iommu/iommu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/iommu.h | 14 ++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index b486b8bbd1fcd..d042944713ab4 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -309,6 +309,13 @@ int iommu_device_register(struct iommu_device *iommu,
iommu_device_unregister(iommu);
else
WRITE_ONCE(iommu->ready, true);
+ /*
+ * Mark IOMMU as available if registration succeeded and bus probing
+ * succeeded. This enables security checks (e.g. lockdown IOMMU check)
+ * that depend on knowing whether hardware IOMMU isolation is present.
+ */
+ if (!err)
+ iommu_set_available();
return err;
}
EXPORT_SYMBOL_GPL(iommu_device_register);
@@ -2961,6 +2968,47 @@ static int __init iommu_init(void)
}
core_initcall(iommu_init);
+static bool iommu_available __read_mostly;
+
+/**
+ * iommu_is_available() - Check if IOMMU subsystem is available
+ *
+ * Returns true if at least one IOMMU driver has been registered and
+ * successfully probed, meaning hardware IOMMU support is available on
+ * the platform. Returns false if no IOMMU driver is available.
+ *
+ * This function is intended for use by security subsystems that require
+ * IOMMU isolation to provide meaningful security guarantees (e.g. lockdown).
+ *
+ * Note: This function only reports on whether IOMMU drivers are present,
+ * not whether specific devices are covered. Use device_iommu_capable() or
+ * iommu_group_get() to check per-device IOMMU coverage.
+ *
+ * Context: Can be called at any time after module initialization has begun.
+ * Returns a snapshot of the IOMMU availability state.
+ *
+ * Return: True if IOMMU is available, false otherwise.
+ */
+bool iommu_is_available(void)
+{
+ return iommu_available;
+}
+EXPORT_SYMBOL_GPL(iommu_is_available);
+
+/**
+ * iommu_set_available() - Mark IOMMU as available
+ *
+ * Called by IOMMU drivers during probe to indicate that hardware IOMMU
+ * support is functional on this platform.
+ *
+ * Context: Called from driver probe paths.
+ */
+void iommu_set_available(void)
+{
+ iommu_available = true;
+}
+EXPORT_SYMBOL_GPL(iommu_set_available);
+
int iommu_set_pgtable_quirks(struct iommu_domain *domain,
unsigned long quirk)
{
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ef5043752a365..d77237fc880ae 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -1222,6 +1222,13 @@ void iommu_detach_device_pasid(struct iommu_domain *domain,
ioasid_t iommu_alloc_global_pasid(struct device *dev);
void iommu_free_global_pasid(ioasid_t pasid);
+/*
+ * IOMMU availability API - for use by subsystems that require IOMMU
+ * isolation to provide security guarantees.
+ */
+bool iommu_is_available(void);
+void iommu_set_available(void);
+
/* PCI device reset functions */
int pci_dev_reset_iommu_prepare(struct pci_dev *pdev);
void pci_dev_reset_iommu_done(struct pci_dev *pdev);
@@ -1557,6 +1564,13 @@ static inline int pci_dev_reset_iommu_prepare(struct pci_dev *pdev)
static inline void pci_dev_reset_iommu_done(struct pci_dev *pdev)
{
}
+
+static inline bool iommu_is_available(void)
+{
+ return false;
+}
+static inline void iommu_set_available(void) {}
+
#endif /* CONFIG_IOMMU_API */
#ifdef CONFIG_IRQ_MSI_IOMMU
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] security: lockdown: Prevent boot with lockdown but no IOMMU
2026-11-02 14:00 [PATCH 0/2] lockdown: Prevent booting with lockdown enabled but IOMMU disabled Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 1/2] iommu: Add iommu_is_available() API Mario Limonciello (AMD)
@ 2026-11-02 14:00 ` Mario Limonciello (AMD)
1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello (AMD) @ 2026-11-02 14:00 UTC (permalink / raw)
To: Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Nicolas Bouchinet, Xiu Jianfeng,
Paul Moore, James Morris, Serge E. Hallyn
Cc: iommu, linux-kernel, linux-security-module, Mario Limonciello (AMD)
Lockdown is a kernel LSM that restricts access to sensitive kernel
resources (e.g. /dev/mem, kernel modules, perf, tracing, kprobes,
BPF access to kernel memory). However, without IOMMU, any PCI/PCIe
device can perform DMA to arbitrary physical memory, effectively
bypassing all lockdown protections.
A malicious or compromised device can:
- Read kernel memory directly (encryption keys, credentials, secrets)
- Write to kernel memory directly (code patches, rootkits, backdoors)
- Circumvent all lockdown LSM checks (which run inside the kernel)
Add a two-phase check to prevent booting with lockdown enabled and
IOMMU disabled:
1. Early check (in lockdown_lsm_init()): On x86, check the no_iommu
flag, which is set early by the 'iommu=off' kernel cmdline option.
If lockdown is active and no_iommu is set, panic with a clear error.
2. Late check (late_initcall): On all architectures, check
iommu_is_available() which returns true if any IOMMU driver
registered successfully. This catches cases where:
- IOMMU hardware is absent on the platform
- IOMMU was disabled by driver initialization failure
- IOMMU was not detected (broken firmware, missing ACPI tables)
This follows the precedent set by s390 UV code which panics when
security cannot be guaranteed ("System security cannot be guaranteed
unless the system panics now").
Also update iommu_device_register() to call iommu_set_available() on
successful registration, so all IOMMU drivers automatically signal
their availability.
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
---
security/lockdown/lockdown.c | 65 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
index 8d46886d2cca0..6ce1490188d5d 100644
--- a/security/lockdown/lockdown.c
+++ b/security/lockdown/lockdown.c
@@ -13,8 +13,14 @@
#include <linux/security.h>
#include <linux/export.h>
#include <linux/lsm_hooks.h>
+#include <linux/init.h>
#include <uapi/linux/lsm.h>
+#if IS_ENABLED(CONFIG_X86)
+#include <asm/iommu.h>
+#endif
+#include <linux/iommu.h>
+
static enum lockdown_reason kernel_locked_down;
static const enum lockdown_reason lockdown_levels[] = {LOCKDOWN_NONE,
@@ -88,6 +94,25 @@ static int __init lockdown_lsm_init(void)
#elif defined(CONFIG_LOCK_DOWN_KERNEL_FORCE_CONFIDENTIALITY)
lock_kernel_down("Kernel configuration", LOCKDOWN_CONFIDENTIALITY_MAX);
#endif
+
+ /*
+ * If lockdown was activated (via command line or kernel config)
+ * and IOMMU is disabled, refuse to boot. Without IOMMU, any
+ * PCI/PCIe device can perform DMA to arbitrary physical memory,
+ * completely bypassing lockdown protections.
+ *
+ * On x86, 'no_iommu' is set early by the 'iommu=off' cmdline
+ * option during parse_early_param(), before this init function.
+ */
+#if IS_ENABLED(CONFIG_X86)
+ if (kernel_locked_down > LOCKDOWN_NONE && no_iommu) {
+ pr_err("FATAL: Lockdown is active but IOMMU is disabled.\n");
+ pr_err("FATAL: PCI devices can perform DMA to arbitrary memory,\n");
+ pr_err("FATAL: bypassing all lockdown protections.\n");
+ panic("Lockdown enabled but IOMMU is disabled (no_iommu)\n");
+ }
+#endif
+
security_add_hooks(lockdown_hooks, ARRAY_SIZE(lockdown_hooks),
&lockdown_lsmid);
return 0;
@@ -170,3 +195,43 @@ DEFINE_LSM(lockdown) = {
.init = lockdown_lsm_init,
.initcall_core = lockdown_secfs_init,
};
+
+/*
+ * Late init call to verify IOMMU availability when lockdown is active.
+ * This catches cases where:
+ * - IOMMU hardware is absent on the platform
+ * - IOMMU was disabled by driver initialization failure
+ * - IOMMU was not detected (e.g. broken firmware, missing ACPI tables)
+ *
+ * On x86, we also check no_iommu here as a double-check. The early check
+ * in lockdown_lsm_init() catches 'iommu=off' from the cmdline before
+ * lockdown_lsm_init() runs, but this late check covers any missed cases.
+ */
+static int __init lockdown_check_iommu(void)
+{
+ if (kernel_locked_down > LOCKDOWN_NONE) {
+ /*
+ * Check generic IOMMU availability (all architectures).
+ * iommu_is_available() returns true if any IOMMU driver
+ * registered successfully.
+ */
+ if (!iommu_is_available()) {
+ pr_err("FATAL: Lockdown is active but no IOMMU driver\n");
+ pr_err("FATAL: registered. PCI devices can DMA to\n");
+ pr_err("FATAL: arbitrary memory, bypassing lockdown.\n");
+ panic("Lockdown enabled but IOMMU not available\n");
+ }
+#if IS_ENABLED(CONFIG_X86)
+ /*
+ * Also double-check x86-specific flag.
+ */
+ if (no_iommu) {
+ pr_err("FATAL: Lockdown is active but IOMMU disabled\n");
+ pr_err("FATAL: via kernel command line (iommu=off).\n");
+ panic("Lockdown enabled but IOMMU disabled (iommu=off)\n");
+ }
+#endif
+ }
+ return 0;
+}
+late_initcall(lockdown_check_iommu);
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-02 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 14:00 [PATCH 0/2] lockdown: Prevent booting with lockdown enabled but IOMMU disabled Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 1/2] iommu: Add iommu_is_available() API Mario Limonciello (AMD)
2026-11-02 14:00 ` [PATCH 2/2] security: lockdown: Prevent boot with lockdown but no IOMMU Mario Limonciello (AMD)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®