Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2499994imm; Mon, 24 Sep 2018 05:31:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ZZfZsp4h2ZSlhLnpV51M6DiRiNEu+aZxFRc6yHlzKbosYWbtbs/08MUOBJU2C3Z9kznKD X-Received: by 2002:a17:902:830b:: with SMTP id bd11-v6mr8144530plb.249.1537792303533; Mon, 24 Sep 2018 05:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792303; cv=none; d=google.com; s=arc-20160816; b=HuB8KZITrL3iRz5avzI60RtKu09siSZrVkD9kREIy4T/nOpwendXNSjpjpsYhK53JZ MQCvV//luvS9OSQJ9wAhgfqokf1Ykk0A5xVzHfylfh0ja1qpwnAHc5zsPJ3QJ+E9W7aK D5uJXN+aCmMjbz3nuVANBHDjLq6BXCq6GUQUb68yZMOW0IDJ8HNT0YqUR/HUfAxg7xKD aatcWHcJZWTpM3h9I3rl/3zHtp+77AfQOVeO6xF5Sdlwnk+7Nls5BY7EmgsC6FR1G73m VAhlrTk8TpqwRmIAL1ijuIYVIPSM2LyyYgUU7V7Cbwtb+wj60nFqa0f84TlurATGmaoY 4Mnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=H4cJhPV0yCB8jXldinWcQE+FOWod9xS/kqm8YB8asaI=; b=bJmeN/TcK9PD/T2f4xOZl5L0Y+vhaynfdM+4kKyNPSBQnzRQ/VKOQT/MwfTeWeM+bw ZtKV4RE6KgeLvJc9OUnoG1z+NUdCn/JMDjoOb5QOqbgJggTz4m3AU3BLl5EYJO4zd5cN bngYCyodlMuDgT5NCzcO8cWGI9xBl0gyzuzju3AboiEAmWaPZXKGxTjSQhbq/djqK/zP zssTKIeyeADL+Sp8tKG/sVF3IkNS/cCICzDRqdTeSTIFao1rhF9lLvCrCHsBWKhtoSxb 4HX4bJaLg8XCN0pmPAyATWW76QkHZKrP0NRDBg6Hy7FoHlT9NJOj3nMxwBEsdZW+s7fh Pryg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6-v6si32488337pls.150.2018.09.24.05.31.28; Mon, 24 Sep 2018 05:31:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387675AbeIXSbC (ORCPT + 99 others); Mon, 24 Sep 2018 14:31:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57558 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732800AbeIXSbC (ORCPT ); Mon, 24 Sep 2018 14:31:02 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A54B91018; Mon, 24 Sep 2018 12:29:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vakul Garg , "David S. Miller" Subject: [PATCH 4.18 007/235] net/tls: Set count of SG entries if sk_alloc_sg returns -ENOSPC Date: Mon, 24 Sep 2018 13:49:53 +0200 Message-Id: <20180924113105.027790477@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vakul Garg [ Upstream commit 52ea992cfac357b73180d5c051dca43bc8d20c2a ] tls_sw_sendmsg() allocates plaintext and encrypted SG entries using function sk_alloc_sg(). In case the number of SG entries hit MAX_SKB_FRAGS, sk_alloc_sg() returns -ENOSPC and sets the variable for current SG index to '0'. This leads to calling of function tls_push_record() with 'sg_encrypted_num_elem = 0' and later causes kernel crash. To fix this, set the number of SG elements to the number of elements in plaintext/encrypted SG arrays in case sk_alloc_sg() returns -ENOSPC. Fixes: 3c4d7559159b ("tls: kernel TLS support") Signed-off-by: Vakul Garg Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/tls/tls_sw.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -149,6 +149,9 @@ static int alloc_encrypted_sg(struct soc &ctx->sg_encrypted_num_elem, &ctx->sg_encrypted_size, 0); + if (rc == -ENOSPC) + ctx->sg_encrypted_num_elem = ARRAY_SIZE(ctx->sg_encrypted_data); + return rc; } @@ -162,6 +165,9 @@ static int alloc_plaintext_sg(struct soc &ctx->sg_plaintext_num_elem, &ctx->sg_plaintext_size, tls_ctx->pending_open_record_frags); + if (rc == -ENOSPC) + ctx->sg_plaintext_num_elem = ARRAY_SIZE(ctx->sg_plaintext_data); + return rc; }