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 82044337BAD for ; Wed, 24 Dec 2025 13:10:32 +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=1766581832; cv=none; b=sm4W3VNw+XDgNF4CFA4LLQzhC+Nx4jvF/Fb66kgCLMD7VNBjZZRd+mLTaahmnjiTSaF4UwE2HUmzvjNYSZKBF8Mh/LQZxP5RMJiyZyOokU4rG3Pa5BnYUeTR0gYvAkXksmZ6YcZ+uaf7uzXPLeETNb4H4uj0bl1r2DOKn/ZtIGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766581832; c=relaxed/simple; bh=R4eF71Fnrh+XQdvosN7g/K53LbnQLw/nkG2uugwcQ+s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NRcMyMF6KVh+uKAh5/N5n5xJ2jlOS4R5yVCGhE4xzcYCN52ENZ4/tp5BQOUupKXyEvKC1/XIsVR2E0e2enWiPjN1ZDdywXgqC8M4T+a36jUG4EZVdhd1YdoVubhpMLr1vJZ0RRs9eQt+lxxlWTb3DS4lNWQ1QQ89OM6uZmeQGhg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=weX5pZm2; 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="weX5pZm2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09A09C4CEFB; Wed, 24 Dec 2025 13:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1766581832; bh=R4eF71Fnrh+XQdvosN7g/K53LbnQLw/nkG2uugwcQ+s=; h=From:To:Cc:Subject:Date:Reply-To:From; b=weX5pZm2Gjs5O6G3qHDK0gQW01SA4UEV335z3KLY6ZU08cumW6500lwzd17MyCRmO +Fwj97NA2yk/dCZUvOASAeV1lfb9/7IWmD244gvQRr328WXIvCrLeD5c6nmCYF7yCw oLjY6a74mGa+ofARSuRLyG/2JwdTkNK2Tl2m2rsM= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-54121: btrfs: fix incorrect splitting in btrfs_drop_extent_map_range Date: Wed, 24 Dec 2025 14:07:18 +0100 Message-ID: <2025122416-CVE-2023-54121-691a@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3879; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Dxd/BD6f2XfSzoeoyuyD1jFp9Slpjk3bySfY9NsqQYE=; b=owGbwMvMwCRo6H6F97bub03G02pJDJneTz036ag4eIUcme8kff257fbmsqN7MteLt99VzL6/7 FRZ/ZW+jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZiIoAXDXCnPxuSVZhrM1pnd qfz75q1YJeYyjWG+t2u9sdoxrg33352s28ffXnvdtKMFAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: btrfs: fix incorrect splitting in btrfs_drop_extent_map_range In production we were seeing a variety of WARN_ON()'s in the extent_map code, specifically in btrfs_drop_extent_map_range() when we have to call add_extent_mapping() for our second split. Consider the following extent map layout PINNED [0 16K) [32K, 48K) and then we call btrfs_drop_extent_map_range for [0, 36K), with skip_pinned == true. The initial loop will have start = 0 end = 36K len = 36K we will find the [0, 16k) extent, but since we are pinned we will skip it, which has this code start = em_end; if (end != (u64)-1) len = start + len - em_end; em_end here is 16K, so now the values are start = 16K len = 16K + 36K - 16K = 36K len should instead be 20K. This is a problem when we find the next extent at [32K, 48K), we need to split this extent to leave [36K, 48k), however the code for the split looks like this split->start = start + len; split->len = em_end - (start + len); In this case we have em_end = 48K split->start = 16K + 36K // this should be 16K + 20K split->len = 48K - (16K + 36K) // this overflows as 16K + 36K is 52K and now we have an invalid extent_map in the tree that potentially overlaps other entries in the extent map. Even in the non-overlapping case we will have split->start set improperly, which will cause problems with any block related calculations. We don't actually need len in this loop, we can simply use end as our end point, and only adjust start up when we find a pinned extent we need to skip. Adjust the logic to do this, which keeps us from inserting an invalid extent map. We only skip_pinned in the relocation case, so this is relatively rare, except in the case where you are running relocation a lot, which can happen with auto relocation on. The Linux kernel CVE team has assigned CVE-2023-54121 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.33 with commit 55ef68990029fcd8d04d42fc184aa7fb18cf309e and fixed in 6.1.47 with commit 9f68e2105dd96cf0fafffffafb2337fbd0fbae1f Issue introduced in 2.6.33 with commit 55ef68990029fcd8d04d42fc184aa7fb18cf309e and fixed in 6.4.12 with commit b43a4c99d878cf5e59040e45c96bb0a8358bfb3b Issue introduced in 2.6.33 with commit 55ef68990029fcd8d04d42fc184aa7fb18cf309e and fixed in 6.5 with commit c962098ca4af146f2625ed64399926a098752c9c Issue introduced in 2.6.32.19 with commit c87afd35a28b2661a2626a1b28e9fd69adcad9f9 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-2023-54121 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: fs/btrfs/extent_map.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/9f68e2105dd96cf0fafffffafb2337fbd0fbae1f https://git.kernel.org/stable/c/b43a4c99d878cf5e59040e45c96bb0a8358bfb3b https://git.kernel.org/stable/c/c962098ca4af146f2625ed64399926a098752c9c