[GIT PULL for v6.6] super fixes

From: Christian Brauner
Date: Thu Aug 31 2023 - 07:05:03 EST


Hey Linus,

/* Summary */
This contains two more small follow-up fixes for the super work this
cycle. I went through all filesystems once more and detected two minor
issues that still needed fixing:

* Some filesystems support mtd devices (e.g., mount -t jffs2 mtd2 /mnt).
The mtd infrastructure uses the sb->s_mtd pointer to find an existing
superblock. When the mtd device is put and sb->s_mtd cleared the
superblock can still be found fs_supers and so this risks a
use-after-free.

Add a small patch that aligns mtd with what we did for regular block
devices and switch keying to rely on sb->s_dev.

(This was tested with mtd devices and jffs2 as xfstests doesn't
support mtd devices.)

* Switch nfs back to rely on kill_anon_super() so the superblock is
removed from the list of active supers before sb->s_fs_info is freed.

/* Testing */
clang: Ubuntu clang version 15.0.7
gcc: (Ubuntu 12.2.0-3ubuntu1) 12.2.0

All patches are based on v6.6-vfs.super and have been sitting in
linux-next. No build failures or warnings were observed. All old and new
tests in selftests, and LTP pass without regressions.

/* Conflicts */
At the time of creating this PR no merge conflicts were reported from
linux-next and no merge conflicts showed up doing a test-merge with
current mainline.

The following changes since commit b97d64c722598ffed42ece814a2cb791336c6679:

Merge tag '6.6-rc-smb3-client-fixes-part1' of git://git.samba.org/sfrench/cifs-2.6 (2023-08-30 21:01:40 -0700)

are available in the Git repository at:

git@xxxxxxxxxxxxxxxxxxx:pub/scm/linux/kernel/git/vfs/vfs tags/v6.6-vfs.super.fixes.2

for you to fetch changes up to 5069ba84b5e67873a2dfa4bf73a24506950fa1bf:

NFS: switch back to using kill_anon_super (2023-08-31 12:47:16 +0200)

Please consider pulling these changes from the signed v6.6-vfs.super.fixes.2 tag.

Thanks!
Christian

----------------------------------------------------------------
v6.6-vfs.super.fixes.2

----------------------------------------------------------------
Christian Brauner (2):
fs: export sget_dev()
mtd: key superblock by device number

Christoph Hellwig (1):
NFS: switch back to using kill_anon_super

drivers/mtd/mtdsuper.c | 45 +++++++++--------------------------
fs/nfs/super.c | 4 +---
fs/super.c | 64 +++++++++++++++++++++++++++++++++++---------------
include/linux/fs.h | 1 +
4 files changed, 58 insertions(+), 56 deletions(-)