Re: [syzbot] [ecryptfs?] KASAN: slab-use-after-free Read in ecryptfs_destroy_mount_crypt_stat
From: Edward Adam Davis
Date: Thu Sep 17 2026 - 05:10:38 EST
From: Edward Aadm Davis <eadavis@xxxxxxxx>
#syz test: upstream 238650ef6c7c
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 5f37cddb956f..6b82c077c0d6 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -441,7 +441,7 @@ static int ecryptfs_get_tree(struct fs_context *fc)
const char *err = "Getting sb failed";
struct inode *inode;
struct path path;
- int rc;
+ int rc, active;
if (!fc->source) {
rc = -EINVAL;
@@ -468,6 +468,7 @@ static int ecryptfs_get_tree(struct fs_context *fc)
goto out;
}
+ active = atomic_read(&s->s_active);
rc = super_setup_bdi(s);
if (rc)
goto out1;
@@ -562,7 +563,7 @@ static int ecryptfs_get_tree(struct fs_context *fc)
out1:
deactivate_locked_super(s);
out:
- if (sbi)
+ if (sbi && active > 1)
ecryptfs_destroy_mount_crypt_stat(&sbi->mount_crypt_stat);
printk(KERN_ERR "%s; rc = [%d]\n", err, rc);