Subject: CVE-2024-50087: btrfs: fix uninitialized pointer free on read_alloc_one_name() error

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

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

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

btrfs: fix uninitialized pointer free on read_alloc_one_name() error

The function read_alloc_one_name() does not initialize the name field of
the passed fscrypt_str struct if kmalloc fails to allocate the
corresponding buffer.  Thus, it is not guaranteed that
fscrypt_str.name is initialized when freeing it.

This is a follow-up to the linked patch that fixes the remaining
instances of the bug introduced by commit e43eec81c516 ("btrfs: use
struct qstr instead of name and namelen pairs").

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

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

	Issue introduced in 6.1.57 with commit 1cf474cd474b and fixed in 6.1.114 with commit b37de9491f14
	Issue introduced in 6.2 with commit e43eec81c516 and fixed in 6.6.58 with commit 7fc7c47b9ba0
	Issue introduced in 6.2 with commit e43eec81c516 and fixed in 6.11.5 with commit 1ec28de5e476
	Issue introduced in 6.2 with commit e43eec81c516 and fixed in 6.12-rc4 with commit 2ab5e243c226

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-50087
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/tree-log.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/b37de9491f140a0ff125c27dd1050185c3accbc1
	https://git.kernel.org/stable/c/7fc7c47b9ba0cf2d192f2117a64b24881b0b577f
	https://git.kernel.org/stable/c/1ec28de5e476913ae51f909660b4447eddb28838
	https://git.kernel.org/stable/c/2ab5e243c2266c841e0f6904fad1514b18eaf510