Message ID | 15974c79b84c0b3aad566ff7c33b082f90ac5f17e.1697486714.git.nabijaczleweli@nabijaczleweli.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7627848vqy; Tue, 12 Dec 2023 02:25:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGXW2lzHcOAbagfRvnORdOpday7nMvT/rMakVyMp/PNuEXCDN/rkufONIlvYy9a0hqQEi0 X-Received: by 2002:a05:6870:b69e:b0:1fb:75c:3fdc with SMTP id cy30-20020a056870b69e00b001fb075c3fdcmr7767640oab.60.1702376715943; Tue, 12 Dec 2023 02:25:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702376715; cv=none; d=google.com; s=arc-20160816; b=TX1Vf1uVEcf7ByzlTnm9VllEZ8DusJ8WG7/mtnG2C76+iWuH2s9Q4M2eN77h8FbDHN iJJ42jPL4No04dwEj3yAXyL27ENH6sEvwfqETErpPEE4nwJzDQYnGgPvjN34xR/g8Z1c UBKOt5lkBVI0vup5/YhDWmIHanduzRxF7dtNrWdnNEZZlUcWFzM1p4uBN2VPMUeOQmjI 1oAAN0dLNviQq6PqtLS84w0dJcVMaJkO7uwEQBG6Sr3rLw0VBrdzxOzGns7P82GSVI3U flEc1tlwefZTBK0s1D91Gqn3jdVBsRDGiozBc5CPT0Bj7+/UKxot6q8Qdib1e1Ve+R03 w0gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:user-agent:message-id:subject:to:from:date :dkim-signature; bh=D76F55ANdy0bgWlY2OaYu03oUjSczmKbC4DwH9YTUI0=; fh=c1hve9LK7bidUltaxotdOOkNtWZ8Drk/KOyPdUWU/OI=; b=YkST1GdEVDaalhhDFKzK9KL+prMX8dv5c/R2z8LML3Hh3ykt/K02+F26sSzeVdSUcG cwUBtjfpZF9s4Quu5G2czJeH8D1OHhA6oIVz/YgUakPXojBMeluvhS2LMdrD0E4hUPvu uko9l5dA7DbOIs8ALLT+vnpymYA7a6UmTw+SxMvO3DioNAbnNrxHsJtPpqkr8MOT6LoA FCA6h0MVejfx47hjy7YFAZyMdU3DXEpCjoV8KonY3Qfrklw/DeMqqaWihrBoeMi8hyAk YpiQKGy+6nWD0F4SIt+CffLoc51fHOEJeBZ+3UQe/b3Q6QWQaOD6CqOnRFETt+1IzIkp Nvzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=dbOXt0fX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b9-20020a63eb49000000b00565db2812a0si7565590pgk.60.2023.12.12.02.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 02:25:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=dbOXt0fX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CF4CC8054B56; Tue, 12 Dec 2023 02:13:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbjLLKNR (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Tue, 12 Dec 2023 05:13:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235138AbjLLKNF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Dec 2023 05:13:05 -0500 Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B72C10A; Tue, 12 Dec 2023 02:12:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1702375977; bh=vAk4SO4174j23/YAeB+887LjqaZL3bPNr0Lgpgmz8Yo=; h=Date:From:To:Subject:References:In-Reply-To:From; b=dbOXt0fXbgSGzj0VKyKA8rPuUcws7V4+PXn/drjN3ykVlSvzAMXIeBrAC88PRWd8K NFKzgXoQiguXHwRzHQvi5KPzdw3YhKv5kUTmltbJetqef9LolBZxutnKsgf/uBT5Uw 8Fj4RXMQvYY++5i9gVtI3kr/q7rwxWPI/LhUi1uwBZYQLm/Z7miTdtgEiBJcCQ4tLz H2DiukQB0KJwDl3vVgnVnSTNH7VoT/MfDLX7aNysDOtS83YJRZbaIayuZp5xuqoft3 5vkfJRg6xcq2i9+NgN2ShqqICr9fLToud0dZ2Oe+9k8xhEFvQ6O/P1KTr1ec4b8qYw Z9+LQrgBinSmQ== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id DCDF113782; Tue, 12 Dec 2023 11:12:57 +0100 (CET) Date: Tue, 12 Dec 2023 11:12:57 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= <nabijaczleweli@nabijaczleweli.xyz> To: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND 10/11] splice: file->pipe: -EINVAL for non-regular files w/o FMODE_NOWAIT Message-ID: <15974c79b84c0b3aad566ff7c33b082f90ac5f17e.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231103 References: <cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="y7t5mx3qrwhlffgl" Content-Disposition: inline In-Reply-To: <1cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 02:13:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779945812061719191 X-GMAIL-MSGID: 1785071367265731952 |
Series |
splice(file<>pipe) I/O on file as-if O_NONBLOCK
|
|
Commit Message
Ahelenia Ziemiańska
Dec. 12, 2023, 10:12 a.m. UTC
We request non-blocking I/O in the generic implementation, but some
files ‒ ttys ‒ only check O_NONBLOCK. Refuse them here, lest we
risk sleeping with the pipe locked for indeterminate lengths of
time.
This also masks inconsistent wake-ups (usually every second line)
when splicing from ttys in icanon mode.
Regular files don't /have/ a distinct O_NONBLOCK mode,
because they always behave non-blockingly, and for them FMODE_NOWAIT is
used in the purest sense of
/* File is capable of returning -EAGAIN if I/O will block */
which is not set by the vast majority of filesystems,
and it's not the semantic we want here.
Link: https://lore.kernel.org/linux-fsdevel/qk6hjuam54khlaikf2ssom6custxf5is2ekkaequf4hvode3ls@zgf7j5j4ubvw/t/#u
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
fs/splice.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/splice.c b/fs/splice.c index 9d29664f23ee..81788bf7daa1 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1300,6 +1300,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, } else if (opipe) { if (off_out) return -ESPIPE; + if (!((in->f_mode & FMODE_NOWAIT) || S_ISREG(in->f_inode->i_mode))) + return -EINVAL; if (off_in) { if (!(in->f_mode & FMODE_PREAD)) return -EINVAL;