[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250709165240.GF2672022@frogsfrogsfrogs>
Date: Wed, 9 Jul 2025 09:52:40 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 12/8] fuse2fs: fix races in statfs
From: Darrick J. Wong <djwong@...nel.org>
Take the BFL in statfs so that we don't expose a torn access to
userspace. Found via code inspection.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index f0250bd1cec2ec..bc9fed6f4a8525 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -2743,8 +2743,9 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)),
blk64_t overhead, reserved, free;
FUSE2FS_CHECK_CONTEXT(ff);
- fs = ff->fs;
dbg_printf(ff, "%s: path=%s\n", __func__, path);
+ fs = ff->fs;
+ pthread_mutex_lock(&ff->bfl);
buf->f_bsize = fs->blocksize;
buf->f_frsize = 0;
@@ -2777,6 +2778,7 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)),
if (fs->flags & EXT2_FLAG_RW)
buf->f_flag |= ST_RDONLY;
buf->f_namemax = EXT2_NAME_LEN;
+ pthread_mutex_unlock(&ff->bfl);
return 0;
}
Powered by blists - more mailing lists