| Message ID | 9bc5029f7ad84b0b1e02be231a5abd7e5fa03946.1787239944.git.geert+renesas@glider.be (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-25292-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id 853101C056A for <noreply@patchwork.local>; Fri, 21 Aug 2026 12:03:44 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-25292-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-25292-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 5D19730060A0 for <noreply@patchwork.local>; Fri, 21 Aug 2026 10:03:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F4F446EF8D; Fri, 21 Aug 2026 10:03:37 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAF1346EC64; Fri, 21 Aug 2026 10:03:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787306615; cv=none; b=s9M97OYTGXReX+JglHdM6vuhN1ttYeGtdFbHPAmyqxxfyAbefbZ68YXaMsi9PY58a5n1Ocz/n41P+EgqBO73ScDLy673Shhxz/sj5i1BkvqYqg6WHS4fCYuDrl060KKrxguyfPX53q9XRU2bP3MeGFVJ2fwnnf6jW6360Nd048Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787306615; c=relaxed/simple; bh=bk5/3KnTW1K4VMMTGCj94ajjE4NZlaE1Y7kf52o0HtA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J70bD30BOdNdVGrkwwGyVnxh2teu/+5f8riAK5phzmgAkCdOaDiXwZU9590rTrYToX6y7znmRxyaPPA289Oji3rfQQjygOBjQlzI6dWKIUjdj7t6PCNkKQ8ghB360gxtqZSISM4Yrlj7+oGhiOKmVrq2XCG6A48ZlhJOMy9ZX1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF2421F00A3E; Fri, 21 Aug 2026 10:03:15 +0000 (UTC) From: Geert Uytterhoeven <geert+renesas@glider.be> To: Chen-Yu Tsai <wens@kernel.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>, Jernej Skrabec <jernej.skrabec@gmail.com>, Samuel Holland <samuel@sholland.org>, Thierry Reding <thierry.reding@kernel.org>, Mikko Perttunen <mperttunen@nvidia.com>, Jonathan Hunter <jonathanh@nvidia.com> Cc: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-clk@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH 2/2] drm/tegra: Make sure clk_init_data is fully initialized Date: Fri, 21 Aug 2026 12:03:03 +0200 Message-ID: <9bc5029f7ad84b0b1e02be231a5abd7e5fa03946.1787239944.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.43.0 In-Reply-To: <cover.1787239944.git.geert+renesas@glider.be> References: <cover.1787239944.git.geert+renesas@glider.be> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.66 / 15.00]; BAYES_HAM(-5.50)[99.99%]; RBL_SENDERSCORE(2.00)[104.64.211.4:from]; SUSPICIOUS_RECIPS(1.50)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:rdns,sin.lore.kernel.org:helo,glider.be:email]; PRECEDENCE_BULK(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; TAGGED_RCPT(0.00)[renesas]; DMARC_NA(0.00)[glider.be]; RCPT_COUNT_TWELVE(0.00)[17]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FREEMAIL_TO(0.00)[kernel.org,linux.intel.com,suse.de,gmail.com,ffwll.ch,sholland.org,nvidia.com]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4:c]; TO_DN_SOME(0.00)[]; FORGED_SENDER_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[geert@glider.be,linux-sunxi@lists.linux.dev]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; TAGGED_FROM(0.00)[bounces-25292-noreply=patchwork.local,renesas]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 853101C056A X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
drm: Make sure clk_init_data is fully initialized
|
|
Commit Message
Geert Uytterhoeven
Aug. 21, 2026, 10:03 a.m. UTC
The clk_init_data structure contains several mutually-exclusive members
for different methods to specify the possible parents of a clock,
prompting drivers to initialize only the members they need. However,
not initializing all members may cause subtle issues, which are only
exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is
enabled.
Make sure all members are fully initialized, to avoid such bugs, and to
prevent future breakage when converting drivers to a different method
for specifying the parents.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
---
drivers/gpu/drm/tegra/sor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: Pre-existing issues: - [High] Missing bounds check on the `nvidia,interface` device tree property causes out-of-bounds array indexing and arbitrary MMIO access. -- --- Patch [2]: [PATCH 2/2] drm/tegra: Make sure clk_init_data is fully initialized --- commit d6e18a3c09cc145658765914a32b191ad5da6aa8 Author: Geert Uytterhoeven <geert+renesas@glider.be> drm/tegra: Make sure clk_init_data is fully initialized The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. > diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c > index 802d2db7007af..c28557d0c96e5 100644 > --- a/drivers/gpu/drm/tegra/sor.c > +++ b/drivers/gpu/drm/tegra/sor.c > @@ -596,8 +596,8 @@ static const struct clk_ops tegra_clk_sor_pad_ops = { > static struct clk *tegra_clk_sor_pad_register(struct tegra_sor *sor, > const char *name) > { > + struct clk_init_data init = {}; > struct tegra_clk_sor_pad *pad; > - struct clk_init_data init; > struct clk *clk; > > pad = devm_kzalloc(sor->dev, sizeof(*pad), GFP_KERNEL); [ ... ] > pad->sor = sor; > > init.name = name; > init.flags = 0; > init.parent_names = tegra_clk_sor_pad_parents[sor->index]; [Severity: High] This is a pre-existing issue, but can this out-of-bounds array indexing occur if the Device Tree provides an invalid "nvidia,interface" value? In tegra_sor_parse_dt(), the "nvidia,interface" property is read and assigned directly to sor->index without any bounds checking: drivers/gpu/drm/tegra/sor.c:tegra_sor_parse_dt() { ... err = of_property_read_u32(np, "nvidia,interface", &value); if (err < 0) return err; sor->index = value; ... } If a malformed Device Tree is provided, does using this unbounded sor->index to access the tegra_clk_sor_pad_parents array lead to an out-of-bounds memory read? It appears it could also cause arbitrary MMIO reads and writes when computing register offsets using DC_DISP_CORE_SOR_SET_CONTROL(sor->index).
diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index e384cbd0cbf72fb9..46449c69807d369e 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -600,8 +600,8 @@ static const struct clk_ops tegra_clk_sor_pad_ops = { static struct clk *tegra_clk_sor_pad_register(struct tegra_sor *sor, const char *name) { + struct clk_init_data init = {}; struct tegra_clk_sor_pad *pad; - struct clk_init_data init; struct clk *clk; pad = devm_kzalloc(sor->dev, sizeof(*pad), GFP_KERNEL);