Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4539953rdb; Tue, 12 Dec 2023 02:25:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYbhTRarT/inJl1c7fh8ZrPFF7GzmsIxqenoS/HlVVk5zZWw/yBYyOtZs8kBctzm1Z9luh X-Received: by 2002:a17:902:d346:b0:1d0:98b8:7c96 with SMTP id l6-20020a170902d34600b001d098b87c96mr2919966plk.53.1702376724174; Tue, 12 Dec 2023 02:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702376724; cv=none; d=google.com; s=arc-20160816; b=bnQQ48zGlA7Yvit6IL4bweW+rnnCom9Pxsv31u7WXISkfoeNlz7fHoTKcj80i40nmf L7WPFattnZBxQPFtqTcEkyoPwteaK0Ck/VrG17C3KCiAwIfsn7PpvpS8SC/1vAln8h6n CCvPosk9gxCXRi8tgmN/TRWDEzOKp/desNLGLWhswha+pmO8EtIxh3K5rc2wluw7/qkb 0CH8TnI9uOCjOAnepAbHMv3aWWKDtL+3RPMSKsoXQ2a3E1GFwfMgcWC1rpwayTyLjoC3 fgJ5IpKcrQG1nTNeMFlIoqldnpmD07Fvvb/GSRxT/c1rQ0tFMVKDNV/eRBY6wrUn/9re sqyg== 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 Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j12-20020a170903024c00b001d0c1281f07si7753823plh.205.2023.12.12.02.25.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 02:25:24 -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 76A348054B6C; Tue, 12 Dec 2023 02:13:52 -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 + 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 ); 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?= To: Alexander Viro , Christian Brauner , 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: 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: 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:52 -0800 (PST) --y7t5mx3qrwhlffgl Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable We request non-blocking I/O in the generic implementation, but some files =E2=80=92 ttys =E2=80=92 only check O_NONBLOCK. Refuse them here, les= t 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/qk6hjuam54khlaikf2ssom6custxf5i= s2ekkaequf4hvode3ls@zgf7j5j4ubvw/t/#u Signed-off-by: Ahelenia Ziemia=C5=84ska --- 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, struc= t 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; --=20 2.39.2 --y7t5mx3qrwhlffgl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmV4MikACgkQvP0LAY0m WPGYyQ//Tquu7sSWASqmOJvlr2pjnwv9/NwuaGlAnKWjPhH1AcvQV0+YC+ifbR59 AaSCix0+PZeI7Yw9dc9h87F73aiwm1G60fzdSMkNtH6ZwjU3stWlN44r6E+ZAhti sKefJ1e7FgLMYyMpNEf+8D1FhDWaTCBxQH0KTZk+rV3R4l1103T7/HZZP0fIRw29 u94hDgHyixw1Hm+wd7G8QDf4uaT1CDAl8CWTsI3rzZqsWoFXReX4/QHFDyUXUBIV P7uFIpLEZ6KOSMNK2zJ5NyjW/K/KpcN4FfnzqS7KEAmQrOKkqN8S/+xiIeG/lyRF cQevMVvliQWQqT6p3JNhCa3w2wiCx5QEvVlqlZmtptLSgGbOKxoyh77A29k4DINq ovOVi2PMUotFm3ZdX5rk2D13w3r8eEtFznF2gpGhyRDNGnNe7Fm8PDqLZUhwiDhu f3NEALxJGWr7EOL5wP4ZVsRMnL+jvWAKNFqhyfttbH3qt/2D8k6+fZekuCyXqJSG 9zcm/5ffXyBCoIiL0XhtFiKfQ9SrSZaHh2Qwhl9WCvx00WLtBYbG9nu2u8RAN/8D W2ugUNcyIaobnVLxiViYeY/VhH/XsQsHxWJDYYVrqWpYn097FEByyD7Aw+UyIvFO ksuZmHjkSsQp6hft+bFMURmOVeqRgYDZ4PohyESGl+wRCdCHHZg= =IhiX -----END PGP SIGNATURE----- --y7t5mx3qrwhlffgl--