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.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, 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 48919C2BA83 for ; Fri, 14 Feb 2020 09:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12BD92086A for ; Fri, 14 Feb 2020 09:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729147AbgBNJPU (ORCPT ); Fri, 14 Feb 2020 04:15:20 -0500 Received: from stargate.chelsio.com ([12.32.117.8]:50882 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728994AbgBNJPU (ORCPT ); Fri, 14 Feb 2020 04:15:20 -0500 Received: from redhouse.blr.asicdesginers.com ([10.193.187.72]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 01E9EaoS006786; Fri, 14 Feb 2020 01:14:37 -0800 From: Rohit Maheshwari To: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org Cc: borisp@mellanox.com, aviadye@mellanox.com, john.fastabend@gmail.com, daniel@iogearbox.net, manojmalviya@chelsio.com, Rohit Maheshwari Subject: [PATCH net v2] net/tls: Fix to avoid gettig invalid tls record Date: Fri, 14 Feb 2020 14:44:33 +0530 Message-Id: <20200214091433.1868-1-rohitm@chelsio.com> X-Mailer: git-send-email 2.25.0.191.gde93cc1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Current code doesn't check if tcp sequence number is starting from (/after) 1st record's start sequnce number. It only checks if seq number is before 1st record's end sequnce number. This problem will always be a possibility in re-transmit case. If a record which belongs to a requested seq number is already deleted, tls_get_record will start looking into list and as per the check it will look if seq number is before the end seq of 1st record, which will always be true and will return 1st record always, it should in fact return NULL. As part of the fix checking if the sequence number lies in the list else return NULL. Fixes: e8f69799810c ("net/tls: Add generic NIC offload infrastructure") Signed-off-by: Rohit Maheshwari --- net/tls/tls_device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index cd91ad812291..3ee06759dc80 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -592,7 +592,7 @@ struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context, u32 seq, u64 *p_record_sn) { u64 record_sn = context->hint_record_sn; - struct tls_record_info *info; + struct tls_record_info *info, *last; info = context->retransmit_hint; if (!info || @@ -604,6 +604,15 @@ struct tls_record_info *tls_get_record(struct tls_offload_context_tx *context, struct tls_record_info, list); if (!info) return NULL; + /* we have first record, get the last record to see if this seq + * number belongs to the list. + */ + last = list_last_entry(&context->records_list, + struct tls_record_info, list); + WARN_ON(!last); + + if (!between(seq, tls_record_start_seq(info), last->end_seq)) + return NULL; record_sn = context->unacked_record_sn; } -- 2.25.0.191.gde93cc1