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 2EB0C168DC for ; Sun, 19 May 2024 08:36:18 +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=1716107779; cv=none; b=AbN6fbwJ4JtjBmsSd4YPoBFTDOX7KLeoVFyFZ606MYFPq8tNhjlKv6yi+pxJIryYsvVKehzerIzOnxt0s+forETTVav92Y+8J4/hiprBwsQv5T6hvkxCf2HfohAzxSr/DiZk6UifwiYrrMu0sGiwzlFUfyIhlmO7xOLKrtOXah4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716107779; c=relaxed/simple; bh=mSr/DwcGsDftZhcdd8IqPciakxGcIby+JMU50PIFotw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fpYf435k/+qOc5zkpw0zyUZOQw08HzkUFzyAPMHLOJeMHcMQb551lCHTRAKpiu1+T7QgDnZGNeUeBNAChKIbW3qO5Q1h/TMTCt3NAbvOF0cjX/1YB/Gple2wRF3WA8zqUWwzulJtccINa5jAG4BQdQ1cf/19jt+eymp7pOcorE0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wmC5xgUh; 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="wmC5xgUh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61742C32781; Sun, 19 May 2024 08:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716107778; bh=mSr/DwcGsDftZhcdd8IqPciakxGcIby+JMU50PIFotw=; h=From:To:Cc:Subject:Date:Reply-to:From; b=wmC5xgUhIYdiDmq6N783OzJuvZIG4Y2IlrhaXjXfJwd+shUz+nsT50qJI65/NXjca 7zTS1PFL7/xpCKfkmFhHyP7hLFfUxisQ2wscsGrak0yyHJOK8DRwzEjDuWzPIxxXF2 n1Z7zItn/ajSIhDKApxRKUvRTVFzqljPWZ45PAyc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-35860: bpf: support deferring bpf_link dealloc to after RCU grace period Date: Sun, 19 May 2024 10:34:34 +0200 Message-ID: <2024051935-CVE-2024-35860-04fd@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=3301; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=mSr/DwcGsDftZhcdd8IqPciakxGcIby+JMU50PIFotw=; b=owGbwMvMwCRo6H6F97bub03G02pJDGmeO2e7VZ7qfR5xY7Ozd0LIM6b9M2KXsls/0Ju1LP1WY ts9r8XeHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjAR8xcM80v/ym3afm39+ZWP rG5pxvvq27M4HmaYn2x4ueBC0ZeZDvv3NT/LPf6tTm8eJwA= 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: support deferring bpf_link dealloc to after RCU grace period BPF link for some program types is passed as a "context" which can be used by those BPF programs to look up additional information. E.g., for multi-kprobes and multi-uprobes, link is used to fetch BPF cookie values. Because of this runtime dependency, when bpf_link refcnt drops to zero there could still be active BPF programs running accessing link data. This patch adds generic support to defer bpf_link dealloc callback to after RCU GP, if requested. This is done by exposing two different deallocation callbacks, one synchronous and one deferred. If deferred one is provided, bpf_link_free() will schedule dealloc_deferred() callback to happen after RCU GP. BPF is using two flavors of RCU: "classic" non-sleepable one and RCU tasks trace one. The latter is used when sleepable BPF programs are used. bpf_link_free() accommodates that by checking underlying BPF program's sleepable flag, and goes either through normal RCU GP only for non-sleepable, or through RCU tasks trace GP *and* then normal RCU GP (taking into account rcu_trace_implies_rcu_gp() optimization), if BPF program is sleepable. We use this for multi-kprobe and multi-uprobe links, which dereference link during program run. We also preventively switch raw_tp link to use deferred dealloc callback, as upcoming changes in bpf-next tree expose raw_tp link data (specifically, cookie value) to BPF program at runtime as well. The Linux kernel CVE team has assigned CVE-2024-35860 to this issue. Affected and fixed versions =========================== Issue introduced in 5.18 with commit 0dcac2725406 and fixed in 6.6.26 with commit 876941f533e7 Issue introduced in 5.18 with commit 0dcac2725406 and fixed in 6.8.5 with commit 5d8d44777756 Issue introduced in 5.18 with commit 0dcac2725406 and fixed in 6.9 with commit 1a80dbcb2dba 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-2024-35860 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: include/linux/bpf.h kernel/bpf/syscall.c kernel/trace/bpf_trace.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/876941f533e7b47fc69977fc4551c02f2d18af97 https://git.kernel.org/stable/c/5d8d447777564b35f67000e7838e7ccb64d525c8 https://git.kernel.org/stable/c/1a80dbcb2dbaf6e4c216e62e30fa7d3daa8001ce