AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
To: Asad Kamal <asad.kamal@amd.com>
Cc: amd-gfx@lists.freedesktop.org, lijo.lazar@amd.com,
	 hawking.zhang@amd.com, le.ma@amd.com, shiwu.zhang@amd.com,
	alexander.deucher@amd.com, kevinyang.wang@amd.com,
	Tom.StDenis@amd.com
Subject: Re: [PATCH v3] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
Date: Mon, 8 Jun 2026 11:03:46 +0200	[thread overview]
Message-ID: <aiaEMl-b5qo6dmL6@archlinux> (raw)
In-Reply-To: <20260603114459.938031-1-asad.kamal@amd.com>

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

  parent reply	other threads:[~2026-06-09  7:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aiaEMl-b5qo6dmL6@archlinux \
    --to=nicolas.bouchinet@oss.cyber.gouv.fr \
    --cc=Tom.StDenis@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=asad.kamal@amd.com \
    --cc=hawking.zhang@amd.com \
    --cc=kevinyang.wang@amd.com \
    --cc=le.ma@amd.com \
    --cc=lijo.lazar@amd.com \
    --cc=shiwu.zhang@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox