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: 1720163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=gw+eCMVA; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=d0Ax4PSW; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Njcdt1dpsz23f4 for ; Fri, 30 Dec 2022 05:40:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233614AbiL2Skc (ORCPT ); Thu, 29 Dec 2022 13:40:32 -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 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-rtc@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); From patchwork Thu Dec 29 18:40:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1720162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.a=rsa-sha256 header.s=fm3 header.b=N0fNr3t6; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=SVNBHGKc; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by legolas.ozlabs.org (Postfix) with ESMTP id 4Njcds5mpFz23dD for ; Fri, 30 Dec 2022 05:40:33 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbiL2Skb (ORCPT ); Thu, 29 Dec 2022 13:40:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233601AbiL2SkR (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 3A730D104; Thu, 29 Dec 2022 10:40:17 -0800 (PST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 2B459320077A; Thu, 29 Dec 2022 13:40:16 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 29 Dec 2022 13:40:16 -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 :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1672339215; x=1672425615; bh=XR 9sJUSnhveDvOfDAvp56v1RweLMdB53meAwdF02cGM=; b=N0fNr3t6UvfhplTozx Rbz/dUEf8E2IIcKlF41KO5XnFrBj6L4MGi5ZJ1mAfMpi6MR+mqJ5dPSh+9kG+BfI CA/4AhdUHh66wEM3pxcWyta8ITan+L5tSNReyVXAftD0huvpVqXdt6laDtzzj5gx 83vwdiqqUN2ZSuMhGHeiRmf2OV6HO1hvPWcBPGTO0r/3J12aNoSdCtBZVNju0eTM KGor7cTeV6Z4aEl2NpWaUtCTSyJAjQO98T5DoPrtyEIInyR74HhN72d9fYOVIQy4 zBng3qD5Nmp+OY65mM1GDScwT7Iyl+7RSqFqIQyDxxHa8Pwb+41kFeYhorkPSkzm bh7Q== 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:in-reply-to :message-id:mime-version:references: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=1672339215; x=1672425615; bh=XR9sJUSnhveDv OfDAvp56v1RweLMdB53meAwdF02cGM=; b=SVNBHGKcbZ/cWQTSov09qLPC2vaj8 lfh04OXhzg90OzEVhjZhmhtIYYAo2aH43w8+LDTIhz3RjQZQV6Hqm1YGwzqbR2Cj pswyHAIglD7NWMK0dHorfvKGaxDnD7B14giTCexe+EFYjQHgSZMgYt6840tsM/Wq i7f+CQBCzk9ZbhCOH+zHJCDO1h7wwZFU65XgRitp57hrW+9pUR9hjRLBoloG+w3Q Uq3OGAh2tWTjRwhZQHQCZQDYtpo9HnQKVY4onivq03ELq05yWcsObpdxOvfmzyYP ZOkXgcVNrO6tbYHhBAez91wI1iiyqMsaNekGz4TdtJjJR8QTGF56zZ0XA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggdduudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepudekteeuudehtdelteevgfduvddvjefhfedulefgudevgeeghefg udefiedtveetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Feedback-ID: i0ad843c9:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 29 Dec 2022 13:40:15 -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 2/2] rtc: sun6i: Drop the unused has_out_clk flag Date: Thu, 29 Dec 2022 12:40:11 -0600 Message-Id: <20221229184011.62925-2-samuel@sholland.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221229184011.62925-1-samuel@sholland.org> References: <20221229184011.62925-1-samuel@sholland.org> MIME-Version: 1.0 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-rtc@vger.kernel.org This flag was never used by the driver. Signed-off-by: Samuel Holland Reviewed-by: Jernej Skrabec --- drivers/rtc/rtc-sun6i.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index a22358a44e32..52049f139474 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c @@ -135,7 +135,6 @@ struct sun6i_rtc_clk_data { unsigned long rc_osc_rate; unsigned int fixed_prescaler : 16; unsigned int has_prescaler : 1; - unsigned int has_out_clk : 1; unsigned int export_iosc : 1; unsigned int has_losc_en : 1; unsigned int has_auto_swt : 1; @@ -346,7 +345,6 @@ CLK_OF_DECLARE_DRIVER(sun6i_a31_rtc_clk, "allwinner,sun6i-a31-rtc", static const struct sun6i_rtc_clk_data sun8i_a23_rtc_data = { .rc_osc_rate = 667000, /* datasheet says 600 ~ 700 KHz */ .has_prescaler = 1, - .has_out_clk = 1, }; static void __init sun8i_a23_rtc_clk_init(struct device_node *node) @@ -360,7 +358,6 @@ static const struct sun6i_rtc_clk_data sun8i_h3_rtc_data = { .rc_osc_rate = 16000000, .fixed_prescaler = 32, .has_prescaler = 1, - .has_out_clk = 1, .export_iosc = 1, }; @@ -378,7 +375,6 @@ static const struct sun6i_rtc_clk_data sun50i_h6_rtc_data = { .rc_osc_rate = 16000000, .fixed_prescaler = 32, .has_prescaler = 1, - .has_out_clk = 1, .export_iosc = 1, .has_losc_en = 1, .has_auto_swt = 1, @@ -409,7 +405,6 @@ CLK_OF_DECLARE_DRIVER(sun8i_r40_rtc_clk, "allwinner,sun8i-r40-rtc", static const struct sun6i_rtc_clk_data sun8i_v3_rtc_data = { .rc_osc_rate = 32000, - .has_out_clk = 1, }; static void __init sun8i_v3_rtc_clk_init(struct device_node *node)