From patchwork Thu Dec 29 18:40:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 13083726 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 ACA96C4332F for ; Thu, 29 Dec 2022 19:11:24 +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=5raeCvhN0WthazUeZSbn1yfGBdnLF3CODENhMmuZYC8=; b=ZEJcEJoyg6+Qxv V60/zezmrpioVlWQgTBiGIxGL5huPbT2YVoz3QtTm/UVZNQdrp9maK3q4ItkkdQ33rONcKhbb9g7M lc6VPx06SvNv38IA8O8ey4r6mEaIpMvR/npenBBRSGaLaUoDJ+muTw+K6ktNvjGvZ/64Snsi31V3J bDn9DqSoSAwimaL0kI5/ogOtFr9TIGa6h/CwWHNUTg5apRJ5xNoLGgvE9yuq3y4t/ZiYbJwbfCA6W NE/4LQpn4Ra7rsJmTQj/6ydqMnilmW3fwmkn4VKc+y8fqIZhdU3pB/lJqCetEdaojIkI4fpR5ebL+ 7wdhnukYylfZrlDYKk3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAyIA-0016xj-Ia; Thu, 29 Dec 2022 19:10:14 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAxpD-000s7q-GJ for linux-arm-kernel@lists.infradead.org; Thu, 29 Dec 2022 18:40:21 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_104019_918887_A487FF94 X-CRM114-Status: GOOD ( 12.98 ) 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 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);