Message ID | fvxufyqixohx65lcusrkkfoxs5cnlsuv7kajv6bnngcoewsodx@tarta.nabijaczleweli.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-10636-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp1986317dyi; Sat, 23 Dec 2023 21:02:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoZinJ9ZDrF1rRLWHwMYmeewIiyeHnYx3gZhO4yAeyMlwKB/pI5303YLLcIXbzjfW/OI9i X-Received: by 2002:ad4:5aa4:0:b0:67a:a739:afb3 with SMTP id u4-20020ad45aa4000000b0067aa739afb3mr7003555qvg.27.1703394153593; Sat, 23 Dec 2023 21:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703394153; cv=none; d=google.com; s=arc-20160816; b=Ft/x0jSHpuMn0nTxsxWm+ljI1VcDnzGCbfU8Ed+9t5RsvRP95EdnQXPulHYmfSzXMO 7doLpd4g4/jIo6JpLXZg0MY08N5rq0fWq/EmJXQw/yim9ik0+7wTxxVRRxXsX6wDDpUo 7M/3ZBOt9tYNYaMiUuk4Dg7lMhb9h/8QJ8/dnz5GDhso5ipMh4xTaSDfknPfe0CjQ/3T a5FQN4ACO9kmrmCpK+T9HSXRnsITGSNREVsJ78eD3nchalmxilqeO10EFmdyie8+0VkJ ztONx5u6HbrFIOOG4wtL51NVENdbM3+r18HN6UfW9s/lpl1P5j5SNrAvR4wsf860snZp VLmA== 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=Xi/YAdn2lzgT2CUfsDlRWiiX9BcTEJFe65ibiynVxcY=; fh=uyjj3EvmlSF5/RxQn9TOthRtWHD7qmOSnmg5qOg9hm0=; b=HgOyB5CIUHWwbO1atQ8Fn7xXCQzK9hItCLGdJW0AG+Bm7qBiC59sS2sI8WCuY+WH2s EMYvmUjz5qSXwtJkh+ZUHcXIhWXzth4AOPAYYuHWyjSAwUesLUx5SLZDT7H3CjgU15nm IWtoykRYbg0OQzFbD3K4PeKFw+XSSKiSsJr7W4LrS+fTUejv/tMkDOkpEOfO1uFr8KaL P2nvDd/+61iIXeGum+2uxOmqbl+CoDYPRBBHfvvABBxd9m3nimx9DV6jtLIWdjJ+zkNx jQC2GgxAtt2m4iQt4JQrkFUB44rlqT/uuoz31AX5PFeQ79sDw8jZ5dVZj1qCSAGo8+3E berg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=jHk9hGJB; spf=pass (google.com: domain of linux-kernel+bounces-10636-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10636-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j20-20020a0cf314000000b0067f65b3857bsi8379497qvl.15.2023.12.23.21.02.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 21:02:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10636-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=jHk9hGJB; spf=pass (google.com: domain of linux-kernel+bounces-10636-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10636-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5CA251C20F2A for <ouuuleilei@gmail.com>; Sun, 24 Dec 2023 05:02:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BADC823C8; Sun, 24 Dec 2023 05:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="jHk9hGJB" 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 5F4D2EC0; Sun, 24 Dec 2023 05:01:56 +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=1703394109; bh=8JqjLYgVpBXyZxmwMpSVDZbE1TJ3MF+mAG3wx6Uw9pQ=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=jHk9hGJB5O3WI8fjG4cLk3aQJtGC+pfA0r0KZO3OH1sUKU5kWEp0+fh4OVGlfMtMi K+dlbxT25iY5MS+SPpD5IRmF3TuTU5vo46Y7bjzBts7Gaa2eju425b80QL8d95XKMV oEuAasy7V3VjGivCeoLyhnKCyfHJg5L4ELNjAlhFJ23qlJyETRTimLl7C3AFplIvhQ ZThiJDSm9GP4nb092DACHKBbNcYOH2qplLF8TQK1WM0k1TkYiNgSfG8Hqj7z7edvM3 WmaxrW+zaE82xLkdKCiTbbDiYZiIPXeePzmmh2nMnt1e7a0vNaYkPsV1eIHw3+98OC YyXAX7hZgbESA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 5AE9E1421C; Sun, 24 Dec 2023 06:01:49 +0100 (CET) Date: Sun, 24 Dec 2023 06:01:49 +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, linux-kernel@vger.kernel.org, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jiri Slaby <jirislaby@kernel.org>, linux-serial@vger.kernel.org Subject: [PATCH v2 13/11] tty: splice_write: disable Message-ID: <fvxufyqixohx65lcusrkkfoxs5cnlsuv7kajv6bnngcoewsodx@tarta.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="k5qljftky3o4rq3i" Content-Disposition: inline In-Reply-To: <cover.1703126594.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20231103 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786138228407629297 X-GMAIL-MSGID: 1786138228407629297 |
Series |
Avoid unprivileged splice(file->)/(->socket) pipe exclusion
|
|
Commit Message
Ahelenia Ziemiańska
Dec. 24, 2023, 5:01 a.m. UTC
Given:
cat > ttyW.c <<^D
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdlib.h>
int main()
{
int pt = posix_openpt(O_RDWR);
grantpt(pt);
unlockpt(pt);
int cl = open(ptsname(pt), O_WRONLY);
for (;;)
splice(0, 0, cl, 0, 128 * 1024 * 1024, 0);
}
^D
cc ttyW.c -o ttyW
mkfifo fifo
truncate 32M 32M
./ttyW < fifo &
cp 32M fifo &
sleep 0.1
read -r _ < fifo
ttyW used to sleep in splice and the shell used to enter an
uninterruptible sleep in open("fifo");
now the splice returns -EINVAL and the whole program completes.
This is also symmetric with the splice_read removal.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
It hit me that I should actually probably exhaustively re-evaluate
splice_write as well since re-evaluating splice_read went so well.
fs/fuse/dev.c: .splice_write = fuse_dev_splice_write,
drivers/char/virtio_console.c: .splice_write = port_fops_splice_write,
locks, takes some pages, unlocks, writes, so OK
drivers/char/mem.c: .splice_write = splice_write_null,
drivers/char/mem.c: .splice_write = splice_write_zero,
no-op
drivers/char/random.c: .splice_write = iter_file_splice_write,
drivers/char/random.c: .splice_write = iter_file_splice_write,
AFAICT write_pool_user is okay to invoke like this?
net/socket.c: .splice_write = splice_to_socket,
already dealt with in 11/11
drivers/tty/tty_io.c: .splice_write = iter_file_splice_write,
drivers/tty/tty_io.c: .splice_write = iter_file_splice_write,
they do lock the pipe and try the write with the lock held;
we already killed splice_read so just kill splice_write for symmetry
(13/11)
fs/fuse/file.c: .splice_write = iter_file_splice_write,
same logic as splice_read applies (14/11)
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 50c2957a9c7f..d931c34ddcbf 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_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, .compat_ioctl = tty_compat_ioctl, @@ -479,7 +478,6 @@ static const struct file_operations console_fops = { .llseek = no_llseek, .read_iter = tty_read, .write_iter = redirected_tty_write, - .splice_write = iter_file_splice_write, .poll = tty_poll, .unlocked_ioctl = tty_ioctl, .compat_ioctl = tty_compat_ioctl,