* [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
@ 2026-06-03 11:44 Asad Kamal
2026-06-03 12:29 ` StDenis, Tom
2026-06-08 9:03 ` Nicolas Bouchinet
0 siblings, 2 replies; 9+ messages in thread
From: Asad Kamal @ 2026-06-03 11:44 UTC (permalink / raw)
To: amd-gfx
Cc: lijo.lazar, hawking.zhang, le.ma, shiwu.zhang, alexander.deucher,
kevinyang.wang, asad.kamal, Tom.StDenis
amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow
arbitrary MMIO read/write via RREG32/WREG32 without checking
security_locked_down(). On kernel_lockdown=integrity systems
this bypasses the same restrictions as /dev/mem and PCI config
space sysfs.
Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
debugfs handler that performs direct register access.
v2: Use consistent check as per previous check to use
LOCKDOWN_DEBUGFS(Lijo)
v3: Do not create any entry from amdgpu_debugfs_regs_init() if
LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 0ce6e2e4342c..5c4d4ff001ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -26,6 +26,7 @@
#include <linux/kthread.h>
#include <linux/pci.h>
#include <linux/uaccess.h>
+#include <linux/security.h>
#include <linux/pm_runtime.h>
#include "amdgpu.h"
@@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
struct dentry *ent, *root = minor->debugfs_root;
unsigned int i;
+ if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
+ drm_info(adev_to_drm(adev),
+ "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
+ return 0;
+ }
+
for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
ent = debugfs_create_file(debugfs_regs_names[i],
S_IFREG | 0400, root,
--
2.46.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-03 11:44 [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown Asad Kamal
@ 2026-06-03 12:29 ` StDenis, Tom
2026-06-03 12:55 ` Kamal, Asad
2026-06-03 14:20 ` Lazar, Lijo
2026-06-08 9:03 ` Nicolas Bouchinet
1 sibling, 2 replies; 9+ messages in thread
From: StDenis, Tom @ 2026-06-03 12:29 UTC (permalink / raw)
To: Kamal, Asad, amd-gfx@lists.freedesktop.org
Cc: Lazar, Lijo, Zhang, Hawking, Ma, Le, Zhang, Morris,
Deucher, Alexander, Wang, Yang(Kevin)
HI Asad,
This should be fine for umr. UMR detects when the lockdown mode isn't "none" and warns the user that the tool might not work.
So the net effect of this patch is the debugfs files are just not created at all? That'll likely cause umr discovery to fail (after it prints he warning) which is still fine.
Tom
________________________________________
From: Kamal, Asad <Asad.Kamal@amd.com>
Sent: Wednesday, June 3, 2026 07:44
To: amd-gfx@lists.freedesktop.org
Cc: Lazar, Lijo; Zhang, Hawking; Ma, Le; Zhang, Morris; Deucher, Alexander; Wang, Yang(Kevin); Kamal, Asad; StDenis, Tom
Subject: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow
arbitrary MMIO read/write via RREG32/WREG32 without checking
security_locked_down(). On kernel_lockdown=integrity systems
this bypasses the same restrictions as /dev/mem and PCI config
space sysfs.
Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
debugfs handler that performs direct register access.
v2: Use consistent check as per previous check to use
LOCKDOWN_DEBUGFS(Lijo)
v3: Do not create any entry from amdgpu_debugfs_regs_init() if
LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 0ce6e2e4342c..5c4d4ff001ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -26,6 +26,7 @@
#include <linux/kthread.h>
#include <linux/pci.h>
#include <linux/uaccess.h>
+#include <linux/security.h>
#include <linux/pm_runtime.h>
#include "amdgpu.h"
@@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
struct dentry *ent, *root = minor->debugfs_root;
unsigned int i;
+ if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
+ drm_info(adev_to_drm(adev),
+ "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
+ return 0;
+ }
+
for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
ent = debugfs_create_file(debugfs_regs_names[i],
S_IFREG | 0400, root,
--
2.46.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-03 12:29 ` StDenis, Tom
@ 2026-06-03 12:55 ` Kamal, Asad
2026-06-03 14:20 ` Lazar, Lijo
1 sibling, 0 replies; 9+ messages in thread
From: Kamal, Asad @ 2026-06-03 12:55 UTC (permalink / raw)
To: StDenis, Tom, amd-gfx@lists.freedesktop.org
Cc: Lazar, Lijo, Zhang, Hawking, Ma, Le, Zhang, Morris,
Deucher, Alexander, Wang, Yang(Kevin)
AMD General
Hi Dennis,
Yes, debugfs file(amdgpu_regs) wont be created when lockdown mode is not "none".
Thanks & Regards
Asad
-----Original Message-----
From: StDenis, Tom <Tom.StDenis@amd.com>
Sent: Wednesday, June 3, 2026 6:00 PM
To: Kamal, Asad <Asad.Kamal@amd.com>; amd-gfx@lists.freedesktop.org
Cc: Lazar, Lijo <Lijo.Lazar@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Ma, Le <Le.Ma@amd.com>; Zhang, Morris <Shiwu.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>
Subject: Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
HI Asad,
This should be fine for umr. UMR detects when the lockdown mode isn't "none" and warns the user that the tool might not work.
So the net effect of this patch is the debugfs files are just not created at all? That'll likely cause umr discovery to fail (after it prints he warning) which is still fine.
Tom
________________________________________
From: Kamal, Asad <Asad.Kamal@amd.com>
Sent: Wednesday, June 3, 2026 07:44
To: amd-gfx@lists.freedesktop.org
Cc: Lazar, Lijo; Zhang, Hawking; Ma, Le; Zhang, Morris; Deucher, Alexander; Wang, Yang(Kevin); Kamal, Asad; StDenis, Tom
Subject: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow arbitrary MMIO read/write via RREG32/WREG32 without checking security_locked_down(). On kernel_lockdown=integrity systems this bypasses the same restrictions as /dev/mem and PCI config space sysfs.
Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every debugfs handler that performs direct register access.
v2: Use consistent check as per previous check to use
LOCKDOWN_DEBUGFS(Lijo)
v3: Do not create any entry from amdgpu_debugfs_regs_init() if LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
Signed-off-by: Asad Kamal <asad.kamal@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index 0ce6e2e4342c..5c4d4ff001ea 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -26,6 +26,7 @@
#include <linux/kthread.h>
#include <linux/pci.h>
#include <linux/uaccess.h>
+#include <linux/security.h>
#include <linux/pm_runtime.h>
#include "amdgpu.h"
@@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
struct dentry *ent, *root = minor->debugfs_root;
unsigned int i;
+ if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
+ drm_info(adev_to_drm(adev),
+ "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
+ return 0;
+ }
+
for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
ent = debugfs_create_file(debugfs_regs_names[i],
S_IFREG | 0400, root,
--
2.46.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-03 12:29 ` StDenis, Tom
2026-06-03 12:55 ` Kamal, Asad
@ 2026-06-03 14:20 ` Lazar, Lijo
1 sibling, 0 replies; 9+ messages in thread
From: Lazar, Lijo @ 2026-06-03 14:20 UTC (permalink / raw)
To: StDenis, Tom, Kamal, Asad, amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking, Ma, Le, Zhang, Morris, Deucher, Alexander,
Wang, Yang(Kevin)
Thanks, Tom.
The patch looks good to me -
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Hi Alex/Hawking,
Any concerns on shutting down the interfaces in lockdown mode?
Thanks,
Lijo
On 03-Jun-26 5:59 PM, StDenis, Tom wrote:
> HI Asad,
>
> This should be fine for umr. UMR detects when the lockdown mode isn't "none" and warns the user that the tool might not work.
>
> So the net effect of this patch is the debugfs files are just not created at all? That'll likely cause umr discovery to fail (after it prints he warning) which is still fine.
>
> Tom
>
>
> ________________________________________
> From: Kamal, Asad <Asad.Kamal@amd.com>
> Sent: Wednesday, June 3, 2026 07:44
> To: amd-gfx@lists.freedesktop.org
> Cc: Lazar, Lijo; Zhang, Hawking; Ma, Le; Zhang, Morris; Deucher, Alexander; Wang, Yang(Kevin); Kamal, Asad; StDenis, Tom
> Subject: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
>
> amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow
> arbitrary MMIO read/write via RREG32/WREG32 without checking
> security_locked_down(). On kernel_lockdown=integrity systems
> this bypasses the same restrictions as /dev/mem and PCI config
> space sysfs.
>
> Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
> debugfs handler that performs direct register access.
>
> v2: Use consistent check as per previous check to use
> LOCKDOWN_DEBUGFS(Lijo)
>
> v3: Do not create any entry from amdgpu_debugfs_regs_init() if
> LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
>
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 0ce6e2e4342c..5c4d4ff001ea 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -26,6 +26,7 @@
> #include <linux/kthread.h>
> #include <linux/pci.h>
> #include <linux/uaccess.h>
> +#include <linux/security.h>
> #include <linux/pm_runtime.h>
>
> #include "amdgpu.h"
> @@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
> struct dentry *ent, *root = minor->debugfs_root;
> unsigned int i;
>
> + if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
> + drm_info(adev_to_drm(adev),
> + "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
> + return 0;
> + }
> +
> for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
> ent = debugfs_create_file(debugfs_regs_names[i],
> S_IFREG | 0400, root,
> --
> 2.46.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-03 11:44 [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown Asad Kamal
2026-06-03 12:29 ` StDenis, Tom
@ 2026-06-08 9:03 ` Nicolas Bouchinet
2026-06-08 11:03 ` Kamal, Asad
1 sibling, 1 reply; 9+ messages in thread
From: Nicolas Bouchinet @ 2026-06-08 9:03 UTC (permalink / raw)
To: Asad Kamal
Cc: amd-gfx, lijo.lazar, hawking.zhang, le.ma, shiwu.zhang,
alexander.deucher, kevinyang.wang, Tom.StDenis
On Wed, Jun 03, 2026 at 07:44:59PM +0800, Asad Kamal wrote:
> amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow
> arbitrary MMIO read/write via RREG32/WREG32 without checking
> security_locked_down(). On kernel_lockdown=integrity systems
> this bypasses the same restrictions as /dev/mem and PCI config
> space sysfs.
>
> Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
> debugfs handler that performs direct register access.
>
> v2: Use consistent check as per previous check to use
> LOCKDOWN_DEBUGFS(Lijo)
>
> v3: Do not create any entry from amdgpu_debugfs_regs_init() if
> LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
>
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 0ce6e2e4342c..5c4d4ff001ea 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -26,6 +26,7 @@
> #include <linux/kthread.h>
> #include <linux/pci.h>
> #include <linux/uaccess.h>
> +#include <linux/security.h>
> #include <linux/pm_runtime.h>
>
> #include "amdgpu.h"
> @@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
> struct dentry *ent, *root = minor->debugfs_root;
> unsigned int i;
>
> + if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
> + drm_info(adev_to_drm(adev),
> + "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
> + return 0;
> + }
> +
> for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
> ent = debugfs_create_file(debugfs_regs_names[i],
> S_IFREG | 0400, root,
> --
> 2.46.0
>
Hi,
Lockdown denies opening of debugfs files but those with the
following conditions :
- The file must only be opened for reading.
- The file must have mode 00444.
- The file must not have ioctl methods fops.
- The file must not have mmap fops.
I might be missing something, but how are you able to write in those ?
Best regards,
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-08 9:03 ` Nicolas Bouchinet
@ 2026-06-08 11:03 ` Kamal, Asad
2026-06-08 11:27 ` Nicolas Bouchinet
0 siblings, 1 reply; 9+ messages in thread
From: Kamal, Asad @ 2026-06-08 11:03 UTC (permalink / raw)
To: Nicolas Bouchinet
Cc: amd-gfx@lists.freedesktop.org, Lazar, Lijo, Zhang, Hawking,
Ma, Le, Zhang, Morris, Deucher, Alexander, Wang, Yang(Kevin),
StDenis, Tom
AMD General
Hi @Nicolas Bouchinet
Thank you for the review.
The commit message references v1 behavior and is no longer accurate. Writes are already blocked, the existing debugfs_locked_down() in fs/debugfs/file.c handles writes when FMODE_WRITE is set, the early-return guard fails and security_locked_down(LOCKDOWN_DEBUGFS) blocks the open under [integrity].
The patch addresses only the read path. Here is why reads are not blocked by debugfs_locked_down():
static int debugfs_locked_down(struct inode *inode,
struct file *filp,
const struct file_operations *real_fops)
{
if ((inode->i_mode & 07777 & ~0444) == 0 &&
!(filp->f_mode & FMODE_WRITE) &&
(!real_fops || (!real_fops->unlocked_ioctl &&
!real_fops->compat_ioctl &&
!real_fops->mmap)))
return 0;
if (security_locked_down(LOCKDOWN_DEBUGFS))
return -EPERM;
return 0;
}
For a read-only open of amdgpu_regs (mode 0400, no ioctl, no mmap):
1) (0400 & 07777 & ~0444) == 0 → true - any mode with no bits set outside the 0444 mask (e.g. 0400, 0440, 0444) 0400 satisfies that.
2) !(filp->f_mode & FMODE_WRITE) → true for a read-only open.
3) No unlocked_ioctl, compat_ioctl, or mmap in amdgpu_debugfs_regs_fops → true.
All three conditions hold, so debugfs_locked_down() returns 0 and the read open proceeds. The read handler then calls RREG32, a direct hardware MMIO read, with no further lockdown check. That is the gap which this patch is addressing.
Thanks & Regards
Asad
-----Original Message-----
From: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
Sent: Monday, June 8, 2026 2:34 PM
To: Kamal, Asad <Asad.Kamal@amd.com>
Cc: amd-gfx@lists.freedesktop.org; Lazar, Lijo <Lijo.Lazar@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Ma, Le <Le.Ma@amd.com>; Zhang, Morris <Shiwu.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; StDenis, Tom <Tom.StDenis@amd.com>
Subject: Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
[Some people who received this message don't often get email from nicolas.bouchinet@oss.cyber.gouv.fr. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
On Wed, Jun 03, 2026 at 07:44:59PM +0800, Asad Kamal wrote:
> amdgpu_regs, amdgpu_regs2, and related debugfs nodes allow arbitrary
> MMIO read/write via RREG32/WREG32 without checking
> security_locked_down(). On kernel_lockdown=integrity systems this
> bypasses the same restrictions as /dev/mem and PCI config space sysfs.
>
> Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
> debugfs handler that performs direct register access.
>
> v2: Use consistent check as per previous check to use
> LOCKDOWN_DEBUGFS(Lijo)
>
> v3: Do not create any entry from amdgpu_debugfs_regs_init() if
> LOCKDOWN_PCI_ACCESS is active and log once. (Lijo)
>
> Signed-off-by: Asad Kamal <asad.kamal@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index 0ce6e2e4342c..5c4d4ff001ea 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> @@ -26,6 +26,7 @@
> #include <linux/kthread.h>
> #include <linux/pci.h>
> #include <linux/uaccess.h>
> +#include <linux/security.h>
> #include <linux/pm_runtime.h>
>
> #include "amdgpu.h"
> @@ -1739,6 +1740,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
> struct dentry *ent, *root = minor->debugfs_root;
> unsigned int i;
>
> + if (security_locked_down(LOCKDOWN_PCI_ACCESS)) {
> + drm_info(adev_to_drm(adev),
> + "amdgpu: HW debugfs nodes disabled (kernel lockdown)\n");
> + return 0;
> + }
> +
> for (i = 0; i < ARRAY_SIZE(debugfs_regs); i++) {
> ent = debugfs_create_file(debugfs_regs_names[i],
> S_IFREG | 0400, root,
> --
> 2.46.0
>
Hi,
Lockdown denies opening of debugfs files but those with the following conditions :
- The file must only be opened for reading.
- The file must have mode 00444.
- The file must not have ioctl methods fops.
- The file must not have mmap fops.
I might be missing something, but how are you able to write in those ?
Best regards,
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-08 11:03 ` Kamal, Asad
@ 2026-06-08 11:27 ` Nicolas Bouchinet
2026-06-08 11:48 ` Kamal, Asad
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Bouchinet @ 2026-06-08 11:27 UTC (permalink / raw)
To: Kamal, Asad
Cc: amd-gfx@lists.freedesktop.org, Lazar, Lijo, Zhang, Hawking,
Ma, Le, Zhang, Morris, Deucher, Alexander, Wang, Yang(Kevin),
StDenis, Tom
On Mon, Jun 08, 2026 at 11:03:05AM +0000, Kamal, Asad wrote:
> AMD General
>
> Hi @Nicolas Bouchinet
>
> Thank you for the review.
>
> The commit message references v1 behavior and is no longer accurate. Writes are already blocked, the existing debugfs_locked_down() in fs/debugfs/file.c handles writes when FMODE_WRITE is set, the early-return guard fails and security_locked_down(LOCKDOWN_DEBUGFS) blocks the open under [integrity].
>
> The patch addresses only the read path. Here is why reads are not blocked by debugfs_locked_down():
>
> static int debugfs_locked_down(struct inode *inode,
> struct file *filp,
> const struct file_operations *real_fops)
> {
> if ((inode->i_mode & 07777 & ~0444) == 0 &&
> !(filp->f_mode & FMODE_WRITE) &&
> (!real_fops || (!real_fops->unlocked_ioctl &&
> !real_fops->compat_ioctl &&
> !real_fops->mmap)))
> return 0;
> if (security_locked_down(LOCKDOWN_DEBUGFS))
> return -EPERM;
> return 0;
> }
>
> For a read-only open of amdgpu_regs (mode 0400, no ioctl, no mmap):
>
> 1) (0400 & 07777 & ~0444) == 0 → true - any mode with no bits set outside the 0444 mask (e.g. 0400, 0440, 0444) 0400 satisfies that.
> 2) !(filp->f_mode & FMODE_WRITE) → true for a read-only open.
> 3) No unlocked_ioctl, compat_ioctl, or mmap in amdgpu_debugfs_regs_fops → true.
>
> All three conditions hold, so debugfs_locked_down() returns 0 and the read open proceeds. The read handler then calls RREG32, a direct hardware MMIO read, with no further lockdown check. That is the gap which this patch is addressing.
>
> Thanks & Regards
> Asad
Thanks Asad for your explaination !
`LOCKDOWN_PCI_ACCESS` is used in the `integrity` mode of Lockdown and
should be used to protect against Kernel integrity tampering.
IIUC your issue, the access is read-only and thus, you should use one of
the existing `confidentiality` lockdown_reasons. You are free to add a
new one if none of the existing one covers your use case.
Best regards,
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-08 11:27 ` Nicolas Bouchinet
@ 2026-06-08 11:48 ` Kamal, Asad
2026-06-08 13:35 ` Nicolas Bouchinet
0 siblings, 1 reply; 9+ messages in thread
From: Kamal, Asad @ 2026-06-08 11:48 UTC (permalink / raw)
To: Nicolas Bouchinet
Cc: amd-gfx@lists.freedesktop.org, Lazar, Lijo, Zhang, Hawking,
Ma, Le, Zhang, Morris, Deucher, Alexander, Wang, Yang(Kevin),
StDenis, Tom
AMD General
Hi Nicolas,
Agreed that pci_read_config() has no lockdown check, standardized PCI config space reads are not blocked under [integrity]. But amdgpu_regs is not equivalent to config space reads. It provides arbitrary read access to the full GPU MMIO register space via RREG32, which is the same class of access as pci_mmap_resource(), a user-space mapping of the PCI BAR. That function is explicitly blocked at integrity with LOCKDOWN_PCI_ACCESS:
/* drivers/pci/pci-sysfs.c */
static int pci_mmap_resource(struct kobject *kobj, ...)
{
ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
if (ret)
return ret;
...
}
pci_mmap_resource() is blocked not only because the mapping enables writes, but because it grants direct, unmediated access to the BAR, the same unmediated hardware access that amdgpu_regs provides through a serial interface. The distinction is not read vs. write, it is mediated (config space via kernel abstractions) vs. unmediated (direct BAR/MMIO access).
The /dev/mem precedent reinforces this. open_port() checks LOCKDOWN_DEV_MEM (which is before LOCKDOWN_INTEGRITY_MAX) on open, blocking both reads and writes unconditionally, because raw hardware memory access of any kind bypasses the kernel's protection model:
/* drivers/char/mem.c */
static int open_port(struct inode *inode, struct file *filp)
{
rc = security_locked_down(LOCKDOWN_DEV_MEM);
if (rc)
return rc;
...
}
RREG32 on an arbitrary register offset is the GPU equivalent of a /dev/mem read of a BAR-mapped region. Blocking it at integrity with LOCKDOWN_PCI_ACCESS is consistent with both of these existing kernel precedents.
We prefer to keep the current approach.
Thanks & Regards
Asad
-----Original Message-----
From: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
Sent: Monday, June 8, 2026 4:58 PM
To: Kamal, Asad <Asad.Kamal@amd.com>
Cc: amd-gfx@lists.freedesktop.org; Lazar, Lijo <Lijo.Lazar@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Ma, Le <Le.Ma@amd.com>; Zhang, Morris <Shiwu.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; StDenis, Tom <Tom.StDenis@amd.com>
Subject: Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
[You don't often get email from nicolas.bouchinet@oss.cyber.gouv.fr. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
On Mon, Jun 08, 2026 at 11:03:05AM +0000, Kamal, Asad wrote:
> AMD General
>
> Hi @Nicolas Bouchinet
>
> Thank you for the review.
>
> The commit message references v1 behavior and is no longer accurate. Writes are already blocked, the existing debugfs_locked_down() in fs/debugfs/file.c handles writes when FMODE_WRITE is set, the early-return guard fails and security_locked_down(LOCKDOWN_DEBUGFS) blocks the open under [integrity].
>
> The patch addresses only the read path. Here is why reads are not blocked by debugfs_locked_down():
>
> static int debugfs_locked_down(struct inode *inode,
> struct file *filp,
> const struct file_operations
> *real_fops) {
> if ((inode->i_mode & 07777 & ~0444) == 0 &&
> !(filp->f_mode & FMODE_WRITE) &&
> (!real_fops || (!real_fops->unlocked_ioctl &&
> !real_fops->compat_ioctl &&
> !real_fops->mmap)))
> return 0;
> if (security_locked_down(LOCKDOWN_DEBUGFS))
> return -EPERM;
> return 0;
> }
>
> For a read-only open of amdgpu_regs (mode 0400, no ioctl, no mmap):
>
> 1) (0400 & 07777 & ~0444) == 0 → true - any mode with no bits set outside the 0444 mask (e.g. 0400, 0440, 0444) 0400 satisfies that.
> 2) !(filp->f_mode & FMODE_WRITE) → true for a read-only open.
> 3) No unlocked_ioctl, compat_ioctl, or mmap in amdgpu_debugfs_regs_fops → true.
>
> All three conditions hold, so debugfs_locked_down() returns 0 and the read open proceeds. The read handler then calls RREG32, a direct hardware MMIO read, with no further lockdown check. That is the gap which this patch is addressing.
>
> Thanks & Regards
> Asad
Thanks Asad for your explaination !
`LOCKDOWN_PCI_ACCESS` is used in the `integrity` mode of Lockdown and should be used to protect against Kernel integrity tampering.
IIUC your issue, the access is read-only and thus, you should use one of the existing `confidentiality` lockdown_reasons. You are free to add a new one if none of the existing one covers your use case.
Best regards,
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
2026-06-08 11:48 ` Kamal, Asad
@ 2026-06-08 13:35 ` Nicolas Bouchinet
0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Bouchinet @ 2026-06-08 13:35 UTC (permalink / raw)
To: Kamal, Asad
Cc: amd-gfx@lists.freedesktop.org, Lazar, Lijo, Zhang, Hawking,
Ma, Le, Zhang, Morris, Deucher, Alexander, Wang, Yang(Kevin),
StDenis, Tom
On Mon, Jun 08, 2026 at 11:48:52AM +0000, Kamal, Asad wrote:
> AMD General
>
> Hi Nicolas,
>
> Agreed that pci_read_config() has no lockdown check, standardized PCI
> config space reads are not blocked under [integrity]. But amdgpu_regs
> is not equivalent to config space reads. It provides arbitrary read
> access to the full GPU MMIO register space via RREG32, which is the
> same class of access as pci_mmap_resource(), a user-space mapping of
> the PCI BAR. That function is explicitly blocked at integrity with
> LOCKDOWN_PCI_ACCESS:
>
> /* drivers/pci/pci-sysfs.c */
> static int pci_mmap_resource(struct kobject *kobj, ...)
> {
> ret = security_locked_down(LOCKDOWN_PCI_ACCESS);
> if (ret)
> return ret;
> ...
> }
>
> pci_mmap_resource() is blocked not only because the mapping enables writes, but because it grants direct, unmediated access to the BAR, the same unmediated hardware access that amdgpu_regs provides through a serial interface. The distinction is not read vs. write, it is mediated (config space via kernel abstractions) vs. unmediated (direct BAR/MMIO access).
>
> The /dev/mem precedent reinforces this. open_port() checks LOCKDOWN_DEV_MEM (which is before LOCKDOWN_INTEGRITY_MAX) on open, blocking both reads and writes unconditionally, because raw hardware memory access of any kind bypasses the kernel's protection model:
>
> /* drivers/char/mem.c */
> static int open_port(struct inode *inode, struct file *filp)
> {
> rc = security_locked_down(LOCKDOWN_DEV_MEM);
> if (rc)
> return rc;
> ...
> }
>
> RREG32 on an arbitrary register offset is the GPU equivalent of a /dev/mem read of a BAR-mapped region. Blocking it at integrity with LOCKDOWN_PCI_ACCESS is consistent with both of these existing kernel precedents.
>
> We prefer to keep the current approach.
>
> Thanks & Regards
> Asad
>
> -----Original Message-----
> From: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
> Sent: Monday, June 8, 2026 4:58 PM
> To: Kamal, Asad <Asad.Kamal@amd.com>
> Cc: amd-gfx@lists.freedesktop.org; Lazar, Lijo <Lijo.Lazar@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com>; Ma, Le <Le.Ma@amd.com>; Zhang, Morris <Shiwu.Zhang@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; Wang, Yang(Kevin) <KevinYang.Wang@amd.com>; StDenis, Tom <Tom.StDenis@amd.com>
> Subject: Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
>
> [You don't often get email from nicolas.bouchinet@oss.cyber.gouv.fr. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> On Mon, Jun 08, 2026 at 11:03:05AM +0000, Kamal, Asad wrote:
> > AMD General
> >
> > Hi @Nicolas Bouchinet
> >
> > Thank you for the review.
> >
> > The commit message references v1 behavior and is no longer accurate. Writes are already blocked, the existing debugfs_locked_down() in fs/debugfs/file.c handles writes when FMODE_WRITE is set, the early-return guard fails and security_locked_down(LOCKDOWN_DEBUGFS) blocks the open under [integrity].
I didn't saw that your patch changed that much, sorry for that.
With the v3 version of your patch, since the debugfs regs files are not
even created it is indeed correct to use an `integrity` lockdown_reason
like `LOCKDOWN_PCI_ACCESS`.
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-06-09 7:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 11:44 [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown Asad Kamal
2026-06-03 12:29 ` StDenis, Tom
2026-06-03 12:55 ` Kamal, Asad
2026-06-03 14:20 ` Lazar, Lijo
2026-06-08 9:03 ` Nicolas Bouchinet
2026-06-08 11:03 ` Kamal, Asad
2026-06-08 11:27 ` Nicolas Bouchinet
2026-06-08 11:48 ` Kamal, Asad
2026-06-08 13:35 ` Nicolas Bouchinet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.