From patchwork Thu Dec 14 18:45:16 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: 178873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8767873dys; Thu, 14 Dec 2023 10:46:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGjGaod/aJ5DoNJN3BKnA5EthUEkawINKOBAEeeMDDJ6tZA0qVRgJ66DsCBTrJgiw4m2cg X-Received: by 2002:a05:6a00:1388:b0:6ce:fa73:a046 with SMTP id t8-20020a056a00138800b006cefa73a046mr11809030pfg.50.1702579569940; Thu, 14 Dec 2023 10:46:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702579569; cv=none; d=google.com; s=arc-20160816; b=GaMgNvhkWaLlX6tIMdELMm+8Ai0ZsA8BCkUgWcn/sukhaPFVyioAJEtDF7vLMuNgWA 95KEEt2WVDDcm97aJsEgaJPTwKfkS/DXYDG5MnAXE4kIQPw11izKgqQ/YO0sye5+KQhf Nb5pqk0JhCCph8y+Nzl167TyVao4lWE72URu4ULNE0dHDJIxVs+qbDV888YXX5AjJBwK +Tk/Pkkc/lCc06PmJygS8TCpOh5nkzWx1xPn00j54suNal0xJx2Huo77p5Z983cSJsPb a3k2Ma8WkutwCANSzrDfKnSbN8FjL7CQVa7hMKnomEX6OQtLBjae6o78pkt3ySVeXpy8 Pu0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:content-disposition:mime-version :references:user-agent:message-id:subject:cc:from:date :dkim-signature; bh=dOsvCvvko640GyLs3c2ueoX0r+kYs6M9vD3YPA0Zpbo=; fh=F3CYGF5tLt2QRCGz6RnC5dSNkSKVVQOih9/vnGahG3Q=; b=M6LO468CEcwpdORsofRpBrE8An2resszKWNdOLJtc31KFImcYLGTWMrgjIuIUCxUMm GTm5kUm0ddE54wnYLB+F74xrZR3xJIXwMmMCqs59RWhKncm0PIr+izXAiwEy/JYvajIp QdNm7HWMnhtAf5kGesVCUo9gTlZvOGd6xaSGwrgI1UJbdUevW13u309rWEvNln1VOfGu OnjFLSul7qbDjyW6sDEvAxRHx71SSvMbK5k/AJQY7Z0vMS9YJoH49aZmgHLQisYO+vpR PeXdUC6vI+7aoVE2BSUV52rjU+8LIPPAKNo1cFApcWlhYrj8nejmq+JUUm5emZ3UKdrL OKNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=bU9lIeGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u12-20020a056a00124c00b006cd8454cbb4si11791449pfi.337.2023.12.14.10.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 10:46:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=bU9lIeGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 2C81D8200CB2; Thu, 14 Dec 2023 10:46:07 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573132AbjLNSpo (ORCPT + 99 others); Thu, 14 Dec 2023 13:45:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573260AbjLNSpR (ORCPT ); Thu, 14 Dec 2023 13:45:17 -0500 Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3FF610C4; Thu, 14 Dec 2023 10:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1702579516; bh=nDrwqDx6g17tp76N5xVUDx8sUEDcvzOb97eotkFu3/k=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=bU9lIeGDIS4sb4eigHq8GkEC2G0QMzGoWlh/3T6TCHg4E7CiLMx6bQhTrB2uPpk8j ssozwnxjkVhZyEpDAVSf+GeMQ2iDxQaNQB9ZJF33EZtkloiW25yAV6e2kfwdpVNQBg rAo1xySnVgDvdqKVSOX/Hx4LKdqcTnlQaI84JLOg6QMzXXlCbUAe6Ced9wsyGUJjqU ybnPvgcZ4j8Qo80Ln49MG0FiNV3kUv2kbj6z9B/91NC+JUFPl13k8ro6EBaBE/uYLt aYiwtqxmm6DHMe24nl6WsxT3vvR/q0x+MAbHsLbLdGqvfOlyB/Lo/b3On3E8BUVJEp V6V+Z3IxNwrbA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 4786313990; Thu, 14 Dec 2023 19:45:16 +0100 (CET) Date: Thu, 14 Dec 2023 19:45:16 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= Cc: Jens Axboe , Christian Brauner , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RERESEND 10/11] splice: file->pipe: -EINVAL for non-regular files w/o FMODE_NOWAIT Message-ID: <25974c79b84c0b3aad566ff7c33b082f90ac5f17e.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231103 References: <2cover.1697486714.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <2cover.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 fry.vger.email To: unlisted-recipients:; (no To-header on input) 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 (fry.vger.email [0.0.0.0]); Thu, 14 Dec 2023 10:46:07 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785284074993824989 X-GMAIL-MSGID: 1785284074993824989 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 --- 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;