linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/simpledrm: Fix return type of simpledrm_simple_display_pipe_mode_valid()
@ 2022-07-25 23:36 Nathan Chancellor
  2022-07-26  0:12 ` Sami Tolvanen
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2022-07-25 23:36 UTC (permalink / raw)
  To: Thomas Zimmermann, Javier Martinez Canillas
  Cc: Sami Tolvanen, Kees Cook, dri-devel, linux-kernel, llvm,
	Nathan Chancellor, stable, Tomasz Paweł Gajc

When booting a kernel compiled with clang's CFI protection
(CONFIG_CFI_CLANG), there is a CFI failure in
drm_simple_kms_crtc_mode_valid() when trying to call
simpledrm_simple_display_pipe_mode_valid() through ->mode_valid():

[    0.322802] CFI failure (target: simpledrm_simple_display_pipe_mode_valid+0x0/0x8):
...
[    0.324928] Call trace:
[    0.324969]  __ubsan_handle_cfi_check_fail+0x58/0x60
[    0.325053]  __cfi_check_fail+0x3c/0x44
[    0.325120]  __cfi_slowpath_diag+0x178/0x200
[    0.325192]  drm_simple_kms_crtc_mode_valid+0x58/0x80
[    0.325279]  __drm_helper_update_and_validate+0x31c/0x464
...

The ->mode_valid() member in 'struct drm_simple_display_pipe_funcs'
expects a return type of 'enum drm_mode_status', not 'int'. Correct it
to fix the CFI failure.

Cc: stable@vger.kernel.org
Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
Link: https://github.com/ClangBuiltLinux/linux/issues/1647
Reported-by: Tomasz Paweł Gajc <tpgxyz@gmail.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/gpu/drm/tiny/simpledrm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
index 768242a78e2b..5422363690e7 100644
--- a/drivers/gpu/drm/tiny/simpledrm.c
+++ b/drivers/gpu/drm/tiny/simpledrm.c
@@ -627,7 +627,7 @@ static const struct drm_connector_funcs simpledrm_connector_funcs = {
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };
 
-static int
+static enum drm_mode_status
 simpledrm_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
 				    const struct drm_display_mode *mode)
 {

base-commit: e0dccc3b76fb35bb257b4118367a883073d7390e
-- 
2.37.1


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

* Re: [PATCH] drm/simpledrm: Fix return type of simpledrm_simple_display_pipe_mode_valid()
  2022-07-25 23:36 [PATCH] drm/simpledrm: Fix return type of simpledrm_simple_display_pipe_mode_valid() Nathan Chancellor
@ 2022-07-26  0:12 ` Sami Tolvanen
  2022-07-26 15:38   ` Thomas Zimmermann
  0 siblings, 1 reply; 3+ messages in thread
From: Sami Tolvanen @ 2022-07-26  0:12 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Thomas Zimmermann, Javier Martinez Canillas, Kees Cook,
	dri-devel, LKML, llvm, # 3.4.x, Tomasz Paweł Gajc

On Mon, Jul 25, 2022 at 4:37 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> When booting a kernel compiled with clang's CFI protection
> (CONFIG_CFI_CLANG), there is a CFI failure in
> drm_simple_kms_crtc_mode_valid() when trying to call
> simpledrm_simple_display_pipe_mode_valid() through ->mode_valid():
>
> [    0.322802] CFI failure (target: simpledrm_simple_display_pipe_mode_valid+0x0/0x8):
> ...
> [    0.324928] Call trace:
> [    0.324969]  __ubsan_handle_cfi_check_fail+0x58/0x60
> [    0.325053]  __cfi_check_fail+0x3c/0x44
> [    0.325120]  __cfi_slowpath_diag+0x178/0x200
> [    0.325192]  drm_simple_kms_crtc_mode_valid+0x58/0x80
> [    0.325279]  __drm_helper_update_and_validate+0x31c/0x464
> ...
>
> The ->mode_valid() member in 'struct drm_simple_display_pipe_funcs'
> expects a return type of 'enum drm_mode_status', not 'int'. Correct it
> to fix the CFI failure.
>
> Cc: stable@vger.kernel.org
> Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1647
> Reported-by: Tomasz Paweł Gajc <tpgxyz@gmail.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  drivers/gpu/drm/tiny/simpledrm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
> index 768242a78e2b..5422363690e7 100644
> --- a/drivers/gpu/drm/tiny/simpledrm.c
> +++ b/drivers/gpu/drm/tiny/simpledrm.c
> @@ -627,7 +627,7 @@ static const struct drm_connector_funcs simpledrm_connector_funcs = {
>         .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>  };
>
> -static int
> +static enum drm_mode_status
>  simpledrm_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
>                                     const struct drm_display_mode *mode)
>  {

Thanks for fixing this, Nathan! The patch looks correct to me.

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>

Sami

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

* Re: [PATCH] drm/simpledrm: Fix return type of simpledrm_simple_display_pipe_mode_valid()
  2022-07-26  0:12 ` Sami Tolvanen
@ 2022-07-26 15:38   ` Thomas Zimmermann
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2022-07-26 15:38 UTC (permalink / raw)
  To: Sami Tolvanen, Nathan Chancellor
  Cc: Tomasz Paweł Gajc, Kees Cook, llvm, LKML, dri-devel,
	Javier Martinez Canillas, # 3.4.x


[-- Attachment #1.1: Type: text/plain, Size: 2392 bytes --]

Hi

Am 26.07.22 um 02:12 schrieb Sami Tolvanen:
> On Mon, Jul 25, 2022 at 4:37 PM Nathan Chancellor <nathan@kernel.org> wrote:
>>
>> When booting a kernel compiled with clang's CFI protection
>> (CONFIG_CFI_CLANG), there is a CFI failure in
>> drm_simple_kms_crtc_mode_valid() when trying to call
>> simpledrm_simple_display_pipe_mode_valid() through ->mode_valid():
>>
>> [    0.322802] CFI failure (target: simpledrm_simple_display_pipe_mode_valid+0x0/0x8):
>> ...
>> [    0.324928] Call trace:
>> [    0.324969]  __ubsan_handle_cfi_check_fail+0x58/0x60
>> [    0.325053]  __cfi_check_fail+0x3c/0x44
>> [    0.325120]  __cfi_slowpath_diag+0x178/0x200
>> [    0.325192]  drm_simple_kms_crtc_mode_valid+0x58/0x80
>> [    0.325279]  __drm_helper_update_and_validate+0x31c/0x464
>> ...
>>
>> The ->mode_valid() member in 'struct drm_simple_display_pipe_funcs'
>> expects a return type of 'enum drm_mode_status', not 'int'. Correct it
>> to fix the CFI failure.
>>
>> Cc: stable@vger.kernel.org
>> Fixes: 11e8f5fd223b ("drm: Add simpledrm driver")
>> Link: https://github.com/ClangBuiltLinux/linux/issues/1647
>> Reported-by: Tomasz Paweł Gajc <tpgxyz@gmail.com>
>> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>> ---
>>   drivers/gpu/drm/tiny/simpledrm.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/tiny/simpledrm.c b/drivers/gpu/drm/tiny/simpledrm.c
>> index 768242a78e2b..5422363690e7 100644
>> --- a/drivers/gpu/drm/tiny/simpledrm.c
>> +++ b/drivers/gpu/drm/tiny/simpledrm.c
>> @@ -627,7 +627,7 @@ static const struct drm_connector_funcs simpledrm_connector_funcs = {
>>          .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
>>   };
>>
>> -static int
>> +static enum drm_mode_status
>>   simpledrm_simple_display_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
>>                                      const struct drm_display_mode *mode)
>>   {
> 
> Thanks for fixing this, Nathan! The patch looks correct to me.
> 
> Reviewed-by: Sami Tolvanen <samitolvanen@google.com>

Thanks a lot. I've added the patch to drm-misc-fixes.

Best regards
Thomas

> 
> Sami

-- 
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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

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

end of thread, other threads:[~2022-07-26 15:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-25 23:36 [PATCH] drm/simpledrm: Fix return type of simpledrm_simple_display_pipe_mode_valid() Nathan Chancellor
2022-07-26  0:12 ` Sami Tolvanen
2022-07-26 15:38   ` Thomas Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).