Subject: CVE-2024-38583: nilfs2: fix use-after-free of timer for log writer thread

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

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

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

nilfs2: fix use-after-free of timer for log writer thread

Patch series "nilfs2: fix log writer related issues".

This bug fix series covers three nilfs2 log writer-related issues,
including a timer use-after-free issue and potential deadlock issue on
unmount, and a potential freeze issue in event synchronization found
during their analysis.  Details are described in each commit log.

This patch (of 3):

A use-after-free issue has been reported regarding the timer sc_timer on
the nilfs_sc_info structure.

The problem is that even though it is used to wake up a sleeping log
writer thread, sc_timer is not shut down until the nilfs_sc_info structure
is about to be freed, and is used regardless of the thread's lifetime.

Fix this issue by limiting the use of sc_timer only while the log writer
thread is alive.

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

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

	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 4.19.316 with commit 822ae5a8eac3
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 5.4.278 with commit 82933c84f188
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 5.10.219 with commit 67fa90d4a2cc
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 5.15.161 with commit e65ccf3a4de4
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 6.1.94 with commit 86a30d6302de
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 6.6.33 with commit f9186bba4ea2
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 6.8.12 with commit 2f12b2c03c5d
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 6.9.3 with commit 68e738be5c51
	Issue introduced in 2.6.35 with commit fdce895ea5dd and fixed in 6.10 with commit f5d4e04634c9

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-38583
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/nilfs2/segment.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/822ae5a8eac30478578a75f7e064f0584931bf2d
	https://git.kernel.org/stable/c/82933c84f188dcfe89eb26b0b48ab5d1ca99d164
	https://git.kernel.org/stable/c/67fa90d4a2ccd9ebb0e1e168c7d0b5d0cf3c7148
	https://git.kernel.org/stable/c/e65ccf3a4de4f0c763d94789615b83e11f204438
	https://git.kernel.org/stable/c/86a30d6302deddb9fb97ba6fc4b04d0e870b582a
	https://git.kernel.org/stable/c/f9186bba4ea282b07293c1c892441df3a5441cb0
	https://git.kernel.org/stable/c/2f12b2c03c5dae1a0de0a9e5853177e3d6eee3c6
	https://git.kernel.org/stable/c/68e738be5c518fc3c4e9146b66f67c8fee0135fb
	https://git.kernel.org/stable/c/f5d4e04634c9cf68bdf23de08ada0bb92e8befe7