From patchwork Wed Nov 2 17:22:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 14405 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp37404wru; Wed, 2 Nov 2022 10:23:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nQvTn/JhgPMgTHDR/CHsaygJPpNr9BX4HOlc0ms3PfkDNp74vfgcnGeNCHyr6XK9thmJm X-Received: by 2002:a17:907:9688:b0:7a5:74eb:d12b with SMTP id hd8-20020a170907968800b007a574ebd12bmr25206317ejc.60.1667409832926; Wed, 02 Nov 2022 10:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667409832; cv=none; d=google.com; s=arc-20160816; b=D5s4LkETgaf49KT2dN4V55YsXA4zPiJKx/pN0SvxFiAS5poRn0VLR/85/ADt2DyvT3 U7UmPR/+e4HYfb49RFb++0ZBO9zKls9zAiak8MZTpMVDPmA9ON6BsL1b8n20YE5ZT0KG lDDdXi51k61pHmUvjr+oIz8c4Y2VunVizSU7pRtQnbnCYagAh07oo0dt4dTnQj7RBqUS X1zlIvJ6hVliBQQT0AYjFRZA+9GVrmUoAsHWPal9LaY7g8mTQCc7zxZ5o0UDGj7TsdZh rz74weafLN2R1eGIynsjRqQL0E/FgVqMLaywhFLG+Pi4qiqrxTAq4MdgySADmPx88JnC 7TiA== 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=5eO7+503/6Kt1O+FOCcqU79H7fCTQBnrHetgNER5y4o=; b=Vdo91YmZK8kS0us/yssSKxS8a9lY4ATn2f2QSaJIb46Vmv4cnHXMWr6r3ivPc7LSRK 5ctNmTHkccuQewJm0IzbE4y35UypYUfD1goT+/ikcFVDP9HUXUDUmWILZ8DqrBOc0Ucz +BgQfs38AG5gkTHhJJiZ78DCfxaIHNriVNn0qOqBRgGjuG6kyj1Fuqx2FlLfUyUP5Kp7 RqV68Wz8zqzYihYuebmoUmIAff0FN6zpS7eYKsbEMusnJQn1HVKFQMvZAf4RJxJ7/7gV 9aHsE7QJxcuavsKaYEESayN2Ech6vO/EFOHEQtcgKA/CLh3phpl955TtgGdpCU181TAD DZSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZtR38H8a; 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 z11-20020aa7cf8b000000b00461bbc0aa47si13620181edx.117.2022.11.02.10.23.29; Wed, 02 Nov 2022 10:23:52 -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=ZtR38H8a; 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 S231343AbiKBRWm (ORCPT + 99 others); Wed, 2 Nov 2022 13:22:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiKBRWk (ORCPT ); Wed, 2 Nov 2022 13:22:40 -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 8325A26139; Wed, 2 Nov 2022 10:22:39 -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 2899C61A32; Wed, 2 Nov 2022 17:22:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7984C433D7; Wed, 2 Nov 2022 17:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667409758; bh=VOPxx1E3nzgzSX4/T9iDwxmKIdfR07u/REHayG82ioQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZtR38H8afcyKcjaRxplQiaodCrL6U01+2ictVzJ4eHQLw6h4wKkBdIU9rNti2ps1Y TXphRcqiH+UQYvmt9VNEY0vEPDdvb+86uKZpXSicZgUZoBJN1FaZFT0S89R9Td4ev8 +tDz9GkFAhGFTE30cokMoULtgCD+J8197M/VdNPkFqCWjR2HiULLjuLIqd/3/bN7nT SIXXwSuZvJ4SdT/WVIzQoLCIUnlnAR4uo1u1B+EZx7rXmqVpz7E+n8DlbLEZZPucyw VmAV9DBVfsAvOuR40tskWxq/YywPMtvI93YZQAMuIh2QLOy6ZCBhehYTMcbdv8shMR C7srL5Lm0GQ9g== From: Nathan Chancellor To: William Breathitt Gray Cc: linux-iio@vger.kernel.org, Nick Desaulniers , Tom Rix , Kees Cook , Sami Tolvanen , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Nathan Chancellor , Fabrice Gasnier , linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH 2/4] counter: stm32-timer-cnt: Adjust final parameter type of stm32_count_direction_read() Date: Wed, 2 Nov 2022 10:22:15 -0700 Message-Id: <20221102172217.2860740-2-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102172217.2860740-1-nathan@kernel.org> References: <20221102172217.2860740-1-nathan@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748405932581474559?= X-GMAIL-MSGID: =?utf-8?q?1748405932581474559?= 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/counter/stm32-timer-cnt.c:220:2: error: incompatible function pointer types initializing 'int (*)(struct counter_device *, struct counter_count *, u32 *)' (aka 'int (*)(struct counter_device *, struct counter_count *, unsigned int *)') with an expression of type 'int (struct counter_device *, struct counter_count *, enum counter_count_direction *)' [-Werror,-Wincompatible-function-pointer-types-strict] COUNTER_COMP_DIRECTION(stm32_count_direction_read), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/counter.h:596:20: note: expanded from macro 'COUNTER_COMP_DIRECTION' .count_u32_read = (_read), \ ^~~~~~~ 1 error generated ->count_u32_read() in 'struct counter_comp' expects a return type of 'u32 *', not 'enum counter_count_direction *'. Adjust the final parameter type of stm32_count_direction_read() 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 --- Cc: Fabrice Gasnier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-stm32@st-md-mailman.stormreply.com --- drivers/counter/stm32-timer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c index ece55113ba85..4062296f4bd4 100644 --- a/drivers/counter/stm32-timer-cnt.c +++ b/drivers/counter/stm32-timer-cnt.c @@ -137,7 +137,7 @@ static int stm32_count_function_write(struct counter_device *counter, static int stm32_count_direction_read(struct counter_device *counter, struct counter_count *count, - enum counter_count_direction *direction) + u32 *direction) { struct stm32_timer_cnt *const priv = counter_priv(counter); u32 cr1;