From: sashiko-bot@kernel.org
To: "Fabio Estevam" <festevam@gmail.com>
Cc: imx@lists.linux.dev, dri-devel@lists.freedesktop.org,
Frank.Li@kernel.org
Subject: Re: [PATCH] drm/mxsfb: lcdif: Fix use-after-free on unbind
Date: Wed, 09 Sep 2026 21:14:55 +0000 [thread overview]
Message-ID: <20260909211456.0DAF21F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260909210213.946159-1-festevam@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Unmapped MMIO Access (Hot-unplug protection)
- [High] Missing Error Handling for pm_runtime_get_sync
--
commit 66de576415540b0c76cf173d95116edc4c840ef4
Author: Fabio Estevam <festevam@gmail.com>
drm/mxsfb: lcdif: Fix use-after-free on unbind
This patch fixes a use-after-free issue during LCDIF unbind by allocating
the DRM private data and encoders using drmm APIs instead of devres. This
ensures the DRM objects remain alive until mode config cleanup completes.
> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> index e2173c4d6fc28..7e9f3b205a458 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
[ ... ]
While reviewing this patch, I noticed a couple of related pre-existing issues
in drivers/gpu/drm/mxsfb/lcdif_kms.c:
> drivers/gpu/drm/mxsfb/lcdif_kms.c:lcdif_crtc_atomic_enable() {
> ...
> clk_set_rate(lcdif->clk, m->clock * 1000);
>
> pm_runtime_get_sync(drm->dev);
>
> lcdif_crtc_mode_set_nofb(new_cstate, new_pstate);
> ...
> }
[Severity: High]
This is a pre-existing issue, but the return value of pm_runtime_get_sync()
is ignored here.
If this call fails (due to a hardware fault or intermediate PM state), the
driver unconditionally proceeds to execute lcdif_crtc_mode_set_nofb(), which
writes to hardware registers. Can this lead to a kernel panic (Synchronous
External Abort) by accessing unpowered hardware registers?
> drivers/gpu/drm/mxsfb/lcdif_kms.c:lcdif_plane_primary_atomic_update() {
> ...
> paddr = drm_fb_dma_get_gem_addr(new_pstate->fb, new_pstate, 0);
> if (paddr) {
> writel(lower_32_bits(paddr),
> lcdif->base + LCDC_V8_CTRLDESCL_LOW0_4);
> writel(CTRLDESCL_HIGH0_4_ADDR_HIGH(upper_32_bits(paddr)),
> lcdif->base + LCDC_V8_CTRLDESCL_HIGH0_4);
> }
> }
[Severity: High]
This is a pre-existing issue, but could this access the lcdif->base MMIO
region after it has been unmapped by devres?
If a privileged user unbinds the driver via sysfs but a userspace process
keeps the DRM device open, drm_dev_unregister() is called but
drm_dev_unplug() is not. Because drm_dev_is_unplugged() would return false,
an ioctl like DRM_IOCTL_MODE_ATOMIC could still execute and trigger
lcdif_plane_primary_atomic_update(). Would this result in a synchronous
abort/kernel panic when accessing the unmapped memory?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909210213.946159-1-festevam@gmail.com?part=1
prev parent reply other threads:[~2026-09-09 21:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 21:02 [PATCH] drm/mxsfb: lcdif: Fix use-after-free on unbind Fabio Estevam
2026-09-09 21:14 ` 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=20260909211456.0DAF21F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--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