Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3545522pxy; Tue, 4 May 2021 04:53:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDvawtZwZFQtJkCx6YmZ3IbOXNDKPOWZtGNxbE/sEb1JSwO3dE8hQnFmHM7/OKqMkYLuM0 X-Received: by 2002:a17:90b:1d86:: with SMTP id pf6mr27200889pjb.59.1620129180772; Tue, 04 May 2021 04:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620129180; cv=none; d=google.com; s=arc-20160816; b=zPtP1AnTn8LEuMccmeilOkpGuEGwHHa3zLUNwqNLC/7jReBXUObWMS3ZNojSXXbQlD dIbb/aF3fEli8cssOchWaaYbp5KhA7TWsHGd/rY0EafEslpqgAVwMTN7/DfokJomhodX lG9+Ss5WOfnjRia5ahVB9ulKo29IGTQb0G2wGkCVvbicbB/Ph9GFNs26HpiK5Xqzgp9/ AxshX27kN+XzStupRxHLejNdfGXSIhdwropgBulyxGSFmWv8ouT5yhCWvQMHNfbl+cM4 FacuXpN0VGT9bki+YOvy3HVkatgcVzLRMy5tdQn4Iceo55xwYEMPSkKIFLKY5hTUCFfH PZGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=/ok8aIPlK9xTprJJi14inc/AUpDiz9YLcs0C7tD4PM4=; b=apYp4hbgOcySazQ1VJuP0VXxDMBZBP/vzwtYaA/Ocq0FJiKSCD9zylglyVQp4FsAUf PoSX1rMjVkFGrBkx8AWAdHJuWmwwWQ2NM2uOuqdI2fVIhimLe27YvlPYr05UqIYSieNo 1N9oVixl5J6yvCaGgl+x3PrTgvy2QvgfgmsLCBEeTMojC0GjkjBN/LtXGK4Lqfq/KI4q Ype0OV0ED+1Houa3i9Y72Pz+xeOG08WB4DayPgVIUcwd+3xc7Kg0kumlQA5bZEorXwZE J4UyZzWlsfDZP8PVi7r6xpEWYN8+xGrIzGqiN6sSZyeNP2WNtM+AY2i2WzLJRlj/fGFJ 1v1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s9USfbjj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si3057693pgl.464.2021.05.04.04.52.48; Tue, 04 May 2021 04:53:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s9USfbjj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230187AbhEDLxB (ORCPT + 99 others); Tue, 4 May 2021 07:53:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:44454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230089AbhEDLxA (ORCPT ); Tue, 4 May 2021 07:53:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 511A360240; Tue, 4 May 2021 11:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620129125; bh=CYlTF8vPOUGmP1yrj7WXGHoZZMuyrNVYYEyGYgffhQQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s9USfbjjXhLtVfch5jWn/Z3G+U9DCpzZ6IpciENXXJSVOTDjJrWwokOxltdsRqO9h bIaG6mNG27BKjX4+ieMquX/Y/eV0kQzpzl5x0UoWcn74Ndr3OgCbqYVkCdxhIzsNPg MKWro3VGJKzDzSRui4MFkqT7CH4OvAGM9cKqU7Jk9y+f4uMmOj0gSNkCvvxyOr+s5j eD9kibxr/8N5vQkT/GR0dE2bNqIIZD8vwl3NybBdkSMO2yujuewgGkxWk23f/RUYa4 BLTc2oqbzXas8Zeif/sZGypzN4Xwa06Or8VEJH/ZkVXt7OBL56kDav35SJ+3VpjV// UjpKR1w+nJJwQ== Date: Tue, 4 May 2021 12:51:30 +0100 From: Mark Brown To: Lukas Wunner Cc: Joe Burmeister , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, linux-spi@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nsaenz@kernel.org, phil@raspberrypi.com Subject: Re: [PATCH] spi: bcm2835: Fix buffer overflow with CS able to go beyond limit. Message-ID: <20210504115130.GA7094@sirena.org.uk> References: <20210420083402.6950-1-joe.burmeister@devtank.co.uk> <7c9f9376-1a80-b624-7b9e-0f6d04437c02@devtank.co.uk> <271ad212-a606-620e-3f0c-d6bff272be3c@gmail.com> <380624c4-82f3-0e6e-8cdb-8a9732636db8@devtank.co.uk> <20210423115724.GB5507@sirena.org.uk> <672e8d77-ee5c-f10f-0bd3-f8708dfc24c8@devtank.co.uk> <20210423162055.GE5507@sirena.org.uk> <20210501195135.GA18501@wunner.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+QahgC5+KEYLbs62" Content-Disposition: inline In-Reply-To: <20210501195135.GA18501@wunner.de> X-Cookie: MY income is ALL disposable! User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --+QahgC5+KEYLbs62 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, May 01, 2021 at 09:51:35PM +0200, Lukas Wunner wrote: > On Fri, Apr 23, 2021 at 05:20:55PM +0100, Mark Brown wrote: > > Part of the issue here is that there has been some variation in how > > num_chipselect is interpreted with regard to GPIO based chip selects > > over time. It *should* be redundant, I'm not clear why it's in the > > generic bindings at all but that's lost to history AFAICT. > It seems num_chipselect is meant to be set to the maximum number of > *native* chipselects supported by the controller. Which is overwritten > if GPIO chipselects are used. This gets fun with the controllers that have for various reasons open coded some or all of the GPIO chip select handling. > I failed to appreciate that when I changed num_chipselects for > spi-bcm2835.c with commit 571e31fa60b3. That single line change > in the commit ought to be reverted. > And the kernel-doc ought to be amended because the crucial detail > that num_chipselect needs to be set to the maximum *native* chipselects > isn't mentioned anywhere. Can you send patches for these please? > > The best thing would be to have it not have a single array of chip > > select specific data and instead store everything in the controller_data > > that's there per-device. > Unfortunately that's non-trivial. The slave-specific data is DMA-mapped. > It could be DMA-mapped in ->setup but there's no ->unsetup to DMA-unmap > the memory once the slave is removed. Note that the slave could be removed > dynamically with a DT overlay, not just when the controller is unbound. > So we'd need a new ->unsetup hook at the very least to make this work. There's the cleanup() callback which seems to fit? --+QahgC5+KEYLbs62 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmCRNUEACgkQJNaLcl1U h9DsmQf/UKHAwxHaMURxnn5hgYu8xFWNaqLHCJM2/x2xMcPvDWe1QWDAtzr7CXg8 BsQ9qd/qGyPFHQyyJVbYK7ahxIkVFdhTkASvHGmn4uGAyKVN2QNNM5Miom5diVzA U88F61K/5WkDEcG5y85IoZKMTKlcUxL11VlWBMCYvYLNzky6iWpWlt8MPj+TBVmu QNIhRRVNEEMFEBNcg7YNHkdf+farFIu8oCaRmxFGSGLFZNx5FOBIsHL/y6djiCMZ CotSqF62zku4CDADQDFVHMzpl4JOcqWqItfl4sir3QIux6aV6KJvLDK2V7lj4noo 8VIITEOCIcvfIDGRZt6wANRN3FV/sw== =QRb8 -----END PGP SIGNATURE----- --+QahgC5+KEYLbs62--