Message ID | f14a9bee9658d8aced8cd0a951bbc962c6a7bd5b.1703126594.git.nabijaczleweli@nabijaczleweli.xyz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-7779-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp156565dyi; Wed, 20 Dec 2023 19:11:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHblMhn+fSYwVBK9rg0co03ZvlZBS5MWeO6tFV2DNieI+kVeqMzJmvLPHe96LWHjNI6R5a+ X-Received: by 2002:a05:6808:2125:b0:3b8:b063:6b96 with SMTP id r37-20020a056808212500b003b8b0636b96mr26979535oiw.69.1703128290767; Wed, 20 Dec 2023 19:11:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703128290; cv=none; d=google.com; s=arc-20160816; b=nKIF4PxHoCbaUnqJ/MY8D7NIBQyIUe6cZKOdB0ywz9+PVT9uBQ9pejWVIjeXHZS9FV h0a10YjAFTL6TOs17hnXKgKJEZuy8WKXPjgn/9NpxlkhepTBPvUuxkDdSxwaXCc8rhzx VTUbYvigIxqIhOm/THg2ZlE5WkTMLQJNpJOd8n6/tF/hxCqFB5r+dKOchjlE2tYWZ9sR 9p9K+dRW1kDigrWgFfwiFRaa4cMWLQOUtf0z1xHykOH2O5rfqk2Q4a+P2FP+xlGLV6GQ 5xEtdmsiMsXkqrK484CZeRuUvtxykNeI8hOmgmhfSUGn1EaeIC+m7FC7U8mOjPeifrQz 30EA== 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=0m2ADhDOtePgSIilDdK/IfXCs07I4ZiIrY7XG62cMTA=; fh=QADJdDQtZos0cb/hCCkLf8y/QMnWIW8ELH8QSW039SU=; b=0Weo046XozhhZJb60gRR2/69AEo0nyoWqFLSpRDSGzO52meyrB3lVD48kMNLsx+4r7 ihsTWfRrW9lMpaDTc2M3EMOggYW/+eu2ReoCsj6ctqgEbC5WaqZZKFdf2wht89wI0xdm wGkPm9YjL038A2js65n7sN7jIfx1tqpfL2ZhoAVMF/iu/UWINLRK4/B+yklQsnDRXwBA qDf4debSPVZhfW9E7AVxZEuOCz6BQFQm/j8oR1NleKfmNIoNAUuFJEJki2056xquitRG R36pH9fuMYtrS1xt1Lanw1WgTmidRmqEq6l62UYaamA5aKFL3V+d7nwIhS8FxoD+qrcP lslQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=hrXydvLU; spf=pass (google.com: domain of linux-kernel+bounces-7779-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7779-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id hg11-20020a17090b300b00b0028bf06a812asi294699pjb.45.2023.12.20.19.11.30 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 19:11:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7779-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=hrXydvLU; spf=pass (google.com: domain of linux-kernel+bounces-7779-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7779-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5D427287F4F for <ouuuleilei@gmail.com>; Thu, 21 Dec 2023 03:11:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37961154B7; Thu, 21 Dec 2023 03:09:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nabijaczleweli.xyz header.i=@nabijaczleweli.xyz header.b="hrXydvLU" 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 D1A5011C8F; Thu, 21 Dec 2023 03:09:07 +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=1703128146; bh=qAmWyUoU8YkxZBfMhksVxnOF3K/+1yNv2stDp0bUYaU=; h=Date:From:Cc:Subject:References:In-Reply-To:From; b=hrXydvLUYIdw/FBFstYDD0jtvpmYHx7nxxp9isDfxsq73gon5fgyFx5bfxnW3/Avt TRS26FntbCF27nt03x2dC7y8lqLSb8Wb9/KZ28RgGNo2I2EespxvKECab83zycPPAO SRSk37HAGLPApY/QUvIqy67G4DmZvN0nFAEeea0qmhYUYPtIJ3s6Ep7PFj0Kz0x/ul SQ3Rx+4PZnCnNpbibiFfc/jBNw9C8+Lz8aDRL8fcTbFUwr45cnLqEBEzfEolTEsuwm frH/s4dgzX1JbwALRgvlMANY91NuJV4w6tAP8xYVCtRzlfeYKZkCAEa85Hl/MMO4kl P60Bb3mQsTUcg== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 10E8D13DB2; Thu, 21 Dec 2023 04:09:06 +0100 (CET) Date: Thu, 21 Dec 2023 04:09:05 +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, Boris Pismenny <borisp@nvidia.com>, John Fastabend <john.fastabend@gmail.com>, Jakub Kicinski <kuba@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 06/11] tls/sw: tls_sw_splice_read: always request non-blocking I/O Message-ID: <f14a9bee9658d8aced8cd0a951bbc962c6a7bd5b.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="ol5qyjq3wpi4gz2a" 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: 1785859450535438525 X-GMAIL-MSGID: 1785859450535438525 |
Series |
Avoid unprivileged splice(file->)/(->socket) pipe exclusion
|
|
Commit Message
Ahelenia Ziemiańska
Dec. 21, 2023, 3:09 a.m. UTC
Otherwise we risk sleeping with the pipe locked for indeterminate
lengths of time ‒ given
cat > tls_sw.c <<^D
#define _GNU_SOURCE
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <linux/tls.h>
int main()
{
int s = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr = {
.sin_family = AF_INET,
.sin_addr = { htonl(INADDR_LOOPBACK) },
.sin_port = htons(getpid() % (0xFFFF - 1000) + 1000)
};
bind(s, &addr, sizeof(addr));
listen(s, 1);
if (!fork()) {
connect(socket(AF_INET, SOCK_STREAM, 0), &addr, sizeof(addr));
sleep(100);
return 0;
}
s = accept(s, NULL, NULL);
setsockopt(s, SOL_TCP, TCP_ULP, "tls", sizeof("tls"));
setsockopt(s, SOL_TLS, TLS_RX,
&(struct tls12_crypto_info_aes_gcm_128){
.info.version = TLS_1_2_VERSION,
.info.cipher_type = TLS_CIPHER_AES_GCM_128 },
sizeof(struct tls12_crypto_info_aes_gcm_128));
for (;;)
splice(s, 0, 1, 0, 128 * 1024 * 1024, 0);
}
^D
cc tls_sw.c -o tls_sw
mkfifo fifo
./tls_sw > fifo &
read -r _ < fifo &
sleep 0.1
echo zupa > fifo
tls_sw used to sleep in splice and the shell used to enter an
uninterruptible sleep in open("fifo");
now the splice returns -EAGAIN and the whole program completes.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
net/tls/tls_sw.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index e37b4d2e2acd..3f474deed94d 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -2157,7 +2157,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, int chunk; int err; - err = tls_rx_reader_lock(sk, ctx, flags & SPLICE_F_NONBLOCK); + err = tls_rx_reader_lock(sk, ctx, true); if (err < 0) return err; @@ -2166,8 +2166,7 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos, } else { struct tls_decrypt_arg darg; - err = tls_rx_rec_wait(sk, NULL, flags & SPLICE_F_NONBLOCK, - true); + err = tls_rx_rec_wait(sk, NULL, true, true); if (err <= 0) goto splice_read_end;