From: sashiko-bot@kernel.org
To: "Sasha Levin" <sashal@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH AUTOSEL 6.18-5.10] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
Date: Mon, 19 Oct 2026 15:09:39 +0000 [thread overview]
Message-ID: <sashiko-outbox-177626@kernel.org> (raw)
In-Reply-To: <20261019135441.1420968-351-sashal@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/amdgpu: init-only lockdown check in amdgpu_debugfs_regs_init() bypassed
--
commit d191beaf95739f7c453353f0fddff9c76024a56e
Author: Asad Kamal <asad.kamal@amd.com>
drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
This commit skips creating hardware register debugfs nodes in
amdgpu_debugfs_regs_init() when kernel lockdown (LOCKDOWN_PCI_ACCESS) is
active during initialization.
> drm/amdgpu: Gate debugfs MMIO access on kernel lockdown
>
> [ Upstream commit 17ac73b24006700f50972d37e297dec1f523c14a ]
>
> 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>
> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> index a70651050acff..5dac8f0f34143 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
[ ... ]
> @@ -1646,6 +1647,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,
[Severity: Medium]
Can this lockdown check be bypassed when kernel lockdown is enabled at
runtime after the driver has already probed?
If amdgpu initializes before lockdown is enabled (for example, when built-in
or loaded from initramfs) and userspace later enables integrity or
confidentiality lockdown by writing to /sys/kernel/security/lockdown via
lockdown_write() -> lock_kernel_down(), amdgpu_debugfs_regs_init() has
already created the debugfs_regs files with mode 0400:
security/lockdown/lockdown.c:lockdown_write() {
...
if (label && !strcmp(state, label))
err = lock_kernel_down("securityfs", level);
...
}
Because amdgpu_regs, amdgpu_regs_didt, amdgpu_regs_pcie, amdgpu_regs_smc,
amdgpu_wave, and amdgpu_gpr have mode 0400 and their file_operations structs
do not define .unlocked_ioctl, .compat_ioctl, or .mmap, opening them with
O_RDONLY is permitted by debugfs_locked_down() without consulting
security_locked_down(LOCKDOWN_DEBUGFS):
fs/debugfs/file.c:debugfs_locked_down() {
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;
}
Subsequent read() calls then reach amdgpu_debugfs_process_reg_op() and its
sibling handlers with no security_locked_down(LOCKDOWN_PCI_ACCESS) check,
allowing arbitrary RREG32() reads as well as MMIO writes to bank and index
selection registers such as GRBM_GFX_INDEX via amdgpu_gfx_select_se_sh() and
SRBM_GFX_CNTL via amdgpu_gfx_select_me_pipe_q(). In addition, any file
descriptor opened O_RDWR before lockdown was activated retains unrestricted
MMIO write and ioctl access (WREG32() / amdgpu_mm_wreg_mmio_rlc()) after
lockdown is enabled.
Also, the commit message body still states:
"Check LOCKDOWN_PCI_ACCESS (matching pci-sysfs) at the entry of every
debugfs handler that performs direct register access."
Should security_locked_down(LOCKDOWN_PCI_ACCESS) also be checked in the
debugfs file operations handlers (or should the commit message be updated to
match the v3 implementation)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261019135441.1420968-351-sashal@kernel.org?part=1
next prev parent reply other threads:[~2026-10-19 15:09 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261019135441.1420968-1-sashal@kernel.org>
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-6.6] drm/amdgpu: add buf length check Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] drm/amd/pm: Validate Vega hwmgr PowerPlay table bounds Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18] drm/amdgpu: validate XCP topology counts before division Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18] drm/panel-edp: Add BOE NE140QDM-NX2 Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] drm/panel: simple: Add Kyocera tcg070wvlq panel Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-6.1] drm/amdgpu/gfx11: WARN() rather than BUG() for invalid SDMA engine Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18] drm/amdgpu: Validate ATPX buffer length before use Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] drm/amd/pm: Validate legacy hwmgr PP table offsets Sasha Levin
2026-10-19 14:28 ` sashiko-bot
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18] drm/amd/display: Fix rounding errors in CalculatePrefetchSchedule Sasha Levin
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] drm/amdgpu: Validate ATIF buffer length before use Sasha Levin
2026-10-19 14:22 ` sashiko-bot
2026-10-19 13:45 ` [PATCH AUTOSEL 6.18-5.10] drm/amdgpu: Add checks to vbios fetch through ATRM Sasha Levin
2026-10-19 13:46 ` [PATCH AUTOSEL 6.18] drm/amd/pm: derive stable PPT limits from PPTable Sasha Levin
2026-10-19 14:32 ` sashiko-bot
2026-10-19 13:46 ` [PATCH AUTOSEL 6.18-6.12] drm/msm/adreno: Add support for A704 GPU Sasha Levin
2026-10-19 13:46 ` [PATCH AUTOSEL 6.18-6.12] drm/xe: only resume exec queues that were actually suspended Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-6.1] drm/amd/pm: Use uploaded size for legacy custom PPTable Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-5.10] gpu: host1x: Wait for timeout worker completion on channel free Sasha Levin
2026-10-19 14:39 ` sashiko-bot
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-5.10] fbdev: udlfb: validate vendor descriptor items Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-5.10] fbdev: maxine: fix 64-bit build error Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18] drm/msm: Move nr_cmds initialization Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18] drm/amdgpu: Fix kobject cleanup in xcp sysfs Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18] drm/amdgpu/mes_v12_0: use mes schedule pipe for legacy queues on unified MES Sasha Levin
2026-10-19 13:47 ` [PATCH AUTOSEL 6.18-6.1] drm/virtio: reclaim pending vbufs before tearing down vqs Sasha Levin
2026-10-19 13:48 ` [PATCH AUTOSEL 6.18-5.15] drm/amd/pm: Validate Tonga PPTable subtable bounds Sasha Levin
2026-10-19 14:47 ` sashiko-bot
2026-10-19 13:48 ` [PATCH AUTOSEL 6.18-6.12] drm/etnaviv: force flush on power register ops Sasha Levin
2026-10-19 13:48 ` [PATCH AUTOSEL 6.18-5.10] drm/amdgpu: Support some Barco AMD based graphics adapters Sasha Levin
2026-10-19 13:48 ` [PATCH AUTOSEL 6.18-5.10] drm/amd/pm: validate vega10 profile mode inputs Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18] drm/amdgpu: add check for xcp id Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18-6.1] drm/amdgpu: add bounds check to prevent array overflow Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18] drm/msm: detach the ARM DMA mapping before attaching our own domain Sasha Levin
2026-10-19 14:59 ` sashiko-bot
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18-6.6] drm/amd/pm: Validate Vega10 PPTable subtable bounds Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18] drm/sysfb: simpledrm: Validate mmap size against framebuffer size Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18-6.12] drm/panel-edp: Support MB116AS01'3 edp panel Sasha Levin
2026-10-19 13:49 ` [PATCH AUTOSEL 6.18-5.10] drm/etnaviv: check all modules for idle after reset Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18] drm/panel: panel-edp: Adjust T8 timing for AUO B116XAK01.6 and B140XTK02.4 Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-5.10] fbdev: omap2: dsi: do not copy isr table Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-6.6] drm/radeon: fix internal display on iMac11, 1 (RV770/DCE3.1) Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18] drm/etnaviv: check MMUv2 status after reset Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-6.6] drm/panel-edp: Add BOE NE160QDM-NY1 panel Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-6.12] drm/amd/display: fix max dispclk_khz/dppclk_khz double 1000 Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18] drm/panel-edp: Add BOE NV116WH2-M30, BOE NT116WHM-N21, BOE NV116FH1-M31, BOE NV116FH1-M30 Sasha Levin
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-5.10] drm/rockchip: dw_hdmi: Use resume_early pm ops for system suspend Sasha Levin
2026-10-19 15:06 ` sashiko-bot
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-5.10] drm/amdgpu: Gate debugfs MMIO access on kernel lockdown Sasha Levin
2026-10-19 15:09 ` sashiko-bot [this message]
2026-10-19 13:50 ` [PATCH AUTOSEL 6.18-5.10] fbcon: Fix KASAN slab-out-of-bounds Read in fbcon_prepare_logo Sasha Levin
2026-10-19 13:51 ` [PATCH AUTOSEL 6.18] drm/amdkfd: use node XCC count for v9 CRIU control stack restore Sasha Levin
2026-10-19 13:51 ` [PATCH AUTOSEL 6.18-5.10] drm/amd/pm: Validate OD DPM triples before mutating tables Sasha Levin
2026-10-19 13:51 ` [PATCH AUTOSEL 6.18] drm/virtio: abort virtqueue wait on device removal to avoid hung task Sasha Levin
2026-10-19 15:24 ` sashiko-bot
2026-10-19 13:51 ` [PATCH AUTOSEL 6.18-5.10] drm/amd/pm: Validate Tonga PowerPlay state array bounds Sasha Levin
2026-10-19 13:51 ` [PATCH AUTOSEL 6.18-5.15] drm/amd/pm: Guard VBIOS AC timing table walk Sasha Levin
2026-10-19 15:20 ` sashiko-bot
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18-6.1] drm/amd/pm: Validate pp_table header before reading size Sasha Levin
2026-10-19 15:31 ` sashiko-bot
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18] drm/msm: Fix barriers accessing ctx vm Sasha Levin
2026-10-19 15:27 ` sashiko-bot
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18-6.1] drm/amdgpu/atomfirmware: WARN() rather than BUG() Sasha Levin
2026-10-19 15:24 ` sashiko-bot
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18] drm/amdgpu/gfx12: set KMD_QUEUE for kernel gfx queues Sasha Levin
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18-6.12] drm/amdgpu: Guard reads in pcie state readout Sasha Levin
2026-10-19 15:24 ` sashiko-bot
2026-10-19 13:52 ` [PATCH AUTOSEL 6.18] drm/amdkfd: Fix signal reset event Sasha Levin
2026-10-19 13:53 ` [PATCH AUTOSEL 6.18-5.10] drm/radeon: avoid double free in r600 DPM cleanup Sasha Levin
2026-10-19 15:33 ` sashiko-bot
2026-10-19 13:53 ` [PATCH AUTOSEL 6.18-6.1] drm/amdkfd: add sanity check in svm_range_is_valid Sasha Levin
2026-10-19 15:36 ` sashiko-bot
2026-10-19 13:53 ` [PATCH AUTOSEL 6.18] drm/amdgpu/gfx11: set KMD_QUEUE for kernel gfx queues Sasha Levin
2026-10-19 13:53 ` [PATCH AUTOSEL 6.18-5.10] fbdev: platinumfb: add error checking for ioremap calls Sasha Levin
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=sashiko-outbox-177626@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashal@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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