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 1604325569 for ; Wed, 19 Jun 2024 14:56:10 +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=1718808970; cv=none; b=f852g8sg+HuXoT/dzFvQ+Qrae5whfu/yls+/WLtHIt3IhvirxhB30pDJ0zcpHl3y6alwcyosUi6N3tTMsvfJD1VRLB0PwP/+NlknomB0cNo2FH65z//Z7PwbdxyemScbBKkp19p0yh2oozYEPqA1tQQf3DgGcXRd+eD7WDFAShQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718808970; c=relaxed/simple; bh=ibc3jev2ORK3dxb73cKeziydMPZMwOp9n2Gig0PPJvE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KiD0NaqK9U8ycw8Y0HrnXkWTf4rFsg8nZ1l4Q3bER4yGjfbIx1GDlHnMxpfAoEo/pOwwAXzs6z5rXXy1MasFlsibEJK9pfHGiw1H1KywAvHTZ5ysn8hfJhPFFhDcU3Cb9md+PDbISYR7HNgzN/PZPTaHHuz4O7DY9LAe6SKOQW0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=shzC/SpX; 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="shzC/SpX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 831DFC32786; Wed, 19 Jun 2024 14:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718808969; bh=ibc3jev2ORK3dxb73cKeziydMPZMwOp9n2Gig0PPJvE=; h=From:To:Cc:Subject:Date:Reply-to:From; b=shzC/SpXS74QRM6RzmItqTeTKWWP2PhbVj10xPL0m859AHFm7OHjIzdkil0cHI2PO CyDXyQnXND1drWva91pjYL+Cxo6G6C4HZ3Qr03Jr6I2qgilvVd9zBxqB2fo5VqyKZA fJNsrftVX937XuLVzvww7MQpxLkqX3wLFd4419P4= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47607: bpf: Fix kernel address leakage in atomic cmpxchg's r0 aux reg Date: Wed, 19 Jun 2024 16:54:46 +0200 Message-ID: <2024061924-CVE-2021-47607-0fbd@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=2685; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=ibc3jev2ORK3dxb73cKeziydMPZMwOp9n2Gig0PPJvE=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlFHxXulZyYJPOu3/xck+xNzScyV6XjZgteWmfC/++em b/qXYNVHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRdieG+VGb6h1/cV7kNpB1 OczCGLtzX8ubKIY5XFataxLiC522SFnYWr37MMHw+xYlAA== 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 cmpxchg's r0 aux reg The implementation of BPF_CMPXCHG on a high level has the following parameters: .-[old-val] .-[new-val] BPF_R0 = cmpxchg{32,64}(DST_REG + insn->off, BPF_R0, SRC_REG) `-[mem-loc] `-[old-val] Given a BPF insn can only have two registers (dst, src), the R0 is fixed and used as an auxilliary register for input (old value) as well as output (returning old value from memory location). While the verifier performs a number of safety checks, it misses to reject unprivileged programs where R0 contains a pointer as old value. Through brute-forcing it takes about ~16sec on my machine to leak a kernel pointer with BPF_CMPXCHG. The PoC is basically probing for kernel addresses by storing the guessed address into the map slot as a scalar, and using the map value pointer as R0 while SRC_REG has a canary value to detect a matching address. Fix it by checking R0 for pointers, and reject if that's the case for unprivileged programs. The Linux kernel CVE team has assigned CVE-2021-47607 to this issue. Affected and fixed versions =========================== Issue introduced in 5.12 with commit 5ffa25502b5a and fixed in 5.15.11 with commit f87a6c160ecc Issue introduced in 5.12 with commit 5ffa25502b5a and fixed in 5.16 with commit a82fe085f344 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-47607 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/f87a6c160ecc8c7b417d25f508d3f076fe346136 https://git.kernel.org/stable/c/a82fe085f344ef20b452cd5f481010ff96b5c4cd