Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp852705pxb; Sat, 16 Jan 2021 09:13:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUNc4yQcn/g7ezdmxz2UYqeg5O63t59K6nffyVsn38f54BnRhI4EHFwXyx6t6EiskVAYX3 X-Received: by 2002:a05:6402:1286:: with SMTP id w6mr14293108edv.351.1610817216979; Sat, 16 Jan 2021 09:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610817216; cv=none; d=google.com; s=arc-20160816; b=1HBJ1Akn8Oz0N/17/vCCB1yuyh15vuZMObxaTV4R+TbCQWxeh7PSpnzd4vcyNSZcKG pJFEf3c+xmgidkBy8cVSyVBw14q812o57Ogedb82zxIEbeoptcHTYaq/pHADdMzDiRwE F7PnS7hzmYkjLgVyjidjl/xMVf7mCilJP7OrEgLqtQWeWUSdbGno2inGSje+n09y1f6C 4O3riDjuiX09IrtzlFcgxaNiCEFPzUKNOnwXUy27tcnU/umkCoVlyi/zien7xRMjVcqn SbeX1xj4K1IcTwO6iY4EmM4cdxXkzcOj684XWtxtoeSmn3eNI5JOcmZS90p03sK63ibp 5eQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=UKROkpS/gizgwFLKmBo3Ygt8DDTI8aT0Y0CnJ3zBOc4=; b=nlzzz1aLsouoZ5BTV3XFcWfchlXPN6hsIZSD48G3Ym0GE716uFGUflEMuehOPArdB8 w2w240yQVS1F9KQdGsrGmHdIoUv3QQnGPFM7SxFyalNXDuSDqI91wzfYDIKnpsZhnYTv /5ujDkPfdVeWy+hLzcR9Yyv3qf6J6Io3BGjxLazzA98uVvMCjChILzRz0oJyrFT8MCCk mSlI2QdwiFHgwI8DeI9PNJB74CqFfmqMb4iydBwOb4UOIus2G1fndFw+aOG/QW9DCl+S vuA7cV9NvYgxYkgA1W0VhSj6gRsnwbLM6NR6Ao+vMX6lj1Qe8cFb2G+ouwYAA+ndwwHP gY2Q== 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 x18si5811165ejd.80.2021.01.16.09.13.13; Sat, 16 Jan 2021 09:13:36 -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 S1728579AbhAPRLh (ORCPT + 99 others); Sat, 16 Jan 2021 12:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbhAPRLH (ORCPT ); Sat, 16 Jan 2021 12:11:07 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F6F3C06179A for ; Sat, 16 Jan 2021 09:09:25 -0800 (PST) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1l0oij-007MTH-H2; Sat, 16 Jan 2021 17:46:37 +0100 Message-ID: Subject: Re: Splicing to/from a tty From: Johannes Berg To: Oliver Giles , linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Christoph Hellwig Date: Sat, 16 Jan 2021 17:46:33 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-01-16 at 20:35 +1300, Oliver Giles wrote: > Commit 36e2c7421f02 (fs: don't allow splice read/write without > explicit ops) broke my userspace application which talks to an SSL VPN > by splice()ing between "openssl s_client" and "pppd". The latter > operates over a pty, and since that commit there is no fallback for > splice()ing between a pipe and a pty, or any tty for that matter. > > The above commit mentions switching them to the iter ops and using > generic_file_splice_read. IIUC, this would require implementing iter > ops also on the line disciplines, which sounds pretty disruptive. > > For my case, I attempted to instead implement splice_write and > splice_read in tty_fops; I managed to get splice_write working calling > ld->ops->write, but splice_read is not so simple because the > tty_ldisc_ops read method expects a userspace buffer. So I cannot see > how to implement this without either (a) using set_fs, or (b) > implementing iter ops on all line disciplines. > > Is splice()ing between a tty and a pipe worth supporting at all? Not a > big deal for my use case at least, but it used to work. Is it even strictly related to the tty? I was just now looking into why my cgit/fcgi/nginx setup no longer works, and the reason is getting -EINVAL from sendfile() when the input is a file and the output is a pipe(). So I wrote a simple test program (below) and that errors out on kernel 5.10.4, while it works fine on the 5.9.16 I currently have. Haven't tried reverting anything yet, but now that I haev a test program it should be simple to even bisect. johannes #include #include #include #include #include #include #include int main(int argc, char **argv) { int in = open(argv[0], O_RDONLY); int p[2], out; off_t off = 0; int err; assert(in >= 0); assert(pipe(p) >= 0); out = p[1]; err = sendfile(out, in, &off, 1024); if (err < 0) perror("sendfile"); assert(err == 1024); return 0; }