lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <741436f7fff7003aa629f8b330a248ddda592d62.camel@mediatek.com>
Date: Mon, 8 Sep 2025 03:41:47 +0000
From: CK Hu (胡俊光) <ck.hu@...iatek.com>
To: "p.zabel@...gutronix.de" <p.zabel@...gutronix.de>,
	"chunkuang.hu@...nel.org" <chunkuang.hu@...nel.org>, "johan@...nel.org"
	<johan@...nel.org>
CC: "simona@...ll.ch" <simona@...ll.ch>, "make24@...as.ac.cn"
	<make24@...as.ac.cn>, "dri-devel@...ts.freedesktop.org"
	<dri-devel@...ts.freedesktop.org>, AngeloGioacchino Del Regno
	<angelogioacchino.delregno@...labora.com>, "airlied@...il.com"
	<airlied@...il.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "matthias.bgg@...il.com"
	<matthias.bgg@...il.com>, "linux-mediatek@...ts.infradead.org"
	<linux-mediatek@...ts.infradead.org>, "stable@...r.kernel.org"
	<stable@...r.kernel.org>
Subject: Re: [PATCH 1/2] drm/mediatek: fix potential OF node use-after-free

On Fri, 2025-08-29 at 11:03 +0200, Johan Hovold wrote:
> External email : Please do not click links or open attachments until you have verified the sender or the content.
> 
> 
> The for_each_child_of_node() helper drops the reference it takes to each
> node as it iterates over children and an explicit of_node_put() is only
> needed when exiting the loop early.
> 
> Drop the recently introduced bogus additional reference count decrement
> at each iteration that could potentially lead to a use-after-free.

Reviewed-by: CK Hu <ck.hu@...iatek.com>

> 
> Fixes: 1f403699c40f ("drm/mediatek: Fix device/node reference count leaks in mtk_drm_get_all_drm_priv")
> Cc: Ma Ke <make24@...as.ac.cn>
> Cc: stable@...r.kernel.org
> Signed-off-by: Johan Hovold <johan@...nel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 34131ae2c207..3b02ed0a16da 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -388,11 +388,11 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
> 
>                 of_id = of_match_node(mtk_drm_of_ids, node);
>                 if (!of_id)
> -                       goto next_put_node;
> +                       continue;
> 
>                 pdev = of_find_device_by_node(node);
>                 if (!pdev)
> -                       goto next_put_node;
> +                       continue;
> 
>                 drm_dev = device_find_child(&pdev->dev, NULL, mtk_drm_match);
>                 if (!drm_dev)
> @@ -418,11 +418,10 @@ static bool mtk_drm_get_all_drm_priv(struct device *dev)
>  next_put_device_pdev_dev:
>                 put_device(&pdev->dev);
> 
> -next_put_node:
> -               of_node_put(node);
> -
> -               if (cnt == MAX_CRTC)
> +               if (cnt == MAX_CRTC) {
> +                       of_node_put(node);
>                         break;
> +               }
>         }
> 
>         if (drm_priv->data->mmsys_dev_num == cnt) {
> --
> 2.49.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ