[PATCH v2 6/7] vmsplice: return -EINVAL for particular combination of flags

From: Askar Safin

Date: Thu Jun 25 2026 - 04:37:19 EST


See comment for details.

Signed-off-by: Askar Safin <safinaskar@xxxxxxxxx>
---
fs/read_write.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/fs/read_write.c b/fs/read_write.c
index dbd0debc2..b1f71b142 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1258,6 +1258,16 @@ SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, vec,
bool non_block = (flags & SPLICE_F_NONBLOCK) || (fd_file(f)->f_flags & O_NONBLOCK);
ssize_t ret;

+ /*
+ * libfuse relies on sharing vmsplice behavior.
+ * So we detect particular combination of flags to
+ * pipe2(2) and vmsplice(2) and return -EINVAL.
+ * This forces libfuse to fail back to non-vmsplice
+ * code path.
+ */
+ if ((flags == SPLICE_F_NONBLOCK) && (fd_file(f)->f_flags & O_NONBLOCK))
+ return -EINVAL;
+
do {
pipe_lock(pipe);
ret = pipe_wait_for_space(pipe, non_block);
--
2.47.3