Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp699012pxb; Wed, 20 Jan 2021 19:03:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzwtJ3UYWT/Tc1ahVwXpC3llj8qIjFDSTVflLcgZHPuysVYbwhALrBcOPr7Z4mOHVRxa/un X-Received: by 2002:a05:6402:31a4:: with SMTP id dj4mr5412893edb.156.1611198210471; Wed, 20 Jan 2021 19:03:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611198210; cv=none; d=google.com; s=arc-20160816; b=wDUuOt9Pcp3af5s+rGOoh9MkwKCWTMkeYSYtY4qaxhQOlE6FRt9Vz5POMrTSpvLAB+ OHr9Z4xNrcfbibrvdwjHpBEkpS9OmEbJW2S55xP0JgeVc0NJg8VvoNFYLq+4T8gvz4XK 6rGCq9mD8fawgjYzbHCgAjU0v7CEkgbkgriJyyJbKX/uc10XsNTFk/4OWIEVDwbSIhD5 0sSn1FI7brvh7rIiQMB+MHO9Q0/sOhxLJMaobmdmrFP9X801H9gXq4mWOx2MIx+hHj7T i6IceN9St8C88D+ne1ciFrP3pbYrZRB6fac/1E/Fh7VEgFAuGJHmHPj32rkDomJqBjoO 5HTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ODPoz9hPAijZQyEMqD2Yk97iw9F5m5omjfJdawf4URM=; b=OEZE32xIx2IdQAk6MLcY3+AiEvDAMYK/a+8sNzxzXYl6v6Hr2BPfjQTpEoMySStxRQ KY2tJqmRJ9k1bJOf5cLzu9snNOCKGui9djPUaHg4GsXFdQv65R9f9y5vK54h55qrIUY4 sbxvXNFdvDYNRodSgp0v4urz2WEG/7xn7Npkmo2yOYMZWbqRRgIW+sHfp43Tv4KwApcb udKZhR+fQB1Df/s8VvXUEvwloo0L9YfiWrnrXdKkuVkDS0n4Ww5Mpv5w55Xjfe5X9vfG vmRUHPjiFObV0gU2RJmdbuBujNvmsCq7g2bFcY3vf1ok9ame7nocipNAfxrnv70QzsRM 5rkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si1362254ejg.566.2021.01.20.19.03.07; Wed, 20 Jan 2021 19:03:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391991AbhAUBDq (ORCPT + 99 others); Wed, 20 Jan 2021 20:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727935AbhAUAj3 (ORCPT ); Wed, 20 Jan 2021 19:39:29 -0500 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [IPv6:2607:5300:60:148a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02206C061757 for ; Wed, 20 Jan 2021 16:38:48 -0800 (PST) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1l2Nzf-0042f0-6V; Thu, 21 Jan 2021 00:38:35 +0000 Date: Thu, 21 Jan 2021 00:38:35 +0000 From: Al Viro To: Linus Torvalds Cc: Christoph Hellwig , Johannes Berg , Oliver Giles , Linux Kernel Mailing List , Greg Kroah-Hartman Subject: Re: Splicing to/from a tty Message-ID: <20210121003835.GF740243@zeniv-ca> References: <20210118085311.GA2735@lst.de> <20210118193457.GA736435@zeniv-ca> <20210118195400.GC736435@zeniv-ca> <20210120162608.GB740243@zeniv-ca> <20210120191116.GC740243@zeniv-ca> <20210120231439.GE740243@zeniv-ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021 at 03:40:29PM -0800, Linus Torvalds wrote: > On Wed, Jan 20, 2021 at 3:14 PM Al Viro wrote: > > > > Umm... Why do we clear FMODE_PWRITE there [seq_open - ed], anyway? > > I think it's pointless and historical, and comes from "several /proc > files supported the simple single-write model, nothing ever supported > moving around and writing". > > The seq_file stuff was always about reading, and then the writing part > was generally random special-case hacks on the side. > > So I think that "clear PWRITE" thing is to make sure we get sane error > cases if somebody tries something funny, knowing that none of the > hacky stuff support it. > > And then the very special kernfs thing adds it back in, because it > does in fact allow seeking writes. OK... I wonder how many debugfs writable files allow pwrite() with BS results... Anyway, possibly more interesting question is why do we care about O_APPEND at all - why not treat it the same way we do in write()? Hell, even our pwrite() just goes ahead and writes to the end of file, whatever position it had been given. Yes, for pwrite(2) that's contrary to POSIX, but it's probably cast in stone by that point anyway... Looking through the instances of ->splice_write(), iter_file_splice_write() will end up appending the data to EOF and so will gfs2_file_splice_write(). For sockets (generic_splice_sendpage()) we definitely don't give a toss about O_APPEND (F_SETFL can set it, so that case is possible to hit), ditto for splice_write_null() and port_fops_splice_write(). Which leaves only one instance: fuse_dev_splice_write(), which also should ignore O_APPEND (IMO fuse_dev_open() ought to call nonseekable_open() anyway). So... why do we ban O_APPEND on destination for splice() or for sendfile()? AFAICS, if we simply remove that test, we'll end up with write going to the end of O_APPEND file. same as for write()/pwrite(). Comments?