dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: raoxu <raoxu@uniontech.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/debugfs: fix dentry leak when removing files
Date: Tue, 09 Jun 2026 05:49:18 +0000	[thread overview]
Message-ID: <20260609054919.018C11F00893@smtp.kernel.org> (raw)
In-Reply-To: <D43FE6467BFBCD12+20260609053655.2406749-1-raoxu@uniontech.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The backing data for the debugfs file (`i_private`) is freed before the file is removed, creating a Use-After-Free vulnerability for concurrent readers.
--

commit 64c6e87c0ad3d93de1579c3c0f9dfebb4d738254
Author: Xu Rao <raoxu@uniontech.com>

drm/debugfs: fix dentry leak when removing files

This commit fixes a dentry leak in drm_debugfs_remove_files by explicitly
calling dput after dropping the looked-up debugfs file, as debugfs_remove
does not consume the lookup reference.

> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index ae1c6126c2c59..fbaa53ec2a4c7 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -285,6 +285,7 @@ int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
>  
>  		drmm_kfree(minor->dev, d_inode(dent)->i_private);
>  		debugfs_remove(dent);

[Severity: High]
This is a pre-existing issue, but does freeing i_private before calling
debugfs_remove() create a use-after-free risk for concurrent readers?

If a concurrent process is actively reading the debugfs file when
drm_debugfs_remove_files() is called, drmm_kfree() will synchronously free
the backing data. While debugfs_remove() does synchronize SRCU to wait
for active readers to finish, that synchronization happens after the
memory has already been freed here. This sequence might allow existing
readers to dereference the freed data while they complete their operations.

> +		dput(dent);
>  	}
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/D43FE6467BFBCD12+20260609053655.2406749-1-raoxu@uniontech.com?part=1

      reply	other threads:[~2026-06-09  5:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-09  5:36 [PATCH] drm/debugfs: fix dentry leak when removing files raoxu
2026-06-09  5:49 ` sashiko-bot [this message]

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=20260609054919.018C11F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=raoxu@uniontech.com \
    --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