From patchwork Fri Nov 18 23:31:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13049140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF384C4332F for ; Fri, 18 Nov 2022 23:32:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gBCBy/PKpwlnDqt32vMAHtCJ3DsCNqxar6P7p0SFfVU=; b=oQ94FQB3m5UDoO 3DY5K8Sn2aAenIbS1wBHx2o4jXVf8I0hiDOihp2ic4+f5H9/95urP7FHX5ccndP3Dt9RVBJG9WdZE SPCuBlASryAaWQUVTkCxfqoL8dZBXud8GT/R48PnNEIx5JhoBengjE/DVXBmd0bO+ljnXtzC2u+av 24p+duAGoMcyoR6NLG6ap4hxml4pTk7X4bZDtabtA2IA/NsjHyvq7C5RBX3KxPpjwGe0Y5OhWWwHB rZpr8ubHnHKaGGy44U4AEk6Y2I/mb6lE8QI21DeJ7+v2+ZjAnyxLGJVcfHh6Vd8nw3BF28SD1rTTv yD1UMqWfJsNMGgtXsKdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1owApE-009BtT-5F; Fri, 18 Nov 2022 23:31:12 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1owApA-009Brg-Gr for linux-arm-kernel@lists.infradead.org; Fri, 18 Nov 2022 23:31:10 +0000 Received: by mail-pf1-x42c.google.com with SMTP id k22so6293727pfd.3 for ; Fri, 18 Nov 2022 15:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=33uTqF7+W9KqoilqutefSDNFwFq6HUhByT2ijkZ5G9U=; b=W7BD5tRI2ij3JGhvPX7uO8vqAdAyVOqI9DLZKtEoNRzDBDtdyxCMAXG4j1tyxVCRUJ vovMvBOZBrVZi/mehG9tAFdBnkNYl/5uVOONDWEVQbnKxaAnud8exlwTl0qnL+ACLAYb CAp+d12k8Q3YC0kSv41zBn2Y5Sh/wxJWEbiuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=33uTqF7+W9KqoilqutefSDNFwFq6HUhByT2ijkZ5G9U=; b=JUG3xO+0oV6Y6jpxyklxmXyTsbDwkoyThuQq4lFFNjb5tokVNpUeobfg/ex8I5mAXc 8YwrFV10+vYY7d5nlM4C/u/lHjdU+2Gi1dwkk+LAmtJbwLrond1wy3pPkXMam3mo5lmF RkbdiCd9dGJAjBDbQoB6mH4h02sfFRENuHKMccs7Tp9Cu89wcDU74yFZAEJJK0if1+Pe eBsKnosCvzHddocstihcanicvFanyusfoa8qjNLlsDd0h4OG4gjX8DnjOUoDTHYayO+o oHRrbaD1EUpf3Z74XPSn3GsFG8w6/CJGsHTMkLHbRpSNWE/zGlIomuHhHlTvAEP+uklb x6hw== X-Gm-Message-State: ANoB5pmI2jyrXGVQJAymHkZpVA6dd3nHc8bmAkhqowrZr5uQeFqAu1Ym hM2mlco4crttMjTn4MNRLHFogQw/eu7XFQ== X-Google-Smtp-Source: AA0mqf6wi59hZOm6qV685//732ZaWyFw539tCrYb7S5osK83avH6C4bX0DQYRJw1N6Xnew1vP6XUiQ== X-Received: by 2002:a62:ab18:0:b0:56b:9ae8:ca05 with SMTP id p24-20020a62ab18000000b0056b9ae8ca05mr9949345pff.59.1668814265054; Fri, 18 Nov 2022 15:31:05 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n1-20020a170902f60100b00186ac4b21cfsm4261573plg.230.2022.11.18.15.31.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 15:31:04 -0800 (PST) From: Kees Cook To: Daniel Palmer Cc: Kees Cook , kernel test robot , Romain Perier , Alessandro Zummo , Alexandre Belloni , "Gustavo A. R. Silva" , linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH] rtc: msc313: Fix function prototype mismatch in msc313_rtc_probe() Date: Fri, 18 Nov 2022 15:31:02 -0800 Message-Id: <20221118233101.never.215-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2135; h=from:subject:message-id; bh=2uMBrJl4p11kK9eP2yD/st+7tL8825ju2BfNzfsIAFA=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjeBW2pC2rpMYTXJkLShGmag664z+K5tiPE3dQug6d 6k7LWyyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY3gVtgAKCRCJcvTf3G3AJqmjD/ 9x/r5mwDVIWZVDGrRBJNY7gBhWQVZs9Z/nqdCrOe6qOkAmhPjIchn1IB6cV1GmDz8UW59kGEtnLdS7 jC1s1/P6gDmZxDY0YrSjBwBrCYTjgk5SEdiG7UleuvQHMDj4ivlWWYw1Yqt2M3qa6wWcjVLZVrBwiW xRgtgPDq8FVLfcjzIztHR/cnfpj5bIFbB4IgjY6l3OgpNY7mssysn2+ggS9aSPfJ5gkG3pPvGtWIi6 EEtLfAjNUNWlED/tP+Tkmmp1PTPTQy6PgDvNCMJrygx0Fv75AsxP7RlPthymvYAGFF+43FCQgQSmLR Yj7JsKW/WC/nTnrsPgyoJME7NdMR3xSOQPspj3DlCxT1EwEn3CEnDdQm/A9amOcCGkiWLUF0Ad0ML7 Qbw+Hf8rGp4VNDDvh54agrBrF29dyoWZj0Dc3fYNZmv/eBV0zjd9IoTkeC1viSK1Bjb1xVrQixTci5 kvaylDZn64g0v7V2S6i8HppnbUtYlHLV973KUmaqypRQP9FNfwo959Bw+LcTa/SCVjNB75LTr7PxaQ cLrhF9jVvisMmnMX44nc/0YGD+rAGhjVRAZkNiyaJycNQd4UJRIMsuTYjBuNUuIZCoL40Nc5IQo+4k qDdrX+pjyAvguJBTMEt2wCJMJIn6QqaLdnvI6LevBtHnBsoy8iGJbeGEZ5JA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221118_153108_598261_F6B71B1F X-CRM114-Status: GOOD ( 17.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. msc313_rtc_probe() was passing clk_disable_unprepare() directly, which did not have matching prototypes for devm_add_action_or_reset()'s callback argument. Add a wrapper and remove the cast. This was found as a result of Clang's new -Wcast-function-type-strict flag, which is more sensitive than the simpler -Wcast-function-type, which only checks for type width mismatches. Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202211041527.HD8TLSE1-lkp@intel.com Cc: Daniel Palmer Cc: Romain Perier Cc: Alessandro Zummo Cc: Alexandre Belloni Cc: "Gustavo A. R. Silva" Cc: linux-arm-kernel@lists.infradead.org Cc: linux-rtc@vger.kernel.org Signed-off-by: Kees Cook --- drivers/rtc/rtc-msc313.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-msc313.c b/drivers/rtc/rtc-msc313.c index f3fde013c4b8..36e3e77f303e 100644 --- a/drivers/rtc/rtc-msc313.c +++ b/drivers/rtc/rtc-msc313.c @@ -177,6 +177,13 @@ static irqreturn_t msc313_rtc_interrupt(s32 irq, void *dev_id) return IRQ_HANDLED; } +static void msc313_clk_disable_unprepare(void *data) +{ + struct clk *clk = data; + + clk_disable_unprepare(clk); +} + static int msc313_rtc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -224,7 +231,7 @@ static int msc313_rtc_probe(struct platform_device *pdev) return ret; } - ret = devm_add_action_or_reset(dev, (void (*) (void *))clk_disable_unprepare, clk); + ret = devm_add_action_or_reset(dev, msc313_clk_disable_unprepare, clk); if (ret) return ret;