Message ID | 20221102154215.78059-1-nathan@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3695131wru; Wed, 2 Nov 2022 08:46:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6b2XxBLsx83/Z+ogqjWDNomzak9M1YkjcFULHRppjnTmCWULPq5oQbcQqJKyp5cq+pu40L X-Received: by 2002:a65:6404:0:b0:46f:a711:c481 with SMTP id a4-20020a656404000000b0046fa711c481mr17060141pgv.262.1667403969045; Wed, 02 Nov 2022 08:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667403969; cv=none; d=google.com; s=arc-20160816; b=D4o8Z8bZpnvxjbaTXX9GCRlN1+TxK0wuhoOwITVKwg9dgFiN5+xLqhsVjC4bWLGfid ev3AQhoo0mr+hhfNz8ZFwxGJ/sDhgdQFILKruYHGax0xCwdq1xDdFox9YBbvGyIQnlIO tVYso5kgZ/HFXEeM3rPpziY7smPV7VHyrfLPjvaBXnrYOlvyUw/uhDpfLigrYhx4i426 bb5TVpuHZTPfn4l/SRE0RgUL11jZbz9iGspGUVN2J6Gag+x/czZ0TG12HE1K+Pf3A96W R2oc1pZPXYloU3Y4b08o9e6BJrvlqbOXHhh40ebP93Ect5+0kwU5XzSJmngRvBSMFFcg aqiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=naNPTebMx/UKG/tomS1KX9OoI173cB3LdjHE/97zLhI=; b=FKeLiDtBpHOj61voyAkr8MI7vsicGfnRWQHCKclsgTWU9ZrsmqWoEMcPZv//LW3EcW 5Vorxblr2wlzrC/Mbh9kahhzwylQUpyiZeJSoHclYW7TLzooWCrCpOFo11nCmRPGbw9v Qe7iitUFqvGlzfX1zyHSxYYMq6Ixj+B+9RYsFGk6u9Wrp6/LXfrfQmNAoYIsVsuKRIl0 jSPAkJ6FjRu9djwmVFgW8oWXbpqFB/0QkiUGcBsfmU/qag4D+wcvAKKEazPfy+0ywS30 vkbbFvpNZaraIXUiWNKj6siKNJCvGeGTYg4ruUrdRDGTv7A/Fp9Ta/2KS81bWMXATz5G DEQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nj1itTaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay5-20020a17090b030500b00200acd39846si2361499pjb.63.2022.11.02.08.45.56; Wed, 02 Nov 2022 08:46:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nj1itTaP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbiKBPmW (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 11:42:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiKBPmV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 11:42:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0247213D14 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 08:42:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 809E561920 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 15:42:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31D96C433C1; Wed, 2 Nov 2022 15:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667403738; bh=RTU4MJOahPxQfCprS6dXSJ2bZU9D7vmWqFb7hhBnnks=; h=From:To:Cc:Subject:Date:From; b=nj1itTaPmyeeCs1glxmOJOEgYHi2qenyZdtfMmFxDLb6RkKgSb8ximzR3or++OZvb o3kRbCDxiGm7/ju/RBv5l9o1+4lm1GODplKBOpsqP8+kRC4p4mdfoSeNVRTDrDEnss xJq44D1a/pEaxS7PErjZmtT1BA9cRSpIfl/mvyCS0WGFCBo7E2j1YbJUEh8nObZFje OabUmowetibTC6TqsmCiZ6BoOqt5kb0vO8ZUkhz5q6xBbCBUocFknhZci0hr6yOlm2 OUrjI0iljGmaC2seHYbjucGiJYf8baJqougkWOhZ2RtGXZXaoZGudhGkYXCIvLNEMm qPKFMarAjG8Mg== From: Nathan Chancellor <nathan@kernel.org> To: Stefan Agner <stefan@agner.ch>, Alison Wang <alison.wang@nxp.com> Cc: dri-devel@lists.freedesktop.org, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Kees Cook <keescook@chromium.org>, Sami Tolvanen <samitolvanen@google.com>, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Nathan Chancellor <nathan@kernel.org> Subject: [PATCH] drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() Date: Wed, 2 Nov 2022 08:42:15 -0700 Message-Id: <20221102154215.78059-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748399784572221984?= X-GMAIL-MSGID: =?utf-8?q?1748399784572221984?= |
Series |
drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid()
|
|
Commit Message
Nathan Chancellor
Nov. 2, 2022, 3:42 p.m. UTC
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
indirect call targets are validated against the expected function
pointer prototype to make sure the call target is valid to help mitigate
ROP attacks. If they are not identical, there is a failure at run time,
which manifests as either a kernel panic or thread getting killed. A
proposed warning in clang aims to catch these at compile time, which
reveals:
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c:74:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = fsl_dcu_drm_connector_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_connector_helper_funcs' expects a return
type of 'enum drm_mode_status', not 'int'. Adjust the return type of
fsl_dcu_drm_connector_mode_valid() to match the prototype's to resolve
the warning and CFI failure.
Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Reported-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
Comments
On Wed, Nov 02, 2022 at 08:42:15AM -0700, Nathan Chancellor wrote: > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), > indirect call targets are validated against the expected function > pointer prototype to make sure the call target is valid to help mitigate > ROP attacks. If they are not identical, there is a failure at run time, > which manifests as either a kernel panic or thread getting killed. A > proposed warning in clang aims to catch these at compile time, which > reveals: > > drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c:74:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = fsl_dcu_drm_connector_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->mode_valid() in 'struct drm_connector_helper_funcs' expects a return > type of 'enum drm_mode_status', not 'int'. Adjust the return type of > fsl_dcu_drm_connector_mode_valid() to match the prototype's to resolve > the warning and CFI failure. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Reported-by: Sami Tolvanen <samitolvanen@google.com> > Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
Hi all, On Wed, Nov 02, 2022 at 08:42:15AM -0700, Nathan Chancellor wrote: > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), > indirect call targets are validated against the expected function > pointer prototype to make sure the call target is valid to help mitigate > ROP attacks. If they are not identical, there is a failure at run time, > which manifests as either a kernel panic or thread getting killed. A > proposed warning in clang aims to catch these at compile time, which > reveals: > > drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c:74:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = fsl_dcu_drm_connector_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->mode_valid() in 'struct drm_connector_helper_funcs' expects a return > type of 'enum drm_mode_status', not 'int'. Adjust the return type of > fsl_dcu_drm_connector_mode_valid() to match the prototype's to resolve > the warning and CFI failure. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > Reported-by: Sami Tolvanen <samitolvanen@google.com> > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > --- > drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > index 4d4a715b429d..2c2b92324a2e 100644 > --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > @@ -60,8 +60,9 @@ static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector) > return drm_panel_get_modes(fsl_connector->panel, connector); > } > > -static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, > - struct drm_display_mode *mode) > +static enum drm_mode_status > +fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, > + struct drm_display_mode *mode) > { > if (mode->hdisplay & 0xf) > return MODE_ERROR; > > base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780 > -- > 2.38.1 > > Could someone please pick this up so that it makes 6.2? We would like to try and get this warning turned on so that it can catch more potential run time issues at compile time but that can only happen when all the warnings are fixed. Cheers, Nathan
On Mon, Nov 14, 2022 at 03:03:05PM -0700, Nathan Chancellor wrote: > Hi all, > > On Wed, Nov 02, 2022 at 08:42:15AM -0700, Nathan Chancellor wrote: > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), > > indirect call targets are validated against the expected function > > pointer prototype to make sure the call target is valid to help mitigate > > ROP attacks. If they are not identical, there is a failure at run time, > > which manifests as either a kernel panic or thread getting killed. A > > proposed warning in clang aims to catch these at compile time, which > > reveals: > > > > drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c:74:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_connector *, struct drm_display_mode *)' with an expression of type 'int (struct drm_connector *, struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > > .mode_valid = fsl_dcu_drm_connector_mode_valid, > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > 1 error generated. > > > > ->mode_valid() in 'struct drm_connector_helper_funcs' expects a return > > type of 'enum drm_mode_status', not 'int'. Adjust the return type of > > fsl_dcu_drm_connector_mode_valid() to match the prototype's to resolve > > the warning and CFI failure. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/1750 > > Reported-by: Sami Tolvanen <samitolvanen@google.com> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org> > > --- > > drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > > index 4d4a715b429d..2c2b92324a2e 100644 > > --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > > +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c > > @@ -60,8 +60,9 @@ static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector) > > return drm_panel_get_modes(fsl_connector->panel, connector); > > } > > > > -static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, > > - struct drm_display_mode *mode) > > +static enum drm_mode_status > > +fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, > > + struct drm_display_mode *mode) > > { > > if (mode->hdisplay & 0xf) > > return MODE_ERROR; > > > > base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780 > > -- > > 2.38.1 > > > > > > Could someone please pick this up so that it makes 6.2? We would like > to try and get this warning turned on so that it can catch more > potential run time issues at compile time but that can only happen when > all the warnings are fixed. I'll pick this up tomorrow if no one else snags it. :)
On Wed, 2 Nov 2022 08:42:15 -0700, Nathan Chancellor wrote: > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), > indirect call targets are validated against the expected function > pointer prototype to make sure the call target is valid to help mitigate > ROP attacks. If they are not identical, there is a failure at run time, > which manifests as either a kernel panic or thread getting killed. A > proposed warning in clang aims to catch these at compile time, which > reveals: > > [...] Applied to for-next/hardening, thanks! [1/1] drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() https://git.kernel.org/kees/c/96d845a67b7e
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c index 4d4a715b429d..2c2b92324a2e 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c @@ -60,8 +60,9 @@ static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector) return drm_panel_get_modes(fsl_connector->panel, connector); } -static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) +static enum drm_mode_status +fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector, + struct drm_display_mode *mode) { if (mode->hdisplay & 0xf) return MODE_ERROR;