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 ECAF915820C for ; Wed, 12 Mar 2025 09:42:35 +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=1741772556; cv=none; b=JPGe5vv9v7QFKeRrv6YujwbEz/r0QcDRTpNaRzm/ULnEWVeKZSPC4ml5G5Ms7QhUZSfDwxr/MFJRq7KjAGJd/UiQUHO5ER5FLY/175Rh+ClH3WcUMI4l5fKZPD2Oqj+N2pEfDAYK9JJTa+S/Rbk1NooQ/ASUDdWtArJZZsjlonU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741772556; c=relaxed/simple; bh=7DY++LUpk8t9mYXrxJmxaan8lSYwYndmm4pqIvcKXGg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B9qMRQczXXqQIP6syyIHgmzQ7bdipiEWB5KTE2Yuk6lKoNoBXlRcZPPmgq9FuNfUePzVfXS/FCgFTTwvvbAf8seHQ3GkURdhu8w2Mo24+jdL8C9m66WvdpFl3WbNLfl7GA4EQ0spO3/JwfSaAqzFosnQCLGXv1QajUcNMOVedLQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Nwf9GfPi; 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="Nwf9GfPi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F6EC4CEE3; Wed, 12 Mar 2025 09:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741772555; bh=7DY++LUpk8t9mYXrxJmxaan8lSYwYndmm4pqIvcKXGg=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Nwf9GfPi0prFgUOxo+rU51d4vE1Bpz+rVa5FoGq5azqtX/hKecHRkp2DUJ5SjFteW mBK1u81zk2OstwSYhsbKSchBt3u1zazr5Er/HDQMCYTSMlIyq3n3AZ5yP+Wb9fBdkT NKG0H2wnYTq3nq4quuxQdLeoAbkc0Vw8nZK2ahQs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-21853: bpf: avoid holding freeze_mutex during mmap operation Date: Wed, 12 Mar 2025 10:42:19 +0100 Message-ID: <2025031214-CVE-2025-21853-cf76@gregkh> X-Mailer: git-send-email 2.48.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=2918; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=7DY++LUpk8t9mYXrxJmxaan8lSYwYndmm4pqIvcKXGg=; b=owGbwMvMwCRo6H6F97bub03G02pJDOkXw749M1IzO95/on5XmnLqfZnA09smGjoZeb/W87+q2 XGsy6OuI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZi38mwYKerx2LX7Wud7hRE T8/b8iTim960yQzz4xd8WVQS9Cdr2YuZX3f9mb3UI+wRNwA= 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: avoid holding freeze_mutex during mmap operation We use map->freeze_mutex to prevent races between map_freeze() and memory mapping BPF map contents with writable permissions. The way we naively do this means we'll hold freeze_mutex for entire duration of all the mm and VMA manipulations, which is completely unnecessary. This can potentially also lead to deadlocks, as reported by syzbot in [0]. So, instead, hold freeze_mutex only during writeability checks, bump (proactively) "write active" count for the map, unlock the mutex and proceed with mmap logic. And only if something went wrong during mmap logic, then undo that "write active" counter increment. [0] https://lore.kernel.org/bpf/678dcbc9.050a0220.303755.0066.GAE@google.com/ The Linux kernel CVE team has assigned CVE-2025-21853 to this issue. Affected and fixed versions =========================== Issue introduced in 5.5 with commit fc9702273e2edb90400a34b3be76f7b08fa3344b and fixed in 6.6.80 with commit 29cfda62ab4d92ab94123813db49ab76c1e61b29 Issue introduced in 5.5 with commit fc9702273e2edb90400a34b3be76f7b08fa3344b and fixed in 6.12.17 with commit d95607a5f2f9bb08194c9deaf4a5f3e8ba59a9d4 Issue introduced in 5.5 with commit fc9702273e2edb90400a34b3be76f7b08fa3344b and fixed in 6.13.5 with commit 271e49f8a58edba65bc2b1250a0abaa98c4bfdbe Issue introduced in 5.5 with commit fc9702273e2edb90400a34b3be76f7b08fa3344b and fixed in 6.14-rc4 with commit bc27c52eea189e8f7492d40739b7746d67b65beb 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-2025-21853 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/syscall.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/29cfda62ab4d92ab94123813db49ab76c1e61b29 https://git.kernel.org/stable/c/d95607a5f2f9bb08194c9deaf4a5f3e8ba59a9d4 https://git.kernel.org/stable/c/271e49f8a58edba65bc2b1250a0abaa98c4bfdbe https://git.kernel.org/stable/c/bc27c52eea189e8f7492d40739b7746d67b65beb