Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BD94912EBEE for ; Tue, 21 May 2024 14:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716301376; cv=none; b=EeMEXQYni6KzaDQE1+2bclqYu9ww7z94KTjnw3HsFjCb0N7y8snDrNETJDAChFS6IAO13faizlABDOxY4Xrzgxpv7R2LV6n3XEdp/534iV8os6Nl9a+jRRo6maJ2Y8XjlusS1bbDkwyJYTrWg5jtUqunlvqHUYe36giL3pRPkSQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716301376; c=relaxed/simple; bh=X1yBT8PqZSzR8W1+ZgF3y4rTH/Xmk6VVL3SmGSibajs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tUTVXD2XtXPGdS9Ondx7/Ra/PWyTbRrIMLfsmhQcBZlFM/ODlwd0LqIPuGz8lY7NI2ZsAg4+xWupb+lfB5a/cEbg7mlr8DBb+RvD3LqjDKsWIywgV2OJdhyOWoLg0PEnSocVkn9SaEgq9Rvt02SJOjsJvLkIPK0yo6361qV0M2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=O82AtFzb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="O82AtFzb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2C2DC2BD11; Tue, 21 May 2024 14:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716301376; bh=X1yBT8PqZSzR8W1+ZgF3y4rTH/Xmk6VVL3SmGSibajs=; h=From:To:Cc:Subject:Date:Reply-to:From; b=O82AtFzbi41ZqC3JGiJLMLeom0aV2qcK0PmGuFYL/TwqZ0odD+SytG/Nf+WZHvL97 stX8rDqI/EkMDBdvmZmLaePeXydMUmZ5wnbAiW2qVycpJu/GBqs4NdueYLBpZrZHVw 0RBCGhPeqySt48rB3jvMSpn+62dVb/+FYT8SfIoY= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47282: spi: bcm2835: Fix out-of-bounds access with more than 4 slaves Date: Tue, 21 May 2024 16:20:36 +0200 Message-ID: <2024052154-CVE-2021-47282-edd8@gregkh> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3146; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=X1yBT8PqZSzR8W1+ZgF3y4rTH/Xmk6VVL3SmGSibajs=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk+a7vWPzC8wHrYwmqj0f0I3wdK7TuXudmsPxArG/pxc +1hn95rHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRGlmGWUxzW2x9etfaSzOG 7S2L06radShvEsNcoff3I9Tm2Rzx/lWWcKBiYWvQItnXAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: spi: bcm2835: Fix out-of-bounds access with more than 4 slaves Commit 571e31fa60b3 ("spi: bcm2835: Cache CS register value for ->prepare_message()") limited the number of slaves to 3 at compile-time. The limitation was necessitated by a statically-sized array prepare_cs[] in the driver private data which contains a per-slave register value. The commit sought to enforce the limitation at run-time by setting the controller's num_chipselect to 3: Slaves with a higher chipselect are rejected by spi_add_device(). However the commit neglected that num_chipselect only limits the number of *native* chipselects. If GPIO chipselects are specified in the device tree for more than 3 slaves, num_chipselect is silently raised by of_spi_get_gpio_numbers() and the result are out-of-bounds accesses to the statically-sized array prepare_cs[]. As a bandaid fix which is backportable to stable, raise the number of allowed slaves to 24 (which "ought to be enough for anybody"), enforce the limitation on slave ->setup and revert num_chipselect to 3 (which is the number of native chipselects supported by the controller). An upcoming for-next commit will allow an arbitrary number of slaves. The Linux kernel CVE team has assigned CVE-2021-47282 to this issue. Affected and fixed versions =========================== Issue introduced in 5.4 with commit 571e31fa60b3 and fixed in 5.4.126 with commit b5502580cf95 Issue introduced in 5.4 with commit 571e31fa60b3 and fixed in 5.10.44 with commit 82a8ffba54d3 Issue introduced in 5.4 with commit 571e31fa60b3 and fixed in 5.12.11 with commit 01415ff85a24 Issue introduced in 5.4 with commit 571e31fa60b3 and fixed in 5.13 with commit 13817d466eb8 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2021-47282 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/spi/spi-bcm2835.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/b5502580cf958b094f3b69dfe4eece90eae01fbc https://git.kernel.org/stable/c/82a8ffba54d31e97582051cb56ba1f988018681e https://git.kernel.org/stable/c/01415ff85a24308059e06ca3e97fd7bf75648690 https://git.kernel.org/stable/c/13817d466eb8713a1ffd254f537402f091d48444