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] [thread-next>] [day] [month] [year] [list]
Message-ID: <a68022f4-28d0-7743-27fe-6df652082184@suse.de>
Date:   Fri, 29 Jul 2022 16:23:21 +0200
From:   Thomas Zimmermann <tzimmermann@...e.de>
To:     Zeng Jingxiang <zengjx95@...il.com>, anitha.chrisanthus@...el.com,
        edmund.j.dea@...el.com, airlied@...ux.ie, daniel@...ll.ch,
        laurent.pinchart@...asonboard.com, maxime@...no.tech,
        ville.syrjala@...ux.intel.com
Cc:     dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
        Zeng Jingxiang <linuszeng@...cent.com>
Subject: Re: [PATCH] drm/kmb: fix dereference before NULL check in
 kmb_plane_atomic_update()

Hi

Am 29.07.22 um 05:07 schrieb Zeng Jingxiang:
> From: Zeng Jingxiang <linuszeng@...cent.com>
> 
> The "plane" pointer was access before checking if it was NULL.
> 
> The drm_atomic_get_old_plane_state() function will dereference
> the pointer "plane".
> 345	struct drm_plane_state *old_plane_state =
> 		drm_atomic_get_old_plane_state(state, plane);
> 346	struct drm_plane_state *new_plane_state =
> 		drm_atomic_get_new_plane_state(state, plane);
> 
> A NULL check for "plane" indicates that it may be NULL
> 363	if (!plane || !new_plane_state || !old_plane_state)

Is this an actual bug that happens?

All planes should always have a state. Therefore the tests for 
!new_plane_state and !old_plane_state can be removed, I'd say.

Best regards
Thomas

> 
> Fixes: 977697e20b3d ("drm/atomic: Pass the full state to planes atomic disable and update")
> Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state pointer")
> Signed-off-by: Zeng Jingxiang <linuszeng@...cent.com>
> ---
>   drivers/gpu/drm/kmb/kmb_plane.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index 2735b8eb3537..d2bc998b65ce 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -342,10 +342,7 @@ static void kmb_plane_set_alpha(struct kmb_drm_private *kmb,
>   static void kmb_plane_atomic_update(struct drm_plane *plane,
>   				    struct drm_atomic_state *state)
>   {
> -	struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
> -										 plane);
> -	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
> -										 plane);
> +	struct drm_plane_state *old_plane_state, *new_plane_state;
>   	struct drm_framebuffer *fb;
>   	struct kmb_drm_private *kmb;
>   	unsigned int width;
> @@ -360,7 +357,13 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
>   	static dma_addr_t addr[MAX_SUB_PLANES];
>   	struct disp_cfg *init_disp_cfg;
>   
> -	if (!plane || !new_plane_state || !old_plane_state)
> +	if (!plane)
> +		return;
> +
> +	old_plane_state = drm_atomic_get_old_plane_state(state, plane);
> +	new_plane_state = drm_atomic_get_new_plane_state(state, plane);
> +
> +	if (!new_plane_state || !old_plane_state)
>   		return;
>   
>   	fb = new_plane_state->fb;

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

Download attachment "OpenPGP_signature" of type "application/pgp-signature" (841 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ