Skip to contentSkip to conversation

CVE-2023-53440: nilfs2: fix sysfs interface lifetime

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Sep 18, 2025

lore
Share & tools
lore
#0 lore raw

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

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

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

nilfs2: fix sysfs interface lifetime

The current nilfs2 sysfs support has issues with the timing of creation and deletion of sysfs entries, potentially leading to null pointer dereferences, use-after-free, and lockdep warnings.

Some of the sysfs attributes for nilfs2 per-filesystem instance refer to metadata file "cpfile", "sufile", or "dat", but nilfs_sysfs_create_device_group that creates those attributes is executed before the inodes for these metadata files are loaded, and nilfs_sysfs_delete_device_group which deletes these sysfs entries is called after releasing their metadata file inodes.

Therefore, access to some of these sysfs attributes may occur outside of the lifetime of these metadata files, resulting in inode NULL pointer dereferences or use-after-free.

In addition, the call to nilfs_sysfs_create_device_group() is made during the locking period of the semaphore "ns_sem" of nilfs object, so the shrinker call caused by the memory allocation for the sysfs entries, may derive lock dependencies "ns_sem" -> (shrinker) -> "locks acquired in nilfs_evict_inode()".

Since nilfs2 may acquire "ns_sem" deep in the call stack holding other locks via its error handler __nilfs_error(), this causes lockdep to report circular locking. This is a false positive and no circular locking actually occurs as no inodes exist yet when nilfs_sysfs_create_device_group() is called. Fortunately, the lockdep warnings can be resolved by simply moving the call to nilfs_sysfs_create_device_group() out of "ns_sem".

This fixes these sysfs issues by revising where the device's sysfs interface is created/deleted and keeping its lifetime within the lifetime of the metadata files above.

The Linux kernel CVE team has assigned CVE-2023-53440 to this issue.

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

	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 4.14.313 with commit d20dcec8f326deb77b6688f8441e014045dac457
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 4.19.281 with commit 5fe0ea141fbb887d407f1bf572ebf24427480d5c
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 5.4.241 with commit 83b16a60e413148685739635901937e2f16a7873
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 5.10.178 with commit 3dbee84bf9e3273c4bb9ca6fc18ff22fba23dd24
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 5.15.107 with commit d540aea451ab5489777a8156560f1388449b3109
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 6.1.24 with commit 1942ccb7d95f287a312fcbabfa8bc9ba501b1953
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 6.2.11 with commit daf4eb3a908b108279b60172d2f176e70d2df875
	Issue introduced in 3.17 with commit dd70edbde2627f47df118d899de6bbb55abcfdbf and fixed in 6.3 with commit 42560f9c92cc43dce75dbf06cc0d840dced39b12

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-53440

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/super.c
fs/nilfs2/the_nilfs.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/d20dcec8f326deb77b6688f8441e014045dac457
	https://git.kernel.org/stable/c/5fe0ea141fbb887d407f1bf572ebf24427480d5c
	https://git.kernel.org/stable/c/83b16a60e413148685739635901937e2f16a7873
	https://git.kernel.org/stable/c/3dbee84bf9e3273c4bb9ca6fc18ff22fba23dd24
	https://git.kernel.org/stable/c/d540aea451ab5489777a8156560f1388449b3109
	https://git.kernel.org/stable/c/1942ccb7d95f287a312fcbabfa8bc9ba501b1953
	https://git.kernel.org/stable/c/daf4eb3a908b108279b60172d2f176e70d2df875
	https://git.kernel.org/stable/c/42560f9c92cc43dce75dbf06cc0d840dced39b12