Re: [PATCH 12/19] fs: convert kill_litter_super to litter_shutdown_sb

2023-09-13 Thread Kees Cook
On Wed, Sep 13, 2023 at 08:10:06AM -0300, Christoph Hellwig wrote:
> Replace kill_litter_super with litter_shutdown_sb, which is wired up to
> the ->shutdown_sb method.  For file systems that wrapped
> kill_litter_super, ->kill_sb is replaced with ->shutdown and ->free_sb
> methods as needed.
> 
> Signed-off-by: Christoph Hellwig 

Reviewed-by: Kees Cook  # for pstore

-- 
Kees Cook


[PATCH 12/19] fs: convert kill_litter_super to litter_shutdown_sb

2023-09-13 Thread Christoph Hellwig
Replace kill_litter_super with litter_shutdown_sb, which is wired up to
the ->shutdown_sb method.  For file systems that wrapped
kill_litter_super, ->kill_sb is replaced with ->shutdown and ->free_sb
methods as needed.

Signed-off-by: Christoph Hellwig 
---
 arch/powerpc/platforms/cell/spufs/inode.c | 10 +-
 arch/s390/hypfs/inode.c   |  6 +++---
 drivers/android/binderfs.c| 12 +++-
 drivers/base/devtmpfs.c   |  8 
 drivers/infiniband/hw/qib/qib_fs.c|  2 +-
 drivers/misc/ibmasm/ibmasmfs.c|  8 
 drivers/usb/gadget/function/f_fs.c|  6 +++---
 drivers/usb/gadget/legacy/inode.c | 12 ++--
 drivers/xen/xenfs/super.c |  8 
 fs/binfmt_misc.c  |  8 
 fs/configfs/mount.c   |  8 
 fs/debugfs/inode.c|  8 
 fs/devpts/inode.c |  6 +++---
 fs/efivarfs/super.c   | 13 ++---
 fs/fuse/control.c | 12 ++--
 fs/hugetlbfs/inode.c  |  2 +-
 fs/nfsd/nfsctl.c  | 22 --
 fs/ocfs2/dlmfs/dlmfs.c|  2 +-
 fs/pstore/inode.c |  7 +++
 fs/ramfs/inode.c  |  6 +++---
 fs/super.c| 14 +++---
 fs/tracefs/inode.c|  2 +-
 include/linux/fs.h|  2 +-
 include/linux/ramfs.h |  2 +-
 init/do_mounts.c  |  6 +++---
 ipc/mqueue.c  |  2 +-
 kernel/bpf/inode.c|  2 +-
 mm/shmem.c|  5 +++--
 net/sunrpc/rpc_pipe.c | 19 ---
 security/inode.c  |  8 
 security/selinux/selinuxfs.c  | 15 +--
 security/smack/smackfs.c  |  6 +++---
 32 files changed, 126 insertions(+), 123 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/inode.c 
b/arch/powerpc/platforms/cell/spufs/inode.c
index 38c5be34c8951f..2610a0731ea242 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -763,11 +763,11 @@ static int spufs_init_fs_context(struct fs_context *fc)
 }
 
 static struct file_system_type spufs_type = {
-   .owner = THIS_MODULE,
-   .name = "spufs",
-   .init_fs_context = spufs_init_fs_context,
-   .parameters = spufs_fs_parameters,
-   .kill_sb = kill_litter_super,
+   .owner  = THIS_MODULE,
+   .name   = "spufs",
+   .init_fs_context= spufs_init_fs_context,
+   .parameters = spufs_fs_parameters,
+   .shutdown_sb= litter_shutdown_sb,
 };
 MODULE_ALIAS_FS("spufs");
 
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index 3261fb9cade648..f18e3b844c5d9b 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -294,9 +294,8 @@ static int hypfs_init_fs_context(struct fs_context *fc)
return 0;
 }
 
-static void hypfs_kill_super(struct super_block *sb)
+static void hypfs_free_sb(struct super_block *sb)
 {
-   kill_litter_super(sb);
kfree(sb->s_fs_info);
 }
 
@@ -417,7 +416,8 @@ static struct file_system_type hypfs_type = {
.name   = "s390_hypfs",
.init_fs_context = hypfs_init_fs_context,
.parameters = hypfs_fs_parameters,
-   .kill_sb= hypfs_kill_super
+   .shutdown_sb= litter_shutdown_sb,
+   .free_sb= hypfs_free_sb,
 };
 
 static const struct super_operations hypfs_s_ops = {
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 81effec17b3d63..f48196391239c0 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -771,19 +771,12 @@ static int binderfs_init_fs_context(struct fs_context *fc)
return 0;
 }
 
-static void binderfs_kill_super(struct super_block *sb)
+static void binderfs_free_sb(struct super_block *sb)
 {
struct binderfs_info *info = sb->s_fs_info;
 
-   /*
-* During inode eviction struct binderfs_info is needed.
-* So first wipe the super_block then free struct binderfs_info.
-*/
-   kill_litter_super(sb);
-
if (info && info->ipc_ns)
put_ipc_ns(info->ipc_ns);
-
kfree(info);
 }
 
@@ -791,7 +784,8 @@ static struct file_system_type binder_fs_type = {
.name   = "binder",
.init_fs_context= binderfs_init_fs_context,
.parameters = binderfs_fs_parameters,
-   .kill_sb= binderfs_kill_super,
+   .shutdown_sb= litter_shutdown_sb,
+   .free_sb= binderfs_free_sb,
.fs_flags   = FS_USERNS_