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); 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: 13083727 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 83A24C4332F for ; Thu, 29 Dec 2022 19:11:50 +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:References:In-Reply-To: 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: List-Owner; bh=T2qoqWAj+8ZdVaTuipZld8EU/vqjKs1sujj2FS+IKS0=; b=vkFpKOQQf6Nkvv iWxcyMKNCXt5x/rFEcRT4NKZtEhVDQQ9XKFl6PeeVaDAJ+t7MtUX+RJcJB5LtcVvbZDemlC1APDHJ 4mS8NheoRrfeIL/HRHmBxar7hEnGnQ2OV39dHrDFK2yV8HtrqRZuc7dfKyUf1n0l5lM3EzSbjZdm1 lhpbCRSKsb+xSzavjU/qlFw+MZr66+8ct0W66npVLVQx04VP/fcb7EP6iLgHp3Yc+lH8V6moMDEKL 82OzIKCmrjEbFTijodoBMMbh/Enj3oMz6NY+SMjINzWQXnUGZpsqRiWAQMKV7F7abcxBwk2dIyvDn 8HQeR7lP6dSbdDdmfItQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pAyIa-00179M-GI; Thu, 29 Dec 2022 19:10:40 +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-000s8T-Fz for linux-arm-kernel@lists.infradead.org; Thu, 29 Dec 2022 18:40:22 +0000 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221229_104019_931568_D4A73245 X-CRM114-Status: GOOD ( 10.95 ) 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 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)