From 48c6c901fe0e68e176029738d829e0d01eabb0b2 Mon Sep 17 00:00:00 2001 From: Lyon Wang Date: Mon, 30 Oct 2023 19:22:31 +0800 Subject: [PATCH] ANDROID: fs/passthrough: Fix compatibility with R/O file system Look at the passthrough file and check to see if its mount is read-only. Bug: 297482438 Signed-off-by: Lyon Wang Change-Id: I0f483c6bcb1effe395eee07b6d721f343840d115 (cherry picked from commit dbeed231965e1a01bf0d70ea5439fbfacc7c4aae) --- fs/fuse/passthrough.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/passthrough.c b/fs/fuse/passthrough.c index c0ae3069c6c8..2449558bac18 100644 --- a/fs/fuse/passthrough.c +++ b/fs/fuse/passthrough.c @@ -214,7 +214,8 @@ int fuse_passthrough_open(struct fuse_dev *fud, u32 lower_fd) } if (!passthrough_filp->f_op->read_iter || - !passthrough_filp->f_op->write_iter) { + !((passthrough_filp->f_path.mnt->mnt_flags | MNT_READONLY) || + passthrough_filp->f_op->write_iter)) { pr_err("FUSE: passthrough file misses file operations.\n"); res = -EBADF; goto err_free_file;