linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: "Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>
Cc: Christian Brauner <brauner@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	"D. Wythe" <alibuda@linux.alibaba.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Alexander Mikhalitsyn <alexander@mihalicyn.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Boris Pismenny <borisp@nvidia.com>,
	Cong Wang <cong.wang@bytedance.com>,
	David Ahern <dsahern@kernel.org>,
	David Howells <dhowells@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>,
	Hyeonggon Yoo <42.hyeyoo@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jan Karcher <jaka@linux.ibm.com>,
	John Fastabend <john.fastabend@gmail.com>,
	Karsten Graul <kgraul@linux.ibm.com>, Kirill Tkhai <tkhai@ya.ru>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Li kunyu <kunyu@nfschina.com>,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Miklos Szeredi <miklos@szeredi.hu>,
	Paolo Abeni <pabeni@redhat.com>,
	Pengcheng Yang <yangpc@wangsu.com>,
	Shigeru Yoshida <syoshida@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Tony Lu <tonylu@linux.alibaba.com>,
	Wen Gu <guwen@linux.alibaba.com>,
	Wenjia Zhang <wenjia@linux.ibm.com>,
	Xu Panda <xu.panda@zte.com.cn>,
	Zhang Zhengming <zhang.zhengming@h3c.com>
Subject: Re: [PATCH RERESEND 00/11] splice(file<>pipe) I/O on file as-if O_NONBLOCK
Date: Thu, 14 Dec 2023 12:06:57 -0700	[thread overview]
Message-ID: <500557ed-3967-455e-8a79-d64711045b70@kernel.dk> (raw)
In-Reply-To: <2cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz>

On 12/14/23 11:44 AM, Ahelenia Ziemia?ska wrote:
> First:  https://lore.kernel.org/lkml/cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz/t/#u
> Resend: https://lore.kernel.org/lkml/1cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz/t/#u
> Resending again per https://lore.kernel.org/lkml/20231214093859.01f6e2cd@kernel.org/t/#u
> 
> Hi!
> 
> As it stands, splice(file -> pipe):
> 1. locks the pipe,
> 2. does a read from the file,
> 3. unlocks the pipe.
> 
> For reading from regular files and blcokdevs this makes no difference.
> But if the file is a tty or a socket, for example, this means that until
> data appears, which it may never do, every process trying to read from
> or open the pipe enters an uninterruptible sleep,
> and will only exit it if the splicing process is killed.
> 
> This trivially denies service to:
> * any hypothetical pipe-based log collexion system
> * all nullmailer installations
> * me, personally, when I'm pasting stuff into qemu -serial chardev:pipe
> 
> This follows:
> 1. https://lore.kernel.org/linux-fsdevel/qk6hjuam54khlaikf2ssom6custxf5is2ekkaequf4hvode3ls@zgf7j5j4ubvw/t/#u
> 2. a security@ thread rooted in
>    <irrrblivicfc7o3lfq7yjm2lrxq35iyya4gyozlohw24gdzyg7@azmluufpdfvu>
> 3. https://nabijaczleweli.xyz/content/blogn_t/011-linux-splice-exclusion.html
> 
> Patches were posted and then discarded on principle or funxionality,
> all in all terminating in Linus posting
>> But it is possible that we need to just bite the bullet and say
>> "copy_splice_read() needs to use a non-blocking kiocb for the IO".
> 
> This does that, effectively making splice(file -> pipe)
> request (and require) O_NONBLOCK on reads fron the file:
> this doesn't affect splicing from regular files and blockdevs,
> since they're always non-blocking
> (and requesting the stronger "no kernel sleep" IOCB_NOWAIT is non-sensical),

Not sure how you got the idea that regular files or block devices is
always non-blocking, this is certainly not true without IOCB_NOWAIT.
Without IOCB_NOWAIT, you can certainly be waiting for previous IO to
complete.

> but always returns -EINVAL for ttys.
> Sockets behave as expected from O_NONBLOCK reads:
> splice if there's data available else -EAGAIN.
> 
> This should all pretty much behave as-expected.

Should it? Seems like there's a very high risk of breaking existing use
cases here.

Have you at all looked into the approach of enabling splice to/from
_without_ holding the pipe lock? That, to me, would seem like a much
saner approach, with the caveat that I have not looked into that at all
so there may indeed be reasons why this is not feasible.

-- 
Jens Axboe


  parent reply	other threads:[~2023-12-14 19:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 18:44 [PATCH RERESEND 00/11] splice(file<>pipe) I/O on file as-if O_NONBLOCK Ahelenia Ziemiańska
2023-12-14 18:44 ` [PATCH RERESEND 01/11] splice: copy_splice_read: do the I/O with IOCB_NOWAIT Ahelenia Ziemiańska
2023-12-14 18:44 ` [PATCH RERESEND 02/11] af_unix: unix_stream_splice_read: always request MSG_DONTWAIT Ahelenia Ziemiańska
2023-12-14 18:44 ` [PATCH RERESEND 03/11] fuse: fuse_dev_splice_read: use nonblocking I/O Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 04/11] tracing: tracing_buffers_splice_read: behave as-if non-blocking I/O Ahelenia Ziemiańska
2023-12-20 16:41   ` Steven Rostedt
2023-12-14 18:45 ` [PATCH RERESEND 05/11] relayfs: relay_file_splice_read: always return -EAGAIN for no data Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 06/11] net/smc: smc_splice_read: always request MSG_DONTWAIT Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 07/11] kcm: kcm_splice_read: " Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 08/11] tls/sw: tls_sw_splice_read: always request non-blocking I/O Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 09/11] net/tcp: tcp_splice_read: always do non-blocking reads Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 10/11] splice: file->pipe: -EINVAL for non-regular files w/o FMODE_NOWAIT Ahelenia Ziemiańska
2023-12-15 15:47   ` Jens Axboe
2023-12-16  5:36     ` Ahelenia Ziemiańska
2023-12-14 18:45 ` [PATCH RERESEND 11/11] splice: splice_to_socket: always request MSG_DONTWAIT Ahelenia Ziemiańska
2023-12-14 19:06 ` Jens Axboe [this message]
2023-12-14 20:14   ` [PATCH RERESEND 00/11] splice(file<>pipe) I/O on file as-if O_NONBLOCK Ahelenia Ziemiańska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=500557ed-3967-455e-8a79-d64711045b70@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=42.hyeyoo@gmail.com \
    --cc=Ilia.Gavrilov@infotecs.ru \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexander@mihalicyn.com \
    --cc=alibuda@linux.alibaba.com \
    --cc=borisp@nvidia.com \
    --cc=brauner@kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=jaka@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=kunyu@nfschina.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=surenb@google.com \
    --cc=syoshida@redhat.com \
    --cc=tkhai@ya.ru \
    --cc=tonylu@linux.alibaba.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wenjia@linux.ibm.com \
    --cc=xu.panda@zte.com.cn \
    --cc=yangpc@wangsu.com \
    --cc=zhang.zhengming@h3c.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).