AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Bouchinet <nicolas.bouchinet@oss.cyber.gouv.fr>
To: "Kamal, Asad" <Asad.Kamal@amd.com>
Cc: "amd-gfx@lists.freedesktop.org" <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
Date: Mon, 8 Jun 2026 13:27:31 +0200	[thread overview]
Message-ID: <aialwv31-f-Rt06W@archlinux> (raw)
In-Reply-To: <DM4PR12MB5038BE603641525F68C9C3018E1C2@DM4PR12MB5038.namprd12.prod.outlook.com>

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

  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
2026-06-08 11:03   ` Kamal, Asad
2026-06-08 11:27     ` Nicolas Bouchinet [this message]
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=aialwv31-f-Rt06W@archlinux \
    --to=nicolas.bouchinet@oss.cyber.gouv.fr \
    --cc=Alexander.Deucher@amd.com \
    --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 \
    --cc=Tom.StDenis@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /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