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 ED5663F8F1 for ; Wed, 19 Jun 2024 14:56:12 +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=1718808973; cv=none; b=bqKh8HTbXl8Bicjq6KfWpoZk/a2o9AhjSG0Ao/OEU6GBFukdgs/QVOhsClQuApV1MKHxK2881Uvrmu1L/g+ldtQJByu/abxFR9QPHRSdMAMGvQL2mjrA7JJ46xHbJrytk6z9DLZMTwGYic8Hlffrc6GSKIOgGQhyBrs6PRS3R1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718808973; c=relaxed/simple; bh=JnAxD6irj0J6HO1qIetgEL7ltRlykSktsU/ah9iVqH4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=O8n+zh2ek56xFCbyAwbLmKrc7y1Uv4rFa1SfDfv6A5grVigk2RqoL1KlPoH2wCtRuY8+WbQ7GkBLae0jyIl/OZ2h0ytkXCLD5t/Sqt3phmRydMSSsFaTsowcGyOeIIaTsPXubdYpcOVCy7UkrOH4i9cuiM12c+BqzvuHU4AAZF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Aif/c+D9; 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="Aif/c+D9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74181C2BBFC; Wed, 19 Jun 2024 14:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718808972; bh=JnAxD6irj0J6HO1qIetgEL7ltRlykSktsU/ah9iVqH4=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Aif/c+D9VSOKtMRuo9Tt/UiMbJiIcTceT+UdYTwSv/mX7QQRoGZplOcM+BlWbkzYp 92Wb+t9PpIfh5Yih1VeyR0AXiCW5q/66uEY5W7NdvXxSrkkGVriboYTvzXNrfTXYeM o7gASiKqWEoNY5+tJ/jGSFT0d1uclfN1UVTvE4n8= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47608: bpf: Fix kernel address leakage in atomic fetch Date: Wed, 19 Jun 2024 16:54:47 +0200 Message-ID: <2024061924-CVE-2021-47608-f4eb@gregkh> X-Mailer: git-send-email 2.45.2 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=3158; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=JnAxD6irj0J6HO1qIetgEL7ltRlykSktsU/ah9iVqH4=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlFHxU2XEwJMGmdbrtm3/L8v/ZyBYunv2+/U21zqMjlz +KwGeL2HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRfR8ZFlxR+td2a19DZIja znIRvq81pQZL7RgWrDVu8tu5oTqyi23lk3/n9D8vUuxXAAA= 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: bpf: Fix kernel address leakage in atomic fetch The change in commit 37086bfdc737 ("bpf: Propagate stack bounds to registers in atomics w/ BPF_FETCH") around check_mem_access() handling is buggy since this would allow for unprivileged users to leak kernel pointers. For example, an atomic fetch/and with -1 on a stack destination which holds a spilled pointer will migrate the spilled register type into a scalar, which can then be exported out of the program (since scalar != pointer) by dumping it into a map value. The original implementation of XADD was preventing this situation by using a double call to check_mem_access() one with BPF_READ and a subsequent one with BPF_WRITE, in both cases passing -1 as a placeholder value instead of register as per XADD semantics since it didn't contain a value fetch. The BPF_READ also included a check in check_stack_read_fixed_off() which rejects the program if the stack slot is of __is_pointer_value() if dst_regno < 0. The latter is to distinguish whether we're dealing with a regular stack spill/ fill or some arithmetical operation which is disallowed on non-scalars, see also 6e7e63cbb023 ("bpf: Forbid XADD on spilled pointers for unprivileged users") for more context on check_mem_access() and its handling of placeholder value -1. One minimally intrusive option to fix the leak is for the BPF_FETCH case to initially check the BPF_READ case via check_mem_access() with -1 as register, followed by the actual load case with non-negative load_reg to propagate stack bounds to registers. The Linux kernel CVE team has assigned CVE-2021-47608 to this issue. Affected and fixed versions =========================== Issue introduced in 5.12 with commit 37086bfdc737 and fixed in 5.15.11 with commit 423628125a48 Issue introduced in 5.12 with commit 37086bfdc737 and fixed in 5.16 with commit 7d3baf0afa3a 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-47608 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: kernel/bpf/verifier.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/423628125a484538111c2c6d9bb1588eb086053b https://git.kernel.org/stable/c/7d3baf0afa3aa9102d6a521a8e4c41888bb79882