Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6336359rwl; Thu, 29 Dec 2022 11:00:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXskWRZ+rea9Frse6+Q7IXoKiVolRuaRC9zou3c2Bt2RZHfkaBMTepzH4W4G23spGppKSE+K X-Received: by 2002:a05:6a20:c183:b0:a4:526a:3f25 with SMTP id bg3-20020a056a20c18300b000a4526a3f25mr37431679pzb.44.1672340449421; Thu, 29 Dec 2022 11:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672340449; cv=none; d=google.com; s=arc-20160816; b=O00ecsl3x3zaEDp+pzvxRmamichWPsAz3huY0sAPXRKokBmmvjg7hdEyyzSejFIeYQ bb1K+HXk1DZKc8o7jNErd3wkt9tJ99mj4OVvAp7CdkP5L4NaQHkQkFdx3D1QhbNfnQiN 7eb3UtPjRJcCJFiI5FiFxK+mvdI5SQWwzGfXLfZMdego5Xqwh8m7Bzu3j4lMntfOgTad YP6Wfl0nqa/TsXbezr5trxREs3vN1t440sks6K/r6bRYQgfKcqG33XUlVEpNsCIUiJbI vFfDU/mrjwFMZZz61SoYemj6diCAikfI04d6pNNY5udSAItECg5yiSiRXajZB8iYzzNL lXew== 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:feedback-id:dkim-signature :dkim-signature; bh=Ub6/Sg6MtwK7zSZLvDEMExGoikMh9KjbbFTpe8DKeuA=; b=TjmZY4jq6p99PvlHfMq9PhSfjmN1y9zBf3Kk52t9sAv0Bx5P+1Lo3l/HT80HGE9epg DlzBbM9cbC+e1jogQRJEzsaZUkfgzxdfaZwPOVkhGhczMyePmwebR9b0cye9k9IpLnln POKwvQ7jvbpwD4lMS3vLYdHpmLPQ8L4UJ2Sg5vFCYgzMRBzlnWmh/+ldv32Td0/HBHKL D/gjk5pHYMjKIri25Tx9R5rKJIh+cZM0Pl8dUhek7h7JqC3+XobAOpvQFGDu3rX/U76x vXvETOizsI478Os9uar2XRVM9AiDruT7PSlCthetRrLNv0Et8BPGnmAr2alh+aIyMC8f iJLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=gw+eCMVA; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=d0Ax4PSW; 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=sholland.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020a056a0021cf00b005634d0b379dsi20491566pfj.115.2022.12.29.11.00.40; Thu, 29 Dec 2022 11:00:49 -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=@sholland.org header.s=fm3 header.b=gw+eCMVA; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=d0Ax4PSW; 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=sholland.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233803AbiL2Skg (ORCPT + 61 others); Thu, 29 Dec 2022 13:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233575AbiL2SkR (ORCPT ); Thu, 29 Dec 2022 13:40:17 -0500 Received: from wout2-smtp.messagingengine.com (wout2-smtp.messagingengine.com [64.147.123.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8FD5116A; Thu, 29 Dec 2022 10:40:16 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B239432007F1; Thu, 29 Dec 2022 13:40:13 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 29 Dec 2022 13:40:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= cc:cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t=1672339213; x=1672425613; bh=Ub6/Sg6MtwK7zSZLvDEMExGoi kMh9KjbbFTpe8DKeuA=; b=gw+eCMVAO9wS/xum4K/FmCm8RLK+HPddgKot9F+6C aXmo+a4J5GbZ/4SQIPdakBOJYRFUnQhvcCA+XVB3SsHzW7NAbSKmotc1ujaD8Y8O vODRxqEvuCsmehC/Kuw9s3h+FY5gHJw4Yv7M1xcQvrhv0JgzDaTBQ/n8yOdkv9ih snRcMti+ltyPcsj+T1ccNfpLLo9W9MEPcGfts8/Uwt7rK4IKydVggD/NcJ4MRpyw hrg9P8FNnY6UQuTZikUJctqGNE+CoVjT+qg2qpg7IVSZ6teE6iotZcmOmwO56qIB o7fhNWNkESC72HMpJ/UQPuUiNBu1yaKj2eX60W9W35MNQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1672339213; x=1672425613; bh=Ub6/Sg6MtwK7zSZLvDEMExGoikMh9KjbbFT pe8DKeuA=; b=d0Ax4PSWdXTAOophmW8FbmoPkGdXa0JFRPff+iWnGGT7jU9VIfw h8SOWIcNDDSZJU2hvODYDoyQXuCvff9dL3p+Nbi2FKaXqqDFTmcZlkPBJZ2HcSqB VejGcWgf7H3NgVKWEDhSA4hnna7Ql7SCrAF1rKyykrC7z55lsegk3KZZ+1EPdRnY 4e1RCKjRR4ulSAMhOmvBlawaDFBHayMO7BcmhKqo0eqIgzNT4Q22Hzd+E0eUfe1i yOh/UuZu7xBn9CoESjRPiboWUdUgF96SZjHM4Uybo+HqxjL4VfUIwqxJBQAAcK6Q oQNF34KNhHa8kjFqHBojTrORJbg7NwAKi0A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepufgrmhhuvghl ucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecuggftrf grthhtvghrnhepkeevlefhjeeuleeltedvjedvfeefteegleehueejffehgffffeekhefh hfekkeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:40:12 -0500 (EST) From: Samuel Holland To: Alessandro Zummo , Alexandre Belloni , Chen-Yu Tsai , Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev, Samuel Holland Subject: [PATCH 1/2] rtc: sun6i: Prevent an out-of-bounds read Date: Thu, 29 Dec 2022 12:40:10 -0600 Message-Id: <20221229184011.62925-1-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLACK autolearn=no 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 If there is more than one parent clock in the devicetree, the driver sets .num_parents to a larger value than the number of array elements, which causes an out-of-bounds read in the clock framework. Fix this by coercing the parent count to a Boolean value, like the driver expects. Fixes: 3855c2c3e546 ("rtc: sun6i: Expose the 32kHz oscillator") Signed-off-by: Samuel Holland --- drivers/rtc/rtc-sun6i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index ed5516089e9a..a22358a44e32 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -294,7 +294,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, init.parent_names = parents; /* ... number of clock parents will be 1. */ - init.num_parents = of_clk_get_parent_count(node) + 1; + init.num_parents = !!of_clk_get_parent_count(node) + 1; of_property_read_string_index(node, "clock-output-names", 0, &init.name); -- 2.37.4