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 2816A15A4B3 for ; Fri, 12 Jul 2024 12:21:52 +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=1720786913; cv=none; b=JchAOE+k3cKioVrZMlH70HFfMY8FYqwha9A+xoyZd2VLDcmYYN5uuFfGAhKjXf1LtdeZmeuerr+KX6fc2J/j3dVl4u26vcvwB3XgxfkxWQR2s9HY7l7H4cxt0Jw4DlTn5nFpeZQWFnEKJPtQY5WqrbKTJf3kr10n3NMxl7qzfYY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720786913; c=relaxed/simple; bh=7LjvzbKAXcvMNJPIeOLlcUnokfHazmUhfT0srCQeNVM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=p95ScjWGdj/Wj9wfY5Z9I/d3m3eY2nNLhAJVJX4I3RLepmwwu0aXYNCRGAMWoRDFZYAuWqV+7hl3+ZnxYzAwclI3+nduyLRjdJN1y+e6WP+vZUK9S5geujPKNQ+A5f4sy1DY88CdU9M6VGzV3BD8IrtlZArlTwbA9NDooV31xTQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ITqOI//I; 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="ITqOI//I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52931C32782; Fri, 12 Jul 2024 12:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1720786912; bh=7LjvzbKAXcvMNJPIeOLlcUnokfHazmUhfT0srCQeNVM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ITqOI//I+OCxkNFN5nMeOHUaPPhV2BjYqgKOh5AHjgO7eDI9kBzNhpkKQ58h/utiB SZrKuwPmwtfXG01wqyxIZQppGHPZAmJ7Vd9ErUhIsF0UuF4rEd9qs3PM5WC8dPzVmZ HIunIxHJF+Vjukn8EI1yTacefPXw/stoihMLatdE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-39496: btrfs: zoned: fix use-after-free due to race with dev replace Date: Fri, 12 Jul 2024 14:21:02 +0200 Message-ID: <2024071202-CVE-2024-39496-7948@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=2624; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=7LjvzbKAXcvMNJPIeOLlcUnokfHazmUhfT0srCQeNVM=; b=owGbwMvMwCRo6H6F97bub03G02pJDGkT5dd5NP3zC3TKljx3S1e9dAZDe/TZUw2LVl5ZtJ17x sZ5a7i4OmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiB3cxLJim98lx3YNNRYfv LDnHzafvFnCizYphQetzWf2u2bY/u54ZvFmhcdKroye4FAA= 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: btrfs: zoned: fix use-after-free due to race with dev replace While loading a zone's info during creation of a block group, we can race with a device replace operation and then trigger a use-after-free on the device that was just replaced (source device of the replace operation). This happens because at btrfs_load_zone_info() we extract a device from the chunk map into a local variable and then use the device while not under the protection of the device replace rwsem. So if there's a device replace operation happening when we extract the device and that device is the source of the replace operation, we will trigger a use-after-free if before we finish using the device the replace operation finishes and frees the device. Fix this by enlarging the critical section under the protection of the device replace rwsem so that all uses of the device are done inside the critical section. The Linux kernel CVE team has assigned CVE-2024-39496 to this issue. Affected and fixed versions =========================== Fixed in 6.1.95 with commit 17765964703b Fixed in 6.6.35 with commit 092571ef9a81 Fixed in 6.9.6 with commit a0cc006f4214 Fixed in 6.10-rc1 with commit 0090d6e1b210 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-39496 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/zoned.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/17765964703b88d8befd899f8501150bb7e07e43 https://git.kernel.org/stable/c/092571ef9a812566c8f2c9038d9c2a64c49788d6 https://git.kernel.org/stable/c/a0cc006f4214b87e70983c692e05bb36c59b5752 https://git.kernel.org/stable/c/0090d6e1b210551e63cf43958dc7a1ec942cdde9