Re: [PATCH] debugfs: Fix lockdown check for mmap_prepare

From: joeyli

Date: Fri Jun 12 2026 - 04:58:31 EST


Hi Lorenzo,

Thanks for your review!

On Fri, Jun 12, 2026 at 08:28:29AM +0100, Lorenzo Stoakes wrote:
> -cc wrong email
>
> (Please make sure to use my correct email address - ljs@xxxxxxxxxx -
> I usually do not see emails sent to the incorrect one)
>
> +From: Chun-Yi Lee <jlee@xxxxxxxx>
>
> (You're sending from a different email address so you need to explicitly
> add a From: xxx tag to match the S-o-b at the top of the message)
>

I will use your kernel.org email address and put From: tag.

>
> On Fri, Jun 12, 2026 at 01:54:55PM +0800, Chun-Yi Lee wrote:
> > Commit 651fdda8406d ("relay: update relay to use mmap_prepare")
> > changed the `mmap` file operation to `mmap_prepare` for relayfs, but
> > the lockdown check in debugfs was not updated accordingly.
> >
> > This prevents debugfs from being locked down when the kernel is in
> > integrity mode if a file uses `mmap_prepare` but not `mmap`.
> >
> > Update the lockdown check to look for `mmap_prepare` instead of `mmap`
> > to fix this.
> >
> > Fixes: 651fdda8406d ("relay: update relay to use mmap_prepare")
>
> You need to explicitly add:
>
> Cc: stable@xxxxxxxxxxxxxxx
>
> As we will want this backported.
>

I will add cc. to stable mailing list.

> > Signed-off-by: Chun-Yi Lee <jlee@xxxxxxxx>
>
> I think the idea is correct, but needs tweaking to cover _both_ mmap and
> mmap_prepare, until the mmap_prepare conversion is complete, see below.
>
> > Cc: David Howells <dhowells@xxxxxxxxxx>
> > Cc: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
> > cc: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
> > cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Rafael J. Wysocki <rafael@xxxxxxxxxx>
> > Cc: Matthew Garrett <matthewgarrett@xxxxxxxxxx>
> > Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> > Cc: Danilo Krummrich <dakr@xxxxxxxxxx>
> > Cc: driver-core@xxxxxxxxxxxxxxx
> > Cc: linux-kernel@xxxxxxxxxxxxxxx
> > ---
> > fs/debugfs/file.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
> > index edd6aafbfbaa..d5e187895dd8 100644
> > --- a/fs/debugfs/file.c
> > +++ b/fs/debugfs/file.c
> > @@ -273,7 +273,7 @@ static int debugfs_locked_down(struct inode *inode,
> > (!real_fops ||
> > (!real_fops->unlocked_ioctl &&
> > !real_fops->compat_ioctl &&
> > - !real_fops->mmap)))
> > + !real_fops->mmap_prepare)))
>
> This is not only applicable to relayfs.
>
> So while we both have mmap and mmap_prepare, this should be:
>
> - !real_fops->mmap)))
> + !real_fops->mmap &&
> + !real_fops->mmap_prepare)))
>

Yes, thanks a lot! I will send v2 patch.

Joey Lee