Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2348130rwd; Fri, 2 Jun 2023 08:13:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4s+VVlpFGWTzwjY7UquQ4GJYmWd9lAi4ri3A6jqbaNtgbGJJlLLE3Fc1zDv5a11Fz3OCdM X-Received: by 2002:a17:90a:b002:b0:258:99d1:6b84 with SMTP id x2-20020a17090ab00200b0025899d16b84mr154272pjq.41.1685718822993; Fri, 02 Jun 2023 08:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685718822; cv=none; d=google.com; s=arc-20160816; b=z27pK5+pkglxh9ycA8A2IXEL1R3xaJwVVjKHzvm4FvGz01w2v08YplqaybqUeo6VaR GeSRxPvLnrHWfxigiZKTjVaHZRRiHn8urhsWhmzVK5quv5R/9YzDccdK6cjjs4dEFF6V 3rfkMHxAPslmGJ/ChQspSp9ImJUYK208wFHexwBlluwPO7MHgYirKenKgD2tbx0VYXbx opoTIwYVLzcCqJGCQRvPodDdUWLhFsmHRQNPs+6cTRmfoLhOJuoCCcsteIRThwXdottp 3NV7xw+u1weLoyahDF944lfM0thpOIl/5pMd3Am4VEK0vQUAmZyPHPNNMTiRToyjV4xf 2fRg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GeaP7/vo94ZZDrAoROnlgLmkpbcL++cZl5U43JLGl7Y=; b=EpEQn/+owRfQBk62FvVRlXoh164DUKW+bUZ//7b9aNv+uR2oZ8nBER5dvFkiQrj3f9 XSs3SAQuCqUv4bnGOahfD40EJFppucgoK8P3urTclYZpJYQmMTYvquzSof/cu5ofhRj8 dvPHl0jkda+7zkY6VvChM853/PLZO9wJekHvNy6RO2OQex0iB5xTbaPgMKnduK0QyBgj 8+QMko/5WvejBokoe89pRRRbhzrV9hHR+Hks9+JWzR9b0xxP4P60ACqh5i0z+LKfjHub g/3tdxYQrH3okr5lBl3DKcMuqhOsUw8HZkL2jFR6/LW3/WFOYCxJ/pekeqIss3rQcMfj e5CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZILjBOuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b005348f910e64si1129836pgh.693.2023.06.02.08.13.20; Fri, 02 Jun 2023 08:13:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZILjBOuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236426AbjFBPJP (ORCPT + 99 others); Fri, 2 Jun 2023 11:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236379AbjFBPJJ (ORCPT ); Fri, 2 Jun 2023 11:09:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E1D5E52 for ; Fri, 2 Jun 2023 08:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685718502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GeaP7/vo94ZZDrAoROnlgLmkpbcL++cZl5U43JLGl7Y=; b=ZILjBOuXaBZFx/j7kah5/nSZvZSoEBPDxV/Ao9wvNxs/6wh7n7htuhXZrwIBJEo4rh5fln AFKyO+zdQs/qHXTHXN4v8M8iimeStyWHNAe2GhwgXb+PEq2dnRu97PpF8H+ZacToZ/WUzT OckRcHLv0cD45SAkfGZuX1Zd2XAoJAQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-675-r53cRdYeNt22xXrH4BTZSw-1; Fri, 02 Jun 2023 11:08:17 -0400 X-MC-Unique: r53cRdYeNt22xXrH4BTZSw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77FF23C0BE49; Fri, 2 Jun 2023 15:08:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D52340CFD46; Fri, 2 Jun 2023 15:08:14 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org, Linus Torvalds Cc: David Howells , Chuck Lever , Boris Pismenny , John Fastabend , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 03/11] tls/sw: Use zero-length sendmsg() without MSG_MORE to flush Date: Fri, 2 Jun 2023 16:07:44 +0100 Message-ID: <20230602150752.1306532-4-dhowells@redhat.com> In-Reply-To: <20230602150752.1306532-1-dhowells@redhat.com> References: <20230602150752.1306532-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow userspace to end a TLS record without supplying any data by calling send()/sendto()/sendmsg() with no data and no MSG_MORE flag. This can be used to flush a previous send/splice that had MSG_MORE or SPLICE_F_MORE set or a sendfile() that was incomplete. Without this, a zero-length send to tls-sw is just ignored. I think tls-device will do the right thing without modification. Signed-off-by: David Howells cc: Chuck Lever cc: Boris Pismenny cc: John Fastabend cc: Jakub Kicinski cc: Eric Dumazet cc: "David S. Miller" cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- net/tls/tls_sw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index cac1adc968e8..6aa6d17888f5 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -945,7 +945,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) struct tls_rec *rec; int required_size; int num_async = 0; - bool full_record; + bool full_record = false; int record_room; int num_zc = 0; int orig_size; @@ -971,6 +971,9 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) } } + if (!msg_data_left(msg) && eor) + goto just_flush; + while (msg_data_left(msg)) { if (sk->sk_err) { ret = -sk->sk_err; @@ -1082,6 +1085,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) */ tls_ctx->pending_open_record_frags = true; copied += try_to_copy; +just_flush: if (full_record || eor) { ret = bpf_exec_tx_verdict(msg_pl, sk, full_record, record_type, &copied,