Message ID | 4dec932dcd027aa5836d70a6d6bedd55914c84c2.1703126594.git.nabijaczleweli@nabijaczleweli.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp156811dyi; Wed, 20 Dec 2023 19:12:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IHV73EW1V9aB3dv5i9CZdJWvItWTFuJA52yUVb0/XiXIAG4wjZSBzCZrMlO4ejaJn35ixFj X-Received: by 2002:a05:6808:3205:b0:3ba:18f8:7c5a with SMTP id cb5-20020a056808320500b003ba18f87c5amr20163228oib.112.1703128338099; Wed, 20 Dec 2023 19:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703128338; cv=none; d=google.com; s=arc-20160816; b=NyHWWbV5XksY/AZLZhy2GzYttJ9cvAXfyc4vcXTzFNrhpn7dooiog6m8RRcWN8RVk4 yzuFpXtdcGMQVIhvD89l6zB4pv8eswJq9HlqD4HGae4G+B0oEP0jdnzjbY5oVTmUrRgf VmcaK+YqpK+IdwQygUZx3zpWSlwd9ejRW7Cr1VVAonH0BnzDd3SvKoQvFZJVnLVL9Eh6 LZ7mzrsnNQuxrAepwyoOwsmLAJE4TGgZlASNYfxuZ6fLE0irowRyIpEtHCJlGHODux/c XtYoJdTotqFGmvBibzKvODD2FBp6nkta/QDhix9yvGFt5havPrIIjgg9ppFFfRdfe5sj s8eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:from:date:dkim-signature; bh=70jIeEDON3WrBuVGoUieR3JkT4KvHiSb7d7QwYW37oU=; fh=B4utz5fiilVR+ogWegaDk2fvq5j9gXCt6RLbtRbUD9M=; b=zcNV/vf3vSKZ1+EZe1hD/zgYmzZiWAbYSLfEA03Y0ckNX7U8PCRjUWfEfSmbeseEun Y6I9KsH9Ux7zLMXPTf+nHjWXRFZw86i0bMRBARd3GJaNiSAupl16kk8dHYeBeY0R5jSm G8F3KTZOVncQmdsaEkGorLg+1Hb0AU76BJWeuuYPad/ETOwbMXANtrvCYauNKmGxqE5C EWlrWdmV/ZYMoG0Ln89F27C8TX17JKVYUE0aRSU8Xq9cN1QhRel5e5YMlVLW/5vpqcDT OqUqNREVQv+mGAQkfKj2FJC7GFGgCWH+gQqucM/dUyP6+enXOXFrzxtKKhaXCSLQ5Ku1 5hrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=WnvVBEoU; spf=pass (google.com: domain of linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f29-20020a63555d000000b005c65d0dd9a0si770437pgm.503.2023.12.20.19.12.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:12:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=WnvVBEoU; spf=pass (google.com: domain of linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7782-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 42636B209E7 for <ouuuleilei@gmail.com>; Thu, 21 Dec 2023 03:12:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3752D1A71D; Thu, 21 Dec 2023 03:09:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="WnvVBEoU" X-Original-To: linux-kernel@vger.kernel.org Received: from tarta.nabijaczleweli.xyz (tarta.nabijaczleweli.xyz [139.28.40.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52D4118035; Thu, 21 Dec 2023 03:09:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nabijaczleweli.xyz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nabijaczleweli.xyz DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1703128150; bh=Jm7XzHnqDG9iwaDHGTe5ldutgziwWY+ScUPkOH8HCS0=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=WnvVBEoUJFMt79/ZV/pfyW1Dj4U9GOMXgiBmZdAw8p9y5MsOYMkGKNgVs3tq+RU6q kGnfCNltQC7vfNESPY2wuggMkbwywOgPLzEnOk1DdWumqI+LIGHIr0QpVwln7sXyjB lKQorhc2w9446jX2cHwSLOOu71JnHxShnnPyuhXTaZ8pvYdiQeRgdn1bj8E2c9kY5F Fn6w3hCwRNqO0qeq2ZHQ45u+XzoiSBMDe/lVVvxBHuXNTfwGnlJfDohjOydzALdzpY 22tTHAkwi0hnuRAlEnPYbDsIC+ZZaBuZBmd7AmHAROo5cxShp3A7BwkHLstbwXqFc9 iIY5IRYM8cZiA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id CB40D13778; Thu, 21 Dec 2023 04:09:10 +0100 (CET) Date: Thu, 21 Dec 2023 04:09:10 +0100 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= <nabijaczleweli@nabijaczleweli.xyz> Cc: Jens Axboe <axboe@kernel.dk>, Christian Brauner <brauner@kernel.org>, Alexander Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v2 08/11] tty: splice_read: disable Message-ID: <4dec932dcd027aa5836d70a6d6bedd55914c84c2.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> References: <cover.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xhoon5hag52ewyt5" Content-Disposition: inline In-Reply-To: <cover.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231103-116-3b855e-dirty X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785859500484176431 X-GMAIL-MSGID: 1785859500484176431 |
Series |
Avoid unprivileged splice(file->)/(->socket) pipe exclusion
|
|
Commit Message
Ahelenia Ziemiańska
Dec. 21, 2023, 3:09 a.m. UTC
We request non-blocking I/O in the generic copy_splice_read, but
"the tty layer doesn't actually honor the IOCB_NOWAIT flag for
various historical reasons.". This means that a tty->pipe splice
will happily sleep with the pipe locked forever, and any process
trying to take it (due to an open/read/write/&c.) will enter
uninterruptible sleep.
This also masks inconsistent wake-ups (usually every second line)
when splicing from ttys in icanon mode.
Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wimmqG_wvSRtMiKPeGGDL816n65u=Mq2+H3-=uM2U6FmA@mail.gmail.com/
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
drivers/tty/tty_io.c | 2 --
1 file changed, 2 deletions(-)
Comments
On Thu, Dec 21, 2023 at 04:09:10AM +0100, Ahelenia Ziemiańska wrote: > We request non-blocking I/O in the generic copy_splice_read, but > "the tty layer doesn't actually honor the IOCB_NOWAIT flag for > various historical reasons.". This means that a tty->pipe splice > will happily sleep with the pipe locked forever, and any process > trying to take it (due to an open/read/write/&c.) will enter > uninterruptible sleep. > > This also masks inconsistent wake-ups (usually every second line) > when splicing from ttys in icanon mode. > > Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wimmqG_wvSRtMiKPeGGDL816n65u=Mq2+H3-=uM2U6FmA@mail.gmail.com/ > Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> > --- Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
On 21. 12. 23, 4:09, Ahelenia Ziemiańska wrote: > We request non-blocking I/O in the generic copy_splice_read, but > "the tty layer doesn't actually honor the IOCB_NOWAIT flag for > various historical reasons.". This means that a tty->pipe splice > will happily sleep with the pipe locked forever, and any process > trying to take it (due to an open/read/write/&c.) will enter > uninterruptible sleep. > > This also masks inconsistent wake-ups (usually every second line) > when splicing from ttys in icanon mode. > > Link: https://lore.kernel.org/linux-fsdevel/CAHk-=wimmqG_wvSRtMiKPeGGDL816n65u=Mq2+H3-=uM2U6FmA@mail.gmail.com/ > Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> > --- > drivers/tty/tty_io.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c > index 06414e43e0b5..50c2957a9c7f 100644 > --- a/drivers/tty/tty_io.c > +++ b/drivers/tty/tty_io.c > @@ -465,7 +465,6 @@ static const struct file_operations tty_fops = { > .llseek = no_llseek, > .read_iter = tty_read, > .write_iter = tty_write, > - .splice_read = copy_splice_read, > .splice_write = iter_file_splice_write, This and the other patch effectively reverts dd78b0c483e33 and 9bb48c82aced0. I.e. it breaks "things". Especially: commit 9bb48c82aced07698a2d08ee0f1475a6c4f6b266 Author: Linus Torvalds <torvalds@linux-foundation.org> Date: Tue Jan 19 11:41:16 2021 -0800 tty: implement write_iter This makes the tty layer use the .write_iter() function instead of the traditional .write() functionality. That allows writev(), but more importantly also makes it possible to enable .splice_write() for ttys, reinstating the "splice to tty" functionality that was lost in commit 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops"). Fixes: 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops") What are those "things" doing that "splice to tty", I don't recall and the commit message above ^^^ does not spell that out. Linus? thanks,
On Wed, 3 Jan 2024 at 03:36, Jiri Slaby <jirislaby@kernel.org> wrote: > > What are those "things" doing that "splice to tty", I don't recall and > the commit message above ^^^ does not spell that out. Linus? It's some annoying SSL VPN thing that splices to pppd: https://lore.kernel.org/all/C8KER7U60WXE.25UFD8RE6QZQK@oguc/ and I'd be happy to try to limit splice to tty's to maybe just the one case that pppd uses. So I don't think we should remove splice_write for tty's entirely, but maybe we can limit it to only the case that the VPN thing used. I never saw the original issue personally, and I think only Oliver reported it, so cc'ing Oliver. Maybe that VPN thing already has the pty in non-blocking mode, for example, and we could make the tty splicing fail for any blocking op? Linus
On Wed, Jan 3 2024 at 11:14:59 -08:00:00, Linus Torvalds <torvalds@linux-foundation.org> wrote: > > It's some annoying SSL VPN thing that splices to pppd: > > https://lore.kernel.org/all/C8KER7U60WXE.25UFD8RE6QZQK@oguc/ I'm happy to report that that particular SSL VPN tool is no longer around. And it had anyway grown a fall-back-to-read/write in case splice() fails. So at least from my perspective, no objections to splice-to-tty going away altogether. > and I'd be happy to try to limit splice to tty's to maybe just the one > case that pppd uses. To be exact, pppd is just providing a pty with which other (now all extinct?) applications can do nefarious things. > Maybe that VPN thing already has the pty in non-blocking mode, for > example, and we could make the tty splicing fail for any blocking op? FWIW, the SSL VPN tool did indeed have the pty in non-blocking mode. Oliver
On Wed, 3 Jan 2024 at 13:34, Oliver Giles <ohw.giles@gmail.com> wrote: > > I'm happy to report that that particular SSL VPN tool is no longer > around. Ahh, well that simplifies things and we can then just remove the tty splice support again. Of course, maybe then somebody else will report on some other odd user, but ... fingers crossed. Linus
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 06414e43e0b5..50c2957a9c7f 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -465,7 +465,6 @@ static const struct file_operations tty_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = tty_write, - .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, @@ -480,7 +479,6 @@ static const struct file_operations console_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = redirected_tty_write, - .splice_read = copy_splice_read, .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl,