From nobody Sun Feb 8 23:32:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68487EB64DC for ; Mon, 3 Jul 2023 14:42:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjGCOmT (ORCPT ); Mon, 3 Jul 2023 10:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbjGCOmQ (ORCPT ); Mon, 3 Jul 2023 10:42:16 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12002B2; Mon, 3 Jul 2023 07:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1688395334; bh=xUQlRJiv0BrDJu2N4vefK4PLI4lrSt6Z70TDgeQpcYs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=hKE4LH1qBJLiXXH9rih/kbNbGViPFRh7mp4kfHOm8PL48Or5SW9QTOO/HZOz0Wiqo /dV6D/T26s14gdarunqZSVTjn1AigsmFkD3jSblOg8ZLckdb7zPN5HhkOwD64aywR9 ffHZwQJBm40JW38O99WfivmMcRi+Lltc3Zwqkpami0Cxc0GnO/is19Q8qapVqPr+cl 6TLGGcvYMbWdN+vqAQqGj56hDfHCqi9BT58EARtAIm6QgOCO9QL4iQec6MTF/ZfH8K erTR/VfIhdHCiB288dTe2BY1fHtPUtWtc5MYFrypJxZ8//WHk9DvbWtufi03usHRph pgTITT+bp/m2g== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 571C71DBE; Mon, 3 Jul 2023 16:42:14 +0200 (CEST) Date: Mon, 3 Jul 2023 16:42:13 +0200 From: Ahelenia =?utf-8?Q?Ziemia=C5=84ska?= To: Christian Brauner Cc: Alexander Viro , Jan Kara , Amir Goldstein , Chung-Chiang Cheng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Message-ID: <604ec704d933e0e0121d9e107ce914512e045fad.1688393619.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jq5mboc5m63x3mer" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --jq5mboc5m63x3mer Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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/jbyihkyk5dtaohdwjyivambb2gffyjs= 3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Link: https://bugs.debian.org/1039488 Signed-off-by: Ahelenia Ziemia=C5=84ska Reviewed-by: Amir Goldstein Acked-by: Jan Kara --- fs/splice.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 3e06611d19ae..6ae6da52eba9 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1154,10 +1154,8 @@ long do_splice(struct file *in, loff_t *off_in, stru= ct file *out, if ((in->f_flags | out->f_flags) & O_NONBLOCK) flags |=3D SPLICE_F_NONBLOCK; =20 - return splice_pipe_to_pipe(ipipe, opipe, len, flags); - } - - if (ipipe) { + ret =3D splice_pipe_to_pipe(ipipe, opipe, len, flags); + } else if (ipipe) { if (off_in) return -ESPIPE; if (off_out) { @@ -1182,18 +1180,11 @@ long do_splice(struct file *in, loff_t *off_in, str= uct file *out, ret =3D do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); =20 - if (ret > 0) - fsnotify_modify(out); - if (!off_out) out->f_pos =3D offset; else *off_out =3D offset; - - return ret; - } - - if (opipe) { + } else if (opipe) { if (off_out) return -ESPIPE; if (off_in) { @@ -1209,18 +1200,24 @@ long do_splice(struct file *in, loff_t *off_in, str= uct file *out, =20 ret =3D splice_file_to_pipe(in, opipe, &offset, len, flags); =20 - if (ret > 0) - fsnotify_access(in); - if (!off_in) in->f_pos =3D offset; else *off_in =3D offset; + } else + return -EINVAL; =20 - 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); } =20 - return -EINVAL; + return ret; } =20 static long __do_splice(struct file *in, loff_t __user *off_in, --=20 2.39.2 --jq5mboc5m63x3mer Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmSi3kQACgkQvP0LAY0m WPHHCQ/8CWKTO+MNjS4ZRBYNto+BgHIPRE68LHKKAziWQgba9ovC43UxLtpmdVdL fEMuS/6qGrsLY2WynXneQZapLD4Kinsf+4wDQG+iEKlhvdFDtfejYGQTqMNADrY1 D8hz+W1imgvGgIWdTUb7P3eGtZJHHwrp3/okTZWVnknevux2+3KcAMnQeJwEZxKw Wsy+xQrK9rOdXhs4MOKlWrJWofNytkZdODeUsyzGdoe2ochw1g3FfqIOgrLLuKLj Nmdypw3N70G7CKzO2lqI9GtgL64HRH0qpi3y+svIfEirLwQYiP+7CwxS2o94RLiT MuEaSL7zWdhWQp8sfdE3lYd+4skNROUZiR5nRLEEOgw2/pRN6iwF8CjOVht/SL8y f9BMP05IP86Skwf2grIuyQiJEg2UVqgMGjsmiSNXrzi6/bBiLQhOdl/WC++uuENF 8lS6cxO/x75EonzjoV/pBm4hszIb9c/pUJoqLPhucgpbZnpbGHFRzSMZ3p6FH6wO nZ3x3/L9IRCwjyhDHzIUJvlLKlK/Gg6qjJb58uI7OUvaPtGY7HflBpfOZxLbb5MY /1xiaqzPW8z/gnDGS26tzlAPXJoh9h8j26Wj+JNpUMoVVcmEjuFmzNtEYE6y9sLD y5BJAAvnOaxm5y9vEJtuSEQejQEIlt0E7cVg7VgLgWh0Co1L5t8= =0+8T -----END PGP SIGNATURE----- --jq5mboc5m63x3mer-- From nobody Sun Feb 8 23:32:51 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB3EEB64DD for ; Mon, 3 Jul 2023 14:42:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjGCOmX (ORCPT ); Mon, 3 Jul 2023 10:42:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjGCOmU (ORCPT ); Mon, 3 Jul 2023 10:42:20 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 428C3E5C; Mon, 3 Jul 2023 07:42:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1688395338; bh=bxFjauUq2WL32jHSPjtbjDPG477Jdv0YrEDq/u80aBE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AhrIA4bpNXctnbjB9zL/sj1rGqhNvu6fT18CYncnYQWpQSIoov7xveEfjOSjqjLPy zFtA91S2is2jbaHqb6RgRM3K+YTrqhLPanrW513653hGfBScv8jheHZe9kn0okLZZJ XKA+JI+Yg0gIQrMPbxwRdGJ9k8THmYYI2v3APzNvzS8NqREcJzHyi8SqAHc1REhDAb TdXAgU+ldh/kaK3eaOOH/XDcfCLjqBQvtKHCWbxiQdr3wWsbCEEtQ7uT4FVP57VCL3 kYYXfuN2yUQWehsiZ/iLwv1fgzmh7N4qgxt2MBp0PUydMkBLfKNDQ2tHekvoqg0yO5 EZklTMJRFR6dg== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 8FBCE1B6C; Mon, 3 Jul 2023 16:42:18 +0200 (CEST) Date: Mon, 3 Jul 2023 16:42:17 +0200 From: Ahelenia =?utf-8?Q?Ziemia=C5=84ska?= To: Christian Brauner Cc: Alexander Viro , Jan Kara , Amir Goldstein , Chung-Chiang Cheng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] splice: fsnotify_access(fd)/fsnotify_modify(fd) in vmsplice Message-ID: <8d9ad5acb9c5c1dd2376a2ff5da6ac3183115389.1688393619.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ybsrpykphwaki6lg" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ybsrpykphwaki6lg Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Same logic applies here: this can fill up the pipe and pollers that rely on getting IN_MODIFY notifications never wake up. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs= 3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Link: https://bugs.debian.org/1039488 Signed-off-by: Ahelenia Ziemia=C5=84ska Reviewed-by: Amir Goldstein Acked-by: Jan Kara --- fs/splice.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/splice.c b/fs/splice.c index 6ae6da52eba9..5deb12d743b1 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1346,6 +1346,9 @@ static long vmsplice_to_user(struct file *file, struc= t iov_iter *iter, pipe_unlock(pipe); } =20 + if (ret > 0) + fsnotify_access(file); + return ret; } =20 @@ -1375,8 +1378,10 @@ static long vmsplice_to_pipe(struct file *file, stru= ct iov_iter *iter, if (!ret) ret =3D iter_to_pipe(iter, pipe, buf_flag); pipe_unlock(pipe); - if (ret > 0) + if (ret > 0) { wakeup_pipe_readers(pipe); + fsnotify_modify(file); + } return ret; } =20 --=20 2.39.2 --ybsrpykphwaki6lg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmSi3kkACgkQvP0LAY0m WPGb/g/9GGTQCA3sX50kUiY44a5rX+Ff2TYxykNMrLWb5vbRU+KcvUQeMpXDOWiB a6I5vSYTnbLemmo7VVKNUPAtN85nKRu8k30QFlYPA8nBXOBQhnfa+mu6hYzEEPZ/ oSBTcdj4eNtgDExIfQ9azx7onGtPQ/W8B4q6sXWSEy/olpqYZEwbT+D9AqZNYj+k VgcFI+dtbSw/fk03vhihniKRLrkue9vyDdkhYDuwvCLyZ0FO/W4Fnp73NPrz54g8 oUdYaOR4wfDYaFf2Mo++4wRlNsBxsVsC8+VMQKPsx2MNuyGUH1o+Hus38/htUGVk DjMp/P6icRwWLZ8+SWt3qpg1POt8voICR6OuI8JvutiHAZiMcyKvyA1vDe8Oi3sf //uzGtAyoKd2x1AybJMoYnMTdV1j8PJfxBH+8VVh6SCTCWdGcklifS2TyWZShoCt F9tKIBayhCOyEHesQQjMiIG5N2BiOnkX9Zr6gKrXwT2wFpeedAZIW4tl4af8Hv9G 1VrnO+hSsA5bLg77KgXlO3sYMLiQsW9oG3uTBds62ownw1xroMKNGIS0hHtNYk8V pUdfLZyUfbc/Kx1S4Wxz1isLdmN7dBuBj00o195RgrcsTUQhIcAYuX6c2+/CI+OC pcfVrAylsjVNMqyKwNC1ywpWxsxzMWmUaj9UQFPeVuuKkdqcG7g= =BYux -----END PGP SIGNATURE----- --ybsrpykphwaki6lg-- From nobody Sun Feb 8 23:32:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2133EC0015E for ; Mon, 3 Jul 2023 14:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230360AbjGCOma (ORCPT ); Mon, 3 Jul 2023 10:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231290AbjGCOm1 (ORCPT ); Mon, 3 Jul 2023 10:42:27 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 806B2E74; Mon, 3 Jul 2023 07:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1688395342; bh=SowbDY6YnsriPuN0djgR0SpF4itfDBztRXtp8moML7o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EsXuPnSi0xOmIDA9aB+N2jhQz9p0AOzj61HDIQTIJdzsnRWnGbDF/huwP1B2Kx+s4 GKbOd+IEDrPuqA8IYlgDBOn6HOsDRcDqUnEcUykq7eexZHfYx4Z3D/N8VYaI//nkFq WJkt4AYUkUzX5FoP6FZzjhpdok8hVpqoRCs4WGx2pbfxIKqawO2xUiBirSXWlAmDpE P8FV50NHcwz5rhWzafQCFhpJ2R+IRTIKCBssG8XeIt/RX5FLzqNjXl7fEXeVDbeqZB +llvKsXyqOJZ9yQPPq7UR0PsOfrof+FV3TOpe1D5CNEgiM3y7YUE3X9IMLGbTYa4l6 iS2kXT2bbIGnA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 9D49F1DC4; Mon, 3 Jul 2023 16:42:22 +0200 (CEST) Date: Mon, 3 Jul 2023 16:42:21 +0200 From: Ahelenia =?utf-8?Q?Ziemia=C5=84ska?= To: Christian Brauner Cc: Alexander Viro , Jan Kara , Amir Goldstein , Chung-Chiang Cheng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] splice: fsnotify_access(in), fsnotify_modify(out) on success in tee Message-ID: <10d76dd8c85017ae3cd047c9b9a32e26daefdaa2.1688393619.git.nabijaczleweli@nabijaczleweli.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kdyjczppc4aawsdj" Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20230517 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --kdyjczppc4aawsdj Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Same logic applies here: this can fill up the pipe, and pollers that rely on getting IN_MODIFY notifications never wake up. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs= 3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Link: https://bugs.debian.org/1039488 Signed-off-by: Ahelenia Ziemia=C5=84ska Reviewed-by: Amir Goldstein Acked-by: Jan Kara --- fs/splice.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/splice.c b/fs/splice.c index 5deb12d743b1..c49909dbf3c5 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1815,6 +1815,11 @@ long do_tee(struct file *in, struct file *out, size_= t len, unsigned int flags) } } =20 + if (ret > 0) { + fsnotify_access(in); + fsnotify_modify(out); + } + return ret; } =20 --=20 2.39.2 --kdyjczppc4aawsdj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmSi3k0ACgkQvP0LAY0m WPF9+Q/+J6bU/ve99xlYUDp9QIZx97GByxsAc60UTli80+/M2askRgboNzVMr54t WeQhhZ+c7qDVF5b6m6xBASK/cOF8jqSawpVZI7RY6FvxvaTl1gBxbaLdizgPIBc0 FpMxenMxQ/fxAlCj4OAYJRjSyunx8JciUdCo8iq9PPa+wGVFYa8Di8UMwzeh60r5 Yu+VQvsGvm74MpvZMhjtvQdljLMsdoZUx/fR4I4SIiyXP34sRm1wM+xOtlT9XO2H tm+6BizWGO0mvh6XDYeKRhgszHAKITKtH8RygIW+Vl7VrtqeUkNxh6g8XOKDQ/oK UlCnE8lWjXUq7iabebSTxBKUPSiCMMhe5tmQ77OL3RFq+frPLZV1uefCPkY/dHvP GjNnAp+vDMQ4kTN9sWK6TobWHVeN4ZQVK2EWm8jA4vTuNqp5DQTvc9pG43j/sXeC zXyUS9+KLuW6PBfJKqoULRnLgufbShCdp2EEdNpBqjgQWB8zMyYGbHq0WRVDvdfW 46irAZjFq6Hcma5/MwRU/fcPRm0TZR4uoyqiSnny7BhGoS8aCDkED5Qe8jWQt2p2 O4yuYvg5To59EL+oPrT5Oel3lRjjeysySFPEBpT3YDolvxaGnHeD1w5QVcitS5e1 2Tx8PIUIN+/ho8iKkqJBqvrUr+Idn+VF7PGi2R0IeOuPwNSmiIc= =htXo -----END PGP SIGNATURE----- --kdyjczppc4aawsdj--