From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED2DAC43381 for ; Wed, 27 Feb 2019 15:38:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B45CE20684 for ; Wed, 27 Feb 2019 15:38:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730136AbfB0PiQ (ORCPT ); Wed, 27 Feb 2019 10:38:16 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:49238 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730096AbfB0PiO (ORCPT ); Wed, 27 Feb 2019 10:38:14 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from borisp@mellanox.com) with ESMTPS (AES256-SHA encrypted); 27 Feb 2019 17:38:08 +0200 Received: from gen-l-vrt-098.mtl.labs.mlnx (gen-l-vrt-098.mtl.labs.mlnx [10.137.170.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1RFc7rc032667; Wed, 27 Feb 2019 17:38:08 +0200 From: Boris Pismenny To: aviadye@mellanox.com, davejwatson@fb.com, john.fastabend@gmail.com, daniel@iogearbox.net, vakul.garg@nxp.com, netdev@vger.kernel.org Cc: eranbe@mellanox.com, borisp@mellanox.com Subject: [PATCH v2 net 4/4] tls: Fix tls_device receive Date: Wed, 27 Feb 2019 17:38:06 +0200 Message-Id: <20190227153806.17080-5-borisp@mellanox.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20190227153806.17080-1-borisp@mellanox.com> References: <20190227153806.17080-1-borisp@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently, the receive function fails to handle records already decrypted by the device due to the commit mentioned below. This commit advances the TLS record sequence number and prepares the context to handle the next record. Fixes: fedf201e1296 ("net: tls: Refactor control message handling on recv") Signed-off-by: Boris Pismenny Reviewed-by: Eran Ben Elisha --- net/tls/tls_sw.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 68cd026fa57c..425351ac2a9b 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1467,23 +1467,26 @@ static int decrypt_skb_update(struct sock *sk, struct sk_buff *skb, struct strp_msg *rxm = strp_msg(skb); int err = 0; + if (!ctx->decrypted) { #ifdef CONFIG_TLS_DEVICE - err = tls_device_decrypted(sk, skb); - if (err < 0) - return err; + err = tls_device_decrypted(sk, skb); + if (err < 0) + return err; #endif - if (!ctx->decrypted) { - err = decrypt_internal(sk, skb, dest, NULL, chunk, zc, async); - if (err < 0) { - if (err == -EINPROGRESS) - tls_advance_record_sn(sk, &tls_ctx->rx, - version); + /* Still not decrypted after tls_device */ + if (!ctx->decrypted) { + err = decrypt_internal(sk, skb, dest, NULL, chunk, zc, + async); + if (err < 0) { + if (err == -EINPROGRESS) + tls_advance_record_sn(sk, &tls_ctx->rx, + version); - return err; + return err; + } } rxm->full_len -= padding_length(ctx, tls_ctx, skb); - rxm->offset += prot->prepend_size; rxm->full_len -= prot->overhead_size; tls_advance_record_sn(sk, &tls_ctx->rx, version); -- 2.12.2