Message ID | 20221102154712.540548-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 l7csp3697152wru; Wed, 2 Nov 2022 08:49:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5fGNrFO3viI54cQaY3+29kmU0DYpmQ+sW5Etq/uAbH4gI9qWAWMehvRdxrcQ8ebiaEl24J X-Received: by 2002:a17:907:8a23:b0:78d:b042:eece with SMTP id sc35-20020a1709078a2300b0078db042eecemr23480896ejc.494.1667404199213; Wed, 02 Nov 2022 08:49:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667404199; cv=none; d=google.com; s=arc-20160816; b=k9qgghGs6eplqvd9oqc5kJhOOYYHiABfvXwF/Etxw2/WJVngZ+K3SOLjxzKjCxUMCa KKXLu+P2oq2ouKqwhyN/s8ReIL/Wu1ujB5t6XLJUe0RkDeiU760y202m7KGF7fE1sIcf BqL/cQa64ayX2HDx7Ww7pgM5Js2cJ6rYFye7zcBl4Tu8cy+MHU1bkOjZc9s3VNARPFWx SbA0c4VRW+NeTA8fLvBhLIyurI3VvOKeeCAAJXaGijJXyvw5BHofNNom49LGpVyRlFR7 ttLD+gkkV5ldtlJIk3Nx1qYUy+86EgYNTBy+Pc3o5BKH/5Uu+vEc39o/akvaJQ4EU7O9 XeLQ== 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=g6ttj8s1HBUAsVkS9zAwvmRPefh6Jiq75lq2trGDN5Y=; b=nbOaPImA/RGt6Ha0eWzj5Fj9t5gjEEQ2ABqO3BVeNfV1klCO3IrKvvtWCZhrgUcMQ+ FrX9EHFSoAmM+OuWYnSqQrDH/Qx2xqZFLEEgsd0Pj4arPtDorgj6xeLreQGq9GWI5dRv GHdHR+x8wu+KfXFvxw23gnUj30VGE7SQF9Fc55mz6qWrpS5K6eLhRQcBHG2XKECUCUKw z67HvP/FX7too97TSNNyFHn5oRkspI6BogdU8db0U9dE/0g11O0UV9Yqov/VAao1iBSb 4qlSwUtNcxbzG36A+C200pepLU1lUel/XVH+kSsIBsOp6PVqfy2cH7r85lwHbA7itAb7 2o3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JGmHAvU0; 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 m10-20020a1709061eca00b0078356aaeb61si12400738ejj.286.2022.11.02.08.49.18; Wed, 02 Nov 2022 08:49:59 -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=JGmHAvU0; 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 S229992AbiKBPrg (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 11:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229548AbiKBPre (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 11:47:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B9029C91 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 08:47:27 -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 ams.source.kernel.org (Postfix) with ESMTPS id DA3BEB82388 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 15:47:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C39C1C433D6; Wed, 2 Nov 2022 15:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667404043; bh=rkW/QyBofVtN1MAesr7DFgUS/FF5stFfPR9fvlPXMF4=; h=From:To:Cc:Subject:Date:From; b=JGmHAvU0/bWPJxrmLujwXYEuDMFsY4lhx9S7zgNWoyuqdqqzjGIAnMctYdhHcxMw8 jenGlEdlAXACE9JEZoYCGpmr1zsYPTeuxt+e4pKjJ/MMoXS1Sybr0Fh0nGkoOSjRNP V75ycFPRrgYv2TCCT8tKqY4Bc8seM82Om7Ba5E5dAuQwolprLC4ZNiO91jDsS1Se37 GA0VR0pV199yY4iuT6DJsy5F3hH+sCiY1ZJc+wrhOSuI/7TRU6xjPWnuRSXs1rliXR noXsBM0VYpXIR14VOEn7F4IUvG2g7UwrOa+Ld82HGfwF+G2Gls5T+DWUI7Lc4r25z5 lxRNkEXEG6CKg== From: Nathan Chancellor <nathan@kernel.org> To: Chun-Kuang Hu <chunkuang.hu@kernel.org>, Philipp Zabel <p.zabel@pengutronix.de> Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.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/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid() Date: Wed, 2 Nov 2022 08:47:12 -0700 Message-Id: <20221102154712.540548-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?1748400025511679866?= X-GMAIL-MSGID: =?utf-8?q?1748400025511679866?= |
Series |
drm/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid()
|
|
Commit Message
Nathan Chancellor
Nov. 2, 2022, 3:47 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/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = mtk_hdmi_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
->mode_valid() in 'struct drm_bridge_funcs' expects a return type of
'enum drm_mode_status', not 'int'. Adjust the return type of
mtk_hdmi_bridge_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/mediatek/mtk_hdmi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
Comments
On Wed, Nov 02, 2022 at 08:47:12AM -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/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = mtk_hdmi_bridge_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->mode_valid() in 'struct drm_bridge_funcs' expects a return type of > 'enum drm_mode_status', not 'int'. Adjust the return type of > mtk_hdmi_bridge_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>
Il 02/11/22 16:47, Nathan Chancellor ha scritto: > 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/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = mtk_hdmi_bridge_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->mode_valid() in 'struct drm_bridge_funcs' expects a return type of > 'enum drm_mode_status', not 'int'. Adjust the return type of > mtk_hdmi_bridge_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> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Hi, Nathan: Nathan Chancellor <nathan@kernel.org> 於 2022年11月2日 週三 晚上11:47寫道: > > 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/mediatek/mtk_hdmi.c:1407:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict] > .mode_valid = mtk_hdmi_bridge_mode_valid, > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > ->mode_valid() in 'struct drm_bridge_funcs' expects a return type of > 'enum drm_mode_status', not 'int'. Adjust the return type of > mtk_hdmi_bridge_mode_valid() to match the prototype's to resolve the > warning and CFI failure. Applied to mediatek-drm-next [1], thanks. [1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next Chun-Kuang. > > 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/mediatek/mtk_hdmi.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c > index 4c80b6896dc3..6e8f99554f54 100644 > --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c > +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c > @@ -1202,9 +1202,10 @@ static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi) > return mtk_hdmi_update_plugged_status(hdmi); > } > > -static int mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge, > - const struct drm_display_info *info, > - const struct drm_display_mode *mode) > +static enum drm_mode_status > +mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge, > + const struct drm_display_info *info, > + const struct drm_display_mode *mode) > { > struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); > struct drm_bridge *next_bridge; > > base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780 > -- > 2.38.1 >
diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index 4c80b6896dc3..6e8f99554f54 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1202,9 +1202,10 @@ static enum drm_connector_status mtk_hdmi_detect(struct mtk_hdmi *hdmi) return mtk_hdmi_update_plugged_status(hdmi); } -static int mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge, - const struct drm_display_info *info, - const struct drm_display_mode *mode) +static enum drm_mode_status +mtk_hdmi_bridge_mode_valid(struct drm_bridge *bridge, + const struct drm_display_info *info, + const struct drm_display_mode *mode) { struct mtk_hdmi *hdmi = hdmi_ctx_from_bridge(bridge); struct drm_bridge *next_bridge;