From patchwork Thu Dec 21 03:09:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 181966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp157040dyi; Wed, 20 Dec 2023 19:13:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFx0A7kRqM9GWLX20FPjzXq+zSMVub0BmeCFkhAe+hZATTuwww3ZKxXH95mbwXNCddG6j8a X-Received: by 2002:a05:620a:1b97:b0:780:f12f:228e with SMTP id dv23-20020a05620a1b9700b00780f12f228emr5282299qkb.155.1703128387702; Wed, 20 Dec 2023 19:13:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703128387; cv=none; d=google.com; s=arc-20160816; b=EvynSiXa9L/VOHzniQNkTkT3N3jHryswZrT/anFZuV2XSmWyVTLKHon93FAiUf2H2s qv8Hf0znGhY/5HAdV3aLHU+TBCjYSfzbb+gNskRV6F6oJ9gJVf+DwgG3JEgBKWr4Itqq CezRUwykw2JXR7u4U+mpaZAGuStov2P5AaLyKs+YArqZEIIQ6vt4zFyzxPINbEwQTtJe D9/CTJe65k1vLcEVHeT4jCpUOWbKOxena20P5fzqxK5vICrvyztRgamcLhPTwJtwOCer qRrjAr3ZSex26TRsDCVxv1Zvj6NnWicsJkA6YYPOiDgTgEwpHMJVPSmRr1nSmfTZrO+n OmYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:from:date:dkim-signature; bh=QL0lddTMwRPoSZ6aTDIQu4Srn7Q11jih7quYd1vg0Vo=; fh=0E7MDSxZff8q8FD7gqZm8K+CR5d2LVVqLJHmFdEJ7Hs=; b=xY2TrMZBLYKCbWQBo+Y/N9t3jloIXT7iW5epAGBubi2xjElkc6r4ITjiqWXmnCDiTs uvS1In1K8pZBXirOlXJtMOc0rijcngmcTjsoB9F+u97JFxYvCOc8MSPTOV07d5OKetip HDmmNsh6XdZ4uzVrRNdXus4VX9EbJ+Xiy1ysQZuI58WS/zocRAl4sgaLi3B+iXGwFPr+ AvtnzxcDurLFSHfnBpxnwRMhpf8yx8xYzvGxzEnzjmM5PuIh9hfJlNe42FdU5H1GkbKI kzf/u4BaHqL7rm7WCUs8YZq0RbsueyT9XcIaOTmzNssuuyBN9Cg53yzVI6blw+8I+SXS +sMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=F7gAnsMy; spf=pass (google.com: domain of linux-kernel+bounces-7786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7786-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id qp3-20020a05620a388300b0077d7d812e3csi1115445qkn.691.2023.12.20.19.13.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:13:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=F7gAnsMy; spf=pass (google.com: domain of linux-kernel+bounces-7786-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7786-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1A8621C240F4 for ; Thu, 21 Dec 2023 03:13:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E626A249FF; Thu, 21 Dec 2023 03:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="F7gAnsMy" X-Original-To: linux-kernel@vger.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 ED18722324; Thu, 21 Dec 2023 03:09:27 +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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1703128166; bh=QL0lddTMwRPoSZ6aTDIQu4Srn7Q11jih7quYd1vg0Vo=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=F7gAnsMyVXO678N+0p+QbMrYBWgojnKNsTIWjttkyfbMZ1MBMUxaIBde0RDt12APh i3Jko7SRzsL1OmiSoIJ4SZ4H6msWH7exQvARD+Jv8HX13w0KORDjAXdTH+Idhj0+X5 GGYH8ke4EI8fIy5O5jg0HH1Ju4a0MSDgVguNsJ0i6Tb//n+Jmvrz0YvkwBlwT5erA4 T/7Md7StzD6FraWo9cmrWWYZTQ6bKz9PpM306NILw6tAxiF9D45Uuhdw8yF4l2ZYH0 QGqBAu0FjQjTd/sqTkj5dUCM0n4fpM1f3dJP7jwVqjPcZAhfI9T4K1xhtdIbPBL48N PQAUUz7vlAFAA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 5CB8213DB6; Thu, 21 Dec 2023 04:09:26 +0100 (CET) Date: Thu, 21 Dec 2023 04:09:26 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jens Axboe , Christian Brauner , Alexander Viro , linux-fsdevel@vger.kernel.org, Alejandro Colomar , linux-man@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/11 man-pages] splice.2: document 6.8 blocking behaviour Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785859552456172183 X-GMAIL-MSGID: 1785859552456172183 Hypothetical text that matches v2. Signed-off-by: Ahelenia ZiemiaƄska --- man2/splice.2 | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/man2/splice.2 b/man2/splice.2 index e5d05a05c..d2c7ac8d5 100644 --- a/man2/splice.2 +++ b/man2/splice.2 @@ -139,10 +139,11 @@ .SH ERRORS .B EAGAIN .B SPLICE_F_NONBLOCK was specified in -.I flags -or one of the file descriptors had been marked as nonblocking -.RB ( O_NONBLOCK ) , -and the operation would block. +.IR flags , +one of the file descriptors had been marked as nonblocking +.RB ( O_NONBLOCK ) +and the operation would block, +or splicing from an untrusted IPC mechanism and no data was available (see HISTORY below). .TP .B EBADF One or both file descriptors are not valid, @@ -192,6 +193,44 @@ .SH HISTORY Since Linux 2.6.31, .\" commit 7c77f0b3f9208c339a4b40737bb2cb0f0319bb8d both arguments may refer to pipes. +.P +Between Linux 4.9 and 6.7, +.\" commit 8924feff66f35fe22ce77aafe3f21eb8e5cff881 +splicing from a non-pipe to a pipe without +.B SPLICE_F_NONBLOCK +would hold the pipe lock and wait for data on the non-pipe. +This isn't an issue for files, but if the non-pipe is a tty, +or an IPC mechanism like a socket or a +.BR fuse (4) +filesystem, this means that a thread attempting any operation (like +.BR open (2)/ read (2)/ write (2)/ close (2)) +on the pipe would enter uninterruptible sleep until data appeared, +which may never happen. +The same applies to splicing from a pipe to a full socket. +.P +Since Linux 6.8, +.\" commit TBD +splicing from ttys is disabled +.RB ( EINVAL ), +reads done when splicing from sockets happen in non-blocking mode +(as-if +.BR MSG_DONTWAIT , +returning +.B EAGAIN +if no data is available), +and splicing from +.BR fuse (4) +filesystems is only allowed if they were mounted by +root in the initial user namespace +(this matches security semantics for normal filesystems). +If a splice implementation is devised that doesn't need to lock the pipe +while waiting for data, this may be reversed in a future version. +Writes when splicing to sockets are also done non-blockingly +(as-if +.BR MSG_DONTWAIT , +returning +.B EAGAIN +if the socket is full). .SH NOTES The three system calls .BR splice (),