From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795059472; b=MEtqMMz2+pmiOpmIdN4flf2FbW7C+vdx85sJFfTSwlfQDZPlezu7qQPiEm6NCUXLGhu9 M6+LGBQivuenKNEgliVKuYM+Q+qomoSDCY53nJYhMFb5x3f4Xz/jT+9IaOTi/NATPqzNQ 0AHidqEJjkJkxR5a4K8s4BYS0ICI+ttba5QCxtDqz79rrAzoF/SD1I+tr8i9At+hbbq4h PQkgKSE0Om51j989MzHYuuWFOpezuXuACfF7wBeFvkQmGzbMoJaxJ5n6X1HGWeV4/x19n 7eH0USqpPgEQslA6mxwpONsZAUS8h7m/SEPQa8yFUg/lbnrKfhNo6IKyX9Pil3RTkFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795059472; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=eL60izOiwUkKYTtpQ6w6S/1XC0GgSpEF/AwZiNM8M/Y=; b=IvP0WybSsdGaMGLDgAU0tB8WW6hiCsXWExA7J6hnGjJhR2UYOx2Dih6OzrdlRBknD3kn wCc5ze6aUpagP0lAIQ4pefa8rFSNaxxwuIfLjWc4N8nlef+urUOEIywmNb0Rfc2F9ehZw Tzrvchj7IvCMvcZI767okvwFZBMtDapGVzOOA6+Y6kv7LM0oCXlZbUUnfJ2FvjS4en//5 /ePHPLU2aEJREFohiOXIy1fuR2Yf8qBml4iSAwxKXhcfn51js2Fn+ZwYFyVHAzsJsW3rq 6m7O4YEuoPX2sr1wyKRyccCz/rsTZ9EJhtneWD1mYvw+wi8+F2gsOEAE4ZSx8Tt367w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sOdh7qKI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB6AE606A325; Thu, 19 Nov 2026 03:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sOdh7qKI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 206FC1F000C4; Thu, 19 Nov 2026 03:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795059472; bh=eL60izOiwUkKYTtpQ6w6S/1XC0GgSpEF/AwZiNM8M/Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sOdh7qKIFHJZBGURwfAFW8sWC89Ln+gfw2IPoe1tpJLTV1pdUfSPX5+yRt8GJulgo uq7n9HGL31Lug18HWUbEq4BDdpdQNvmlqeUxOCAtKfO+eT518EByWUdLRzKcMvXy9T YlnmvWZpn4MyBR5mAHaaq7i+Bq1/M28RPtcxwg9k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Ahelenia=20Ziemia=C5=84ska?= , Jan Kara , Amir Goldstein , Christian Brauner , Sasha Levin Subject: [PATCH 5.10 0855/1848] splice: always fsnotify_access(in), fsnotify_modify(out) on success Date: Wed, 18 Nov 2026 15:48:13 +0100 Message-ID: <20261118145952.337178578@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118145911.150052362@linuxfoundation.org> References: <20261118145911.150052362@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ahelenia Ziemiańska [ Upstream commit 12ee4b66af34f8e72f3b2fd93a946a955efe7c86 ] The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't. This affected userspace which uses inotify, most notably coreutils tail -f, to monitor pipes. If the pipe buffer had been filled by a splice-family function: * tail wouldn't know and thus wouldn't service the pipe, and * all writes to the pipe would block because it's full, thus service was denied. (For the particular case of tail -f this could be worked around with ---disable-inotify.) Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Link: https://bugs.debian.org/1039488 Signed-off-by: Ahelenia Ziemiańska Acked-by: Jan Kara Reviewed-by: Amir Goldstein Message-Id: <604ec704d933e0e0121d9e107ce914512e045fad.1688393619.git.nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Christian Brauner Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error") Signed-off-by: Sasha Levin --- fs/splice.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index c4d3ac181a9f6..a11d5ab38ca63 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1052,10 +1052,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, if ((in->f_flags | out->f_flags) & O_NONBLOCK) flags |= SPLICE_F_NONBLOCK; - return splice_pipe_to_pipe(ipipe, opipe, len, flags); - } - - if (ipipe) { + ret = splice_pipe_to_pipe(ipipe, opipe, len, flags); + } else if (ipipe) { if (off_in) return -ESPIPE; if (off_out) { @@ -1080,18 +1078,11 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); - if (ret > 0) - fsnotify_modify(out); - if (!off_out) out->f_pos = offset; else *off_out = offset; - - return ret; - } - - if (opipe) { + } else if (opipe) { if (off_out) return -ESPIPE; if (off_in) { @@ -1107,18 +1098,25 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = splice_file_to_pipe(in, opipe, &offset, len, flags); - if (ret > 0) - fsnotify_access(in); - if (!off_in) in->f_pos = offset; else *off_in = offset; + } else { + ret = -EINVAL; + } - return ret; + if (ret > 0) { + /* + * Generate modify out before access in: + * do_splice_from() may've already sent modify out, + * and this ensures the events get merged. + */ + fsnotify_modify(out); + fsnotify_access(in); } - return -EINVAL; + return ret; } static long __do_splice(struct file *in, loff_t __user *off_in, -- 2.53.0