public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/amd/display: Fix Null Pointer Dereference Issues
@ 2024-11-05 14:01 Zicheng Qu
  2024-11-05 14:01 ` [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe Zicheng Qu
  2024-11-05 14:01 ` [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp Zicheng Qu
  0 siblings, 2 replies; 6+ messages in thread
From: Zicheng Qu @ 2024-11-05 14:01 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, simona, Dillon.Varone,
	Alvin.Lee2, nicholas.kazlauskas, alex.hung, aurabindo.pillai,
	relja.vojvodic, chiahsuan.chung, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel
  Cc: tanghui20, zhangqiao22, judy.chenhui, quzicheng

Hi all,

I am submitting two patches to fix null pointer dereference issues in
the AMD display driver.

1. Patch 1/2 (Fixes: 8e4ed3cf1642): Add null checks in
dcn20_program_pipe() to prevent potential crashes when accessing
plane_state.

2. Patch 2/2 (Fixes: 0baae6246307): Ensures pipe_ctx->plane_state is
checked in hwss_setup_dpp() to improve function stability.

Thanks for reviewing!

Zicheng Qu (2):
  drm/amd/display: Fix null check for pipe_ctx->plane_state in
    dcn20_program_pipe
  drm/amd/display: Fix null check for pipe_ctx->plane_state in
    hwss_setup_dpp

 drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c   | 3 +++
 drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe
  2024-11-05 14:01 [PATCH 0/2] drm/amd/display: Fix Null Pointer Dereference Issues Zicheng Qu
@ 2024-11-05 14:01 ` Zicheng Qu
  2024-11-14  8:20   ` Chung, ChiaHsuan (Tom)
  2024-11-05 14:01 ` [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp Zicheng Qu
  1 sibling, 1 reply; 6+ messages in thread
From: Zicheng Qu @ 2024-11-05 14:01 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, simona, Dillon.Varone,
	Alvin.Lee2, nicholas.kazlauskas, alex.hung, aurabindo.pillai,
	relja.vojvodic, chiahsuan.chung, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel
  Cc: tanghui20, zhangqiao22, judy.chenhui, quzicheng

This commit addresses a null pointer dereference issue in
dcn20_program_pipe(). Previously, commit 8e4ed3cf1642 ("drm/amd/display:
Add null check for pipe_ctx->plane_state in dcn20_program_pipe")
partially fixed the null pointer dereference issue. However, in
dcn20_update_dchubp_dpp(), the variable pipe_ctx is passed in, and
plane_state is accessed again through pipe_ctx. Multiple if statements
directly call attributes of plane_state, leading to potential null
pointer dereference issues. This patch adds necessary null checks to
ensure stability.

Fixes: 8e4ed3cf1642 ("drm/amd/display: Add null check for pipe_ctx->plane_state in dcn20_program_pipe")
Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
---
 drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
index a80c08582932..36d12db8d022 100644
--- a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
@@ -1923,9 +1923,9 @@ static void dcn20_program_pipe(
 				dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->hubp_regs.det_size);
 	}
 
-	if (pipe_ctx->update_flags.raw ||
-	    (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.raw) ||
-	    pipe_ctx->stream->update_flags.raw)
+	if (pipe_ctx->plane_state && (pipe_ctx->update_flags.raw ||
+	    pipe_ctx->plane_state->update_flags.raw ||
+	    pipe_ctx->stream->update_flags.raw))
 		dcn20_update_dchubp_dpp(dc, pipe_ctx, context);
 
 	if (pipe_ctx->plane_state && (pipe_ctx->update_flags.bits.enable ||
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp
  2024-11-05 14:01 [PATCH 0/2] drm/amd/display: Fix Null Pointer Dereference Issues Zicheng Qu
  2024-11-05 14:01 ` [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe Zicheng Qu
@ 2024-11-05 14:01 ` Zicheng Qu
  2024-11-14  8:16   ` Chung, ChiaHsuan (Tom)
  1 sibling, 1 reply; 6+ messages in thread
From: Zicheng Qu @ 2024-11-05 14:01 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, simona, Dillon.Varone,
	Alvin.Lee2, nicholas.kazlauskas, alex.hung, aurabindo.pillai,
	relja.vojvodic, chiahsuan.chung, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel
  Cc: tanghui20, zhangqiao22, judy.chenhui, quzicheng

This commit addresses a null pointer dereference issue in
hwss_setup_dpp(). The issue could occur when pipe_ctx->plane_state is
null. The fix adds a check to ensure `pipe_ctx->plane_state` is not null
before accessing. This prevents a null pointer dereference.

Fixes: 0baae6246307 ("drm/amd/display: Refactor fast update to use new HWSS build sequence")
Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
---
 drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
index 7ee2be8f82c4..bb766c2a7417 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
@@ -881,6 +881,9 @@ void hwss_setup_dpp(union block_sequence_params *params)
 	struct dpp *dpp = pipe_ctx->plane_res.dpp;
 	struct dc_plane_state *plane_state = pipe_ctx->plane_state;
 
+	if (!plane_state)
+		return;
+
 	if (dpp && dpp->funcs->dpp_setup) {
 		// program the input csc
 		dpp->funcs->dpp_setup(dpp,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp
  2024-11-05 14:01 ` [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp Zicheng Qu
@ 2024-11-14  8:16   ` Chung, ChiaHsuan (Tom)
  2024-11-18 17:12     ` Alex Deucher
  0 siblings, 1 reply; 6+ messages in thread
From: Chung, ChiaHsuan (Tom) @ 2024-11-14  8:16 UTC (permalink / raw)
  To: Zicheng Qu, harry.wentland, sunpeng.li, Rodrigo.Siqueira,
	alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
	Dillon.Varone, Alvin.Lee2, nicholas.kazlauskas, alex.hung,
	aurabindo.pillai, relja.vojvodic, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel
  Cc: tanghui20, zhangqiao22, judy.chenhui

Reviewed-by: Tom Chung <chiahsuan.chung@amd.com>

On 11/5/2024 10:01 PM, Zicheng Qu wrote:
> This commit addresses a null pointer dereference issue in
> hwss_setup_dpp(). The issue could occur when pipe_ctx->plane_state is
> null. The fix adds a check to ensure `pipe_ctx->plane_state` is not null
> before accessing. This prevents a null pointer dereference.
>
> Fixes: 0baae6246307 ("drm/amd/display: Refactor fast update to use new HWSS build sequence")
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> ---
>   drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> index 7ee2be8f82c4..bb766c2a7417 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> @@ -881,6 +881,9 @@ void hwss_setup_dpp(union block_sequence_params *params)
>   	struct dpp *dpp = pipe_ctx->plane_res.dpp;
>   	struct dc_plane_state *plane_state = pipe_ctx->plane_state;
>   
> +	if (!plane_state)
> +		return;
> +
>   	if (dpp && dpp->funcs->dpp_setup) {
>   		// program the input csc
>   		dpp->funcs->dpp_setup(dpp,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe
  2024-11-05 14:01 ` [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe Zicheng Qu
@ 2024-11-14  8:20   ` Chung, ChiaHsuan (Tom)
  0 siblings, 0 replies; 6+ messages in thread
From: Chung, ChiaHsuan (Tom) @ 2024-11-14  8:20 UTC (permalink / raw)
  To: Zicheng Qu, harry.wentland, sunpeng.li, Rodrigo.Siqueira,
	alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
	Dillon.Varone, Alvin.Lee2, nicholas.kazlauskas, alex.hung,
	aurabindo.pillai, relja.vojvodic, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel
  Cc: tanghui20, zhangqiao22, judy.chenhui

Reviewed-by: Tom Chung <chiahsuan.chung@amd.com>

On 11/5/2024 10:01 PM, Zicheng Qu wrote:
> This commit addresses a null pointer dereference issue in
> dcn20_program_pipe(). Previously, commit 8e4ed3cf1642 ("drm/amd/display:
> Add null check for pipe_ctx->plane_state in dcn20_program_pipe")
> partially fixed the null pointer dereference issue. However, in
> dcn20_update_dchubp_dpp(), the variable pipe_ctx is passed in, and
> plane_state is accessed again through pipe_ctx. Multiple if statements
> directly call attributes of plane_state, leading to potential null
> pointer dereference issues. This patch adds necessary null checks to
> ensure stability.
>
> Fixes: 8e4ed3cf1642 ("drm/amd/display: Add null check for pipe_ctx->plane_state in dcn20_program_pipe")
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> ---
>   drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
> index a80c08582932..36d12db8d022 100644
> --- a/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
> +++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c
> @@ -1923,9 +1923,9 @@ static void dcn20_program_pipe(
>   				dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->hubp_regs.det_size);
>   	}
>   
> -	if (pipe_ctx->update_flags.raw ||
> -	    (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.raw) ||
> -	    pipe_ctx->stream->update_flags.raw)
> +	if (pipe_ctx->plane_state && (pipe_ctx->update_flags.raw ||
> +	    pipe_ctx->plane_state->update_flags.raw ||
> +	    pipe_ctx->stream->update_flags.raw))
>   		dcn20_update_dchubp_dpp(dc, pipe_ctx, context);
>   
>   	if (pipe_ctx->plane_state && (pipe_ctx->update_flags.bits.enable ||

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp
  2024-11-14  8:16   ` Chung, ChiaHsuan (Tom)
@ 2024-11-18 17:12     ` Alex Deucher
  0 siblings, 0 replies; 6+ messages in thread
From: Alex Deucher @ 2024-11-18 17:12 UTC (permalink / raw)
  To: Chung, ChiaHsuan (Tom)
  Cc: Zicheng Qu, harry.wentland, sunpeng.li, Rodrigo.Siqueira,
	alexander.deucher, christian.koenig, Xinhui.Pan, airlied, simona,
	Dillon.Varone, Alvin.Lee2, nicholas.kazlauskas, alex.hung,
	aurabindo.pillai, relja.vojvodic, wenjing.liu, george.shen, mwen,
	yi-lchen, martin.leung, srinivasan.shanmugam, stylon.wang,
	jun.lei, amd-gfx, dri-devel, linux-kernel, tanghui20, zhangqiao22,
	judy.chenhui

Applied both.

Thanks!

Alex

On Thu, Nov 14, 2024 at 3:29 AM Chung, ChiaHsuan (Tom)
<chiahsuan.chung@amd.com> wrote:
>
> Reviewed-by: Tom Chung <chiahsuan.chung@amd.com>
>
> On 11/5/2024 10:01 PM, Zicheng Qu wrote:
> > This commit addresses a null pointer dereference issue in
> > hwss_setup_dpp(). The issue could occur when pipe_ctx->plane_state is
> > null. The fix adds a check to ensure `pipe_ctx->plane_state` is not null
> > before accessing. This prevents a null pointer dereference.
> >
> > Fixes: 0baae6246307 ("drm/amd/display: Refactor fast update to use new HWSS build sequence")
> > Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
> > ---
> >   drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> > index 7ee2be8f82c4..bb766c2a7417 100644
> > --- a/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> > +++ b/drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
> > @@ -881,6 +881,9 @@ void hwss_setup_dpp(union block_sequence_params *params)
> >       struct dpp *dpp = pipe_ctx->plane_res.dpp;
> >       struct dc_plane_state *plane_state = pipe_ctx->plane_state;
> >
> > +     if (!plane_state)
> > +             return;
> > +
> >       if (dpp && dpp->funcs->dpp_setup) {
> >               // program the input csc
> >               dpp->funcs->dpp_setup(dpp,

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-11-18 17:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05 14:01 [PATCH 0/2] drm/amd/display: Fix Null Pointer Dereference Issues Zicheng Qu
2024-11-05 14:01 ` [PATCH 1/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in dcn20_program_pipe Zicheng Qu
2024-11-14  8:20   ` Chung, ChiaHsuan (Tom)
2024-11-05 14:01 ` [PATCH 2/2] drm/amd/display: Fix null check for pipe_ctx->plane_state in hwss_setup_dpp Zicheng Qu
2024-11-14  8:16   ` Chung, ChiaHsuan (Tom)
2024-11-18 17:12     ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox