From patchwork Thu Dec 21 03:09:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?0L3QsNCx?= X-Patchwork-Id: 13500930 X-Patchwork-Delegate: kuba@kernel.org Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B53C11733; Thu, 21 Dec 2023 03:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="nkTFe+Uc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1703128143; bh=6cAMXGnL8xft83SbIhEKbKmwbcXCq5q+4GH8QxHM/tU=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=nkTFe+UcamJPNdAUF84BUUelHqg5p0U2NAf/DySmBvEG1zMkvmE8aQS/RngAaN4Kz zC5+ksKX3o+01b3rHDWmjsUPIBqXUwr3xzsNHXotTXW4jdRFqHlhE9rm/Zsq9V1AiA 5lURoPVM0hVQz/fQN2B+ZOeK1vzk+UD962C8pCjJr2FU0KLs+EcbZDBIgDIcbwG0tU vs2YV9lOSzqMm3wKj3T5mo9w7pWrHmRIYG4lNbVOm7PNGIpf7IqR/UXlNdTtDoVOFH OSTHH3079/bf8upcZ4UjTbYiO9zGahq4NJr275pKX86OKXmpB8JBMEBkkpUFLqy5xq UNIiRVnlOhrXA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 5C10313776; Thu, 21 Dec 2023 04:09:03 +0100 (CET) Date: Thu, 21 Dec 2023 04:09:03 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jens Axboe , Christian Brauner , Alexander Viro , linux-fsdevel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Howells , Shigeru Yoshida , Kuniyuki Iwashima , Peilin Ye , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/11] kcm: kcm_splice_read: always request MSG_DONTWAIT Message-ID: <0d8847df2f13e0831ee2f5504d06d5d12036d8f9.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20231103-116-3b855e-dirty X-Patchwork-Delegate: kuba@kernel.org Otherwise we risk sleeping with the pipe locked for indeterminate lengths of time ‒ given: cat > kcm.c <<^D #define _GNU_SOURCE #include #include #include #include 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 --- 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;