Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1526467rwj; Sun, 18 Dec 2022 09:54:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf58tBOgRfPmwLr0SjTN8drUApsHJiofajtsj+jTLvIBGAroZbUH74ULG8cNTSBudpsYl8FD X-Received: by 2002:a17:903:186:b0:189:b3bf:c0b5 with SMTP id z6-20020a170903018600b00189b3bfc0b5mr60500244plg.34.1671386061418; Sun, 18 Dec 2022 09:54:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671386061; cv=none; d=google.com; s=arc-20160816; b=dFlRCe3PjVbfaIFDMGJ2aUPRg0kbL8r6qDbe1M4Vws9iR1CW7Jmm9n4wOZ9Buukk+1 5vpJ/cEULwH4LiHFoXkRLtLVrfQ+2+yx49AImd+TTZYoYzq6+HKsXGjDhwZ3leVxULet CDKkPvQjrVqa86kreVFD7TE5GNY8C/jDYw3AktYotxA8zDOpWRdsZYkmOlO5PJRIs+WL 1sv+6VCqzCiWRnsngSLlbitjQ+TgPK4CiXAjxAq7ZIdtaNGjNFWUb8nu8kolUcvS2ZuM ZGtt2zkMr3q4sBT42pGYaVAxPhZVkBM1YIlhuH8zeA2SKdngQWMHEy4r3QG+o0b/RZtH Srhg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mTH7HFPa/sjugvIOMxDw4mdeT3bXN+KaA0Ptd1qlGPE=; b=anQ9PmzrCaN73UyOqYlCzRygx9e+U8JYdv40/L80WOFksDA0cUt9QyubNk6e4RwjW2 I9vzWgUn9hmk6kFrnZK8fAmkKo0exp5KEQiYOF35HBWHaiShu7gmJK2FZX8lxSuBOLzL FbjJ/ahrRiQPmoa8ZFRRSIV0mhy28wlHiRLIvRWTGtjFRz8ntXgTJMLfyZFsXmHuwE/u OjeWMrYO7JR8t1I/XxRj11YtsWxfA5Y0mU31DrRk6LVf0nfaDfDFT4q0UeOAsLZnRCdE BY2WYyGmUsEST3m2fBFAFm1n1NHo6M1SiUBznnV8l5z6X9mBdQImYV04vZGlGMKL/23/ iR/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dzmje4hK; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l63-20020a638842000000b00477bf7b0c43si9027607pgd.458.2022.12.18.09.54.12; Sun, 18 Dec 2022 09:54:21 -0800 (PST) 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=dzmje4hK; 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 S232603AbiLRQlw (ORCPT + 71 others); Sun, 18 Dec 2022 11:41:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbiLRQks (ORCPT ); Sun, 18 Dec 2022 11:40:48 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277FB5FB0; Sun, 18 Dec 2022 08:14:28 -0800 (PST) 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 C05ABB80BA8; Sun, 18 Dec 2022 16:14:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2F50C433F0; Sun, 18 Dec 2022 16:14:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380066; bh=WeOOt14tkYeELBrtRWfPT2/q6Bw4lnOCH2VvxZFmpcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzmje4hKaeQrYSHdhC+sIKTl3vsoWacmBh8tQRli0WQoXINR+Wqf7Mr1mMLxCBasE k7LqmV3sTY8OOk6+9M5zm2XyZVrSPCuQjwCxkfZkoL5t/VEjQrnrny3xTuP/U/5vb3 AHaHONGG6Kfl8ILtoF53bllgO0bqNgEnNOVYWhGdXez2iqNqEbBM4ECR20H8dWU8zJ VxowEVeEmbTITMAuJfKzJnSADTunTJDwQm3aTlWokw/DCyvSstR4Hx5OphJ93pikv8 RR1bOp1B2B4T8VdKu67+dmU6OxBKjVBQ8JRhZCsDheOuOjWjPeipBaK/zSUbYu/KxQ pSYuOEKPUL4mQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Sami Tolvanen , Kees Cook , AngeloGioacchino Del Regno , Chun-Kuang Hu , Sasha Levin , p.zabel@pengutronix.de, airlied@gmail.com, daniel@ffwll.ch, matthias.bgg@gmail.com, ndesaulniers@google.com, dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 5.15 24/46] drm/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid() Date: Sun, 18 Dec 2022 11:12:22 -0500 Message-Id: <20221218161244.930785-24-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.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: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 890d637523eec9d730e3885532fa1228ba678880 ] 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 Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Chun-Kuang Hu Signed-off-by: Sasha Levin --- 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 3196189429bc..7613b0fa2be6 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -1203,9 +1203,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; -- 2.35.1