From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A24810E6 for ; Tue, 20 Dec 2022 01:22:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42661C433EF; Tue, 20 Dec 2022 01:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671499352; bh=PEIRubEA3fZUjLHgXVWXuXwNJdvRH2v7g+9z6cMocgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ak7uZpd6qqR9F7E5GV4zTkxnJp9LyfzdtXyMvsVhLTNLqSxD4SsyDSqMgu/4JNh3U 11cHKPfumZAR0syI3XKKWL0yh1u7t0QIxeJDE+UuniZf0JWihOFSDwDnEDdww+NcfU GDhZk6xR567cWsUzV8gIzZBBr4i3WuxrIxxDwx3jq2MzTUxfmeEcAR3cffyaFsPnkI t3RcID88HJNY6BORgZCNmLP0dcQcENBPEz0JRkbPLiNB27ZJcrMZpOtuuwJ/JlBJg4 2Gz0VhoiCs8R+3eg8INPjrVLvdcztpevj4sX7/aeiTxn4FSz0VLr6bl0OurMKKAkzc R0k4VtHdGrKbQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Sami Tolvanen , Kees Cook , Sasha Levin , stefan@agner.ch, alison.wang@nxp.com, airlied@gmail.com, daniel@ffwll.ch, ndesaulniers@google.com, dri-devel@lists.freedesktop.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 5.4 2/5] drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid() Date: Mon, 19 Dec 2022 20:22:24 -0500 Message-Id: <20221220012227.1222729-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221220012227.1222729-1-sashal@kernel.org> References: <20221220012227.1222729-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Nathan Chancellor [ Upstream commit 96d845a67b7e406cfed7880a724c8ca6121e022e ] 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 Signed-off-by: Nathan Chancellor Reviewed-by: Kees Cook Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20221102154215.78059-1-nathan@kernel.org Signed-off-by: Sasha Levin --- 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 a92fd6c70b09..8de9bc8343a2 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c @@ -70,8 +70,9 @@ static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector) return drm_panel_get_modes(fsl_connector->panel); } -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; -- 2.35.1