[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0d8847df2f13e0831ee2f5504d06d5d12036d8f9.1703126594.git.nabijaczleweli@nabijaczleweli.xyz>
Date: Thu, 21 Dec 2023 04:09:03 +0100
From:
Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
Cc: Jens Axboe <axboe@...nel.dk>, Christian Brauner <brauner@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>, linux-fsdevel@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
David Howells <dhowells@...hat.com>, Shigeru Yoshida <syoshida@...hat.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>, Peilin Ye <peilin.ye@...edance.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 05/11] kcm: kcm_splice_read: always request MSG_DONTWAIT
Otherwise we risk sleeping with the pipe locked for indeterminate
lengths of time ‒ given:
cat > kcm.c <<^D
#define _GNU_SOURCE
#include <fcntl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/kcm.h>
int main()
{
int kcm = socket(AF_KCM, SOCK_SEQPACKET, KCMPROTO_CONNECTED);
for (;;)
splice(kcm, 0, 1, 0, 128 * 1024 * 1024, 0);
}
^D
cc kcm.c -o kcm
mkfifo fifo
./kcm > fifo &
read -r _ < fifo &
sleep 0.1
echo zupa > fifo
kcm used to sleep in splice and the shell used to enter an
uninterruptible sleep in open("fifo");
now the splice returns -EAGAIN and the whole program completes.
Also: don't pass the SPLICE_F_*-style flags argument to
skb_recv_datagram(), which expects MSG_*-style flags.
This fixes SPLICE_F_NONBLOCK not having worked.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
---
net/kcm/kcmsock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index 65d1f6755f98..ccfc46f31891 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -1028,7 +1028,7 @@ static ssize_t kcm_splice_read(struct socket *sock, loff_t *ppos,
/* Only support splice for SOCKSEQPACKET */
- skb = skb_recv_datagram(sk, flags, &err);
+ skb = skb_recv_datagram(sk, MSG_DONTWAIT, &err);
if (!skb)
goto err_out;
--
2.39.2
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists