Skip to contentSkip to conversation

fuse: do not allow mapping a non-regular backing file

PATCH In review Amir Goldstein 2 participants 2 messages Jul 10, 2025

Subsystems (3)
lore
Share & tools
lore

Amir Goldstein

author maintainer
#0 lore raw

PATCH 1/1 fuse: do not allow mapping a non-regular backing file

We do not support passthrough operations other than read/write on regular file, so allowing non-regular backing files makes no sense.

Fixes efad7153bf93 ("fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN")

---

Miklos,

While working on readdir passthrough, I realized that we accidentrly allowed creating backing fds for non-regular files.
This needs to go to stable kernels IMO.

Thanks,
Amir.

 fs/fuse/passthrough.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/fuse/passthrough.c +5 -0
index 607ef735ad4a..eb97ac009e75 100644
@@ -237,6 +237,11 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
 	if (!file)
 		goto out;
 
+	/* read/write/splice/mmap passthrough only relevant for regular files */
+	res = d_is_dir(file->f_path.dentry) ? -EISDIR : -EINVAL;
+	if (!d_is_reg(file->f_path.dentry))
+		goto out_fput;
+
 	backing_sb = file_inode(file)->i_sb;
 	res = -ELOOP;
 	if (backing_sb->s_stack_depth >= fc->max_stack_depth)
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Amir Goldstein

We do not support passthrough operations other than read/write on regular file, so allowing non-regular backing files makes no sense.

Fixes efad7153bf93 ("fuse: allow O_PATH fd for FUSE_DEV_IOC_BACKING_OPEN")

---

Miklos,

While working on readdir passthrough, I realized that we accidentrly allowed creating backing fds for non-regular files.
This needs to go to stable kernels IMO.

Thanks,
Amir.

 fs/fuse/passthrough.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/fuse/passthrough.c +0 -0
index 607ef735ad4a..eb97ac009e75 100644
@@ -237,6 +237,11 @@ int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map)
 	if (!file)

fs/fuse/passthrough.c int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map) · line 247

Quoted 10 lines
fs/fuse/passthrough.c +5 -0
 		goto out;
 
+	/* read/write/splice/mmap passthrough only relevant for regular files */
+	res = d_is_dir(file->f_path.dentry) ? -EISDIR : -EINVAL;
+	if (!d_is_reg(file->f_path.dentry))
+		goto out_fput;
+
 	backing_sb = file_inode(file)->i_sb;
 	res = -ELOOP;
 	if (backing_sb->s_stack_depth >= fc->max_stack_depth)

LGTM,