lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <174787198487.1484996.12546102480862938973.stgit@frogsfrogsfrogs> Date: Wed, 21 May 2025 17:11:37 -0700 From: "Darrick J. Wong" <djwong@...nel.org> To: tytso@....edu Cc: John@...ves.net, linux-ext4@...r.kernel.org, miklos@...redi.hu, joannelkoong@...il.com, bernd@...ernd.com, linux-fsdevel@...r.kernel.org Subject: [PATCH 03/16] fuse2fs: always use directio disk reads with fuse2fs From: Darrick J. Wong <djwong@...nel.org> In iomap mode, the kernel writes file data directly to the block device and does not flush the bdev page cache. We must open the filesystem in directio mode to avoid cache coherency issues when reading file data blocks. If we can't open the bdev in directio mode, we must not use iomap. Signed-off-by: "Darrick J. Wong" <djwong@...nel.org> --- misc/fuse2fs.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 92a80753f4f1e8..91c0da096bef9c 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -988,8 +988,14 @@ static errcode_t confirm_iomap(struct fuse_conn_info *conn, struct fuse2fs *ff) return 0; } + +static int iomap_enabled(const struct fuse2fs *ff) +{ + return ff->iomap_state == IOMAP_ENABLED; +} #else # define confirm_iomap(...) (0) +# define iomap_enabled(...) (0) #endif static void *op_init(struct fuse_conn_info *conn @@ -1001,6 +1007,9 @@ static void *op_init(struct fuse_conn_info *conn struct fuse_context *ctxt = fuse_get_context(); struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; ext2_filsys fs = ff->fs; +#ifdef HAVE_FUSE_IOMAP + int was_directio = ff->directio; +#endif errcode_t err; int ret; @@ -1023,6 +1032,15 @@ static void *op_init(struct fuse_conn_info *conn if (ff->iomap_state != IOMAP_DISABLED && fuse_set_feature_flag(conn, FUSE_CAP_IOMAP)) ff->iomap_state = IOMAP_ENABLED; + /* + * In iomap mode, the kernel writes file data directly to the block + * device and does not flush the bdev page cache. We must open the + * filesystem in directio mode to avoid cache coherency issues when + * reading file data. If we can't open the bdev in directio mode, we + * must not use iomap. + */ + if (iomap_enabled(ff)) + ff->directio = 1; #endif #if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) @@ -1038,6 +1056,14 @@ static void *op_init(struct fuse_conn_info *conn */ if (!fs) { err = open_fs(ff, 0); +#ifdef HAVE_FUSE_IOMAP + if (err && iomap_enabled(ff) && !was_directio) { + fuse_unset_feature_flag(conn, FUSE_CAP_IOMAP); + ff->iomap_state = IOMAP_DISABLED; + ff->directio = 0; + err = open_fs(ff, 0); + } +#endif if (err) goto mount_fail; fs = ff->fs;
Powered by blists - more mailing lists