Message ID | 5974c79b84c0b3aad566ff7c33b082f90ac5f17e.1697486714.git.nabijaczleweli@nabijaczleweli.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3711788vqb; Mon, 16 Oct 2023 13:36:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKmwajAAjZKVmJiCHE9yIZExRIXlU/wciHcQCaX/D+EfuDVu4qhkFjlUoWxVeOBx+EpQgE X-Received: by 2002:a05:6808:198f:b0:3a9:efde:a022 with SMTP id bj15-20020a056808198f00b003a9efdea022mr449627oib.5.1697488605522; Mon, 16 Oct 2023 13:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697488605; cv=none; d=google.com; s=arc-20160816; b=YTbXMUUKKowXUwKDWV4mJ4OTsz4iw7iXebu+qYUJk19bO3Ocz2u0Gy5bpJm8uCD6Ow RLy4kr+Rg81UM59ksGU0U/yTY9OQWtTMYWx1C7e65j5bJr7YMbRdSw5KX2Pjb09uT1Po B7AgJ8cLGHJwBPktXAniMPSEixwffxISzLCCUggDXTL27PMaCUGn8OpwJyuc0+k9h2xE 3ErLYadFRyN5HRF2kRTlcqYBhka0h+6StVA3xMEZK5ZaMX3kBf8o+bdBQxw2GCzpD3dH /RSdZLlgvp6chj5PWZ34lluC6w+u9IKPFwCPD+wD3mexylU3BfPaDr9zRhFfcjjX4yJX s9Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:from:date :dkim-signature; bh=G8dHxgA/U91iwdBMSSqIaarBh1Cx6bJJWaUon7i5IZ8=; fh=Oskmylf92gQgoWcJVK2DZkdbYki3SlnV/gEzpmChMXQ=; b=mO93WSWeD8VIYb4f/GU8/6RdYD/3+824UDQV/jTZFjy0C56cZf01B566mhccf1JDY/ T4M/H5nNmiFbzpnoAFAYSqqCNQ8htGjCRVzhb8pe9WJP8cUwkFKuJzapCEceRModICJ4 RNS3s71hoQfT2HarTt2/Za5AEMW4JFOCFBG01g5Xn4/PsJEaCmBkBnANA+wUl5ntIELi eYg/JaaMKO4fTrvpzHmy51mnA7l0MpVWsP4Y2xhqj1xLvy0aEvddqn+sNsUkwBnpVGPI mFaLhkp8a1/oLB90l0FwTaIwtAIgiHfbinb4HWmdJE3glOTuZgAkEjheieVhg3uJuKK0 07Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=JVhaOxgf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o6-20020a639206000000b0055c77028579si88005pgd.747.2023.10.16.13.36.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 13:36:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=JVhaOxgf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 364448029051; Mon, 16 Oct 2023 13:36:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234323AbjJPUgg (ORCPT <rfc822;hjfbswb@gmail.com> + 18 others); Mon, 16 Oct 2023 16:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234286AbjJPUgL (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 16 Oct 2023 16:36:11 -0400 Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03DC6F5; Mon, 16 Oct 2023 13:36:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1697488559; bh=AbhKjmGcFK7a0VSiC3Uyp/FqZCpYv3ilKDudDv/H+vg=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=JVhaOxgfx7Mls92DNPEIWl9LDiGpLsqnYzvsIikxwThGSQkKph//v1LaOuQww4Jxs 834qWDOxzlJZ+w3TVxkD/3tpeLhRRRkdC5t+fKPiLNbdpSakUTP/vVweidpMvXV/4j 0dgVhKfiNO0loNffmpqR1pBfze63D4UcGtKLRhaXHvIaleLWumdMi26LAipBDTplCd KoGZKJHXcsIS2oJ0sWeV3HjJFTTxZWaAUV7oKOnQzlIvejR/hrjok+SxPcRKCeZ5B9 6Q8ng29ppdCpc3MKP0JtRI6fKZVE+e7u4Q4ptnz/0LakLzVpNjA+kvLC1ImClyMSR4 RsIlD/R+AywNw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 1CEFD10502; Mon, 16 Oct 2023 22:35:59 +0200 (CEST) Date: Mon, 16 Oct 2023 22:35:59 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= <nabijaczleweli@nabijaczleweli.xyz> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/11] splice: file->pipe: -EINVAL for non-regular files w/o FMODE_NOWAIT Message-ID: <5974c79b84c0b3aad566ff7c33b082f90ac5f17e.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> References: <cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2kmqog55wiriurlb" Content-Disposition: inline In-Reply-To: <cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231006 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 13:36:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779945812061719191 X-GMAIL-MSGID: 1779945812061719191 |
Series |
splice(file<>pipe) I/O on file as-if O_NONBLOCK
|
|
Commit Message
Ahelenia Ziemiańska
Oct. 16, 2023, 8:35 p.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;