nilfs2: protect references to superblock parameters exposed in sysfs
authorRyusuke Konishi <konishi.ryusuke@gmail.com>
Sun, 11 Aug 2024 10:03:20 +0000 (19:03 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 2 Sep 2024 00:59:00 +0000 (17:59 -0700)
commit683408258917541bdb294cd717c210a04381931e
treea3e353cd465324b552c27f456ab9f4d0f20a0fab
parent4828d207dc5161dc7ddf9a4f6dcfd80c7dd7d20a
nilfs2: protect references to superblock parameters exposed in sysfs

The superblock buffers of nilfs2 can not only be overwritten at runtime
for modifications/repairs, but they are also regularly swapped, replaced
during resizing, and even abandoned when degrading to one side due to
backing device issues.  So, accessing them requires mutual exclusion using
the reader/writer semaphore "nilfs->ns_sem".

Some sysfs attribute show methods read this superblock buffer without the
necessary mutual exclusion, which can cause problems with pointer
dereferencing and memory access, so fix it.

Link: https://lkml.kernel.org/r/20240811100320.9913-1-konishi.ryusuke@gmail.com
Fixes: da7141fb78db ("nilfs2: add /sys/fs/nilfs2/<device> group")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/nilfs2/sysfs.c