From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795908026; b=GXTHAt+jqciy/5DsL3eznezgySidMRLYOwW5ZDkbrRuOaZBYW3pmgBlWuX9DR5fZafLs 4AumG3Gkvg6pJ+ZjHoRB6ycK0Z3VlxYXyw2iRAcf15Yjnop0NbRk+Hwsb56q4f7juzaxm yEE0aW68JVUcx1Pc0kCFbS1bwEl8TdN+RbO9lgr69SWxGy+15eJgd8Jszgt9L40eleaFT /j0EYaNE0qN8VFENlRxnovdTC4o3yhDzB5EQ320p/YoXZscoM4Atg5QuadwHqgWRxFOiR +F5CXIk6UZD6QEl+uriJ1IkElkmdwHBJ1+haT77aIziCwN9750jjhE3RzHywWgYKXYw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795908026; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: In-Reply-To:References:X-Mailer:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=CJ9VClW39M8j7v0Hzopuuhau8GOeoqgeDqV4PzK0ZnY=; b=cX/y3JnCXSkVkBae5V5nHP8O1mrf265HRBoytg4d5fKcINWmI1cqh9jMW2lpRmAI/fNc 9WApfK/vvaOIW5Ek0LtKv9QNvMSYnqQEDvOk0zsYYrhk5o7TeQNgnubY1rk+ohcw9dTS/ vU/VNOpbQgXyH7OxK7n3s00B0Alh3TeUM1lrZTJMaQ/GUtpduJ2J/0lWTdRPTMBqub1Yd lYRVnY0QwPmncSq+d9+nvzuf6E7Pi4Pis8vCurbxiWWsdQ+tnGxzGm9uheSpNOEad6qex imvqCu8CjmssOSG1GnwlJGhnLkNBfoDDSIcFfnIExUieJNFcoA7puqpSKCffNdNjW0A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i5hhngoh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD01C606A31C; Sat, 28 Nov 2026 23:20:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=i5hhngoh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DBD41F000C1; Sat, 28 Nov 2026 23:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795908026; bh=CJ9VClW39M8j7v0Hzopuuhau8GOeoqgeDqV4PzK0ZnY=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=i5hhngohvoH3aakMx2qrA3BOaD1o51yReG4yELMvlAn2l8bNps4Bo6peUvyBXB8HV wgjvQdXd7+vEZpxbsnbO+gIWMtsfgNcBUU9AnhP18ImHmkjpGpSbaWi1VSZ1/DdAUu jFF/3Af+nx53PjIkf0MwLCGPph94r/DlG1fIj72mLvlJirdYalLUf+otY7XjXrEYPi YO12EnjjqCtnP7opsw0bO84oluELsSIq7siwoypf9g4wtpIRw+7YGzIX87bC3RMm9a wGuQypMbnWmSNGm/CJRG6ATrz89lwzV3N4ymk6z06xZDJPBDcGaZnIGcB9ChIJl3Ou 1kJH/2QVHXGmA== Date: Sat, 28 Nov 2026 23:20:22 +0000 From: Jonathan Cameron To: Andy Shevchenko Cc: Lee Jones , Marius Cristea , David Lechner , Nuno =?UTF-8?B?U8Oh?= , Andy Shevchenko , Bogdan Bolocan , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2 4/7] iio: adc: pac1934: Fix custom attribute allocation and channel bounds Message-ID: <20261128232022.753396e5@jic23-hlaptop> In-Reply-To: References: <20261123075122.373060-1-lee@kernel.org> <20261123075122.373060-5-lee@kernel.org> X-Mailer: Claws Mail 4.4.0 (GTK 3.24.52; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 23 Nov 2026 13:26:24 +0200 Andy Shevchenko wrote: > On Mon, Nov 23, 2026 at 07:50:30AM +0000, Lee Jones wrote: > > pac1934_prep_custom_attributes() sizes the pac1934_custom_attr pointer > > array using sizeof(*pac1934_group) instead of > > sizeof(*pac1934_custom_attr) and adds 1 byte rather than one pointer > > element for the terminating NULL entry. When active_channels_count is > > zero, only a single byte is allocated and iio_device_register_sysfs() > > reads past the allocation when scanning the attribute list. > > > > In addition, active_channels_count is counted over info->phys_channels, > > whereas the population steps unconditionally inspect all four entries of > > info->active_channels[], which can write past the end of the array on > > 1-, 2-, and 3-channel chip variants. > > ... > > > - Order local variables in reverse Christmas tree style (Andy, > > Jonathan) > > Oh, I meant only this for the case when we touch the content. > Since now it's not changed there, no need to do it, probably? > > ... > > > static int pac1934_prep_custom_attributes(struct pac1934_chip_info *info, > > struct iio_dev *indio_dev) > > { > > - int i, active_channels_count = 0; > > + struct device *dev = &info->client->dev; > > struct attribute **pac1934_custom_attr; > > struct attribute_group *pac1934_group; > > - struct device *dev = &info->client->dev; > > + int i, active_channels_count = 0; > > It took me a while to understand why, but no need to resend, if Jonathan is not > okay with that, this hunk may not be applied while the rest is fine. > > TL;DR: > Up to Jonathan (but personally I would leave this as in the original code). > I then decided that the risk of this racing with the devm_kzalloc_obj treewide update was high enough that I did the unusual thing and moved the base of my fixes-togreg branch to rc4. Seems fine on that, Thanks, Jonathan