Subject: CVE-2024-43885: btrfs: fix double inode unlock for direct IO sync writes

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

btrfs: fix double inode unlock for direct IO sync writes

If we do a direct IO sync write, at btrfs_sync_file(), and we need to skip
inode logging or we get an error starting a transaction or an error when
flushing delalloc, we end up unlocking the inode when we shouldn't under
the 'out_release_extents' label, and then unlock it again at
btrfs_direct_write().

Fix that by checking if we have to skip inode unlocking under that label.

The Linux kernel CVE team has assigned CVE-2024-43885 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.11-rc2 with commit 939b656bc8ab and fixed in 6.11-rc3 with commit e0391e92f9ab

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-43885
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/file.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/1a607d22dea4f60438747705495ec4d0af2ec451
	https://git.kernel.org/stable/c/8bd4c9220416111500c275546c69c63d42185793
	https://git.kernel.org/stable/c/7ba27f14161fc20c4fc0051658a22ddd832eb0aa
	https://git.kernel.org/stable/c/d924a0be2f218501588cf463d70f1c71afea06d9
	https://git.kernel.org/stable/c/e0391e92f9ab4fb3dbdeb139c967dcfa7ac4b115