Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3822137ybi; Mon, 29 Jul 2019 13:17:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxAtFGDzLiSQGhhxJMyTzreXRNqSDUbkXxwaLsG02zj8zOwv9Bp2zf7Q3hpJPtDwcwnK9Y X-Received: by 2002:a17:902:2ac8:: with SMTP id j66mr106734692plb.273.1564431476351; Mon, 29 Jul 2019 13:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431476; cv=none; d=google.com; s=arc-20160816; b=iXL7ZS7eRm7T5bZJN2+5tLYY8yo68rU4bNAOlIYDJmVLbN/jlCG32xreyPvsbS6NP8 2vaMFU5iVvmRItEFXchHekHf484ZKqmolYXdT4EznVRFVR43uJPhw6Y726gYMDyQn8aF U9eyQ8rdYjmzrtdBw4koiOGKHAklE9TyV/eramdGZpvYkl787arZcLKUHn696K8ZXO/l +KPXt32oP5ISjxV6x/t9/WxpuJ0xIP9tvQo9jrK9IPzhpe9yeS8a0GxTPcn5hyH7pLt4 nXSK9dH1nKFaICzWwgavkfP/YfiSUVytBi7x0G+SRBuH53SNN+gOp04ETN2fxcbNin5I t7Xw== 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:dkim-signature; bh=HfVoeZNElIkBT/+LF2KvkSa32vkjxhn2PKnOJO5ZbxU=; b=lyqIwaBP3ahCSP0O4Iz9sOEsnsTTQMtZU6CGslaSYSDWYFMDjkwZ03q8lltcEXiO/B KZ4xppDsOjKSWLm/QwT08fw9n7r6WuWxscqa2hYIDKG6TcR9szLFyXS4XqZ1jTQ5UJiT zdOTc+0EFqZ7Pwv5j/Y3OGHuvmoKLNPja0HO/+WLGD6zuQ3MGhBIQSVJYBGIoE3qNh7z vFzIfje1awnnUt1agMPiQt5sMVndeovzxo8Ta1R5qa1cV0EwEHNUG7RIFHp3I7fM3KHq KrN0gjA0m8JYZudLa8v12OpS4vzT3p0xsLnghqHO3t0MixLZMTXcaeLu0AlASbT8L2EK FWAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZlvA6UC5; 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 7si26897189pga.439.2019.07.29.13.17.40; Mon, 29 Jul 2019 13:17:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZlvA6UC5; 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 S2387946AbfG2TYS (ORCPT + 99 others); Mon, 29 Jul 2019 15:24:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:36458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729460AbfG2TYO (ORCPT ); Mon, 29 Jul 2019 15:24:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF69F21655; Mon, 29 Jul 2019 19:24:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428253; bh=0ec6NeFqmFZxWWpQ73b8nQMKU7+faETgn/Bt1DHjJ4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZlvA6UC5TXsh75mXogLCSNXv0WaVKXwp3r2+2ns4RqKw8p8HSqYQg4z8APHLpUGTd OS4FIorlTJfq0DdKfqNhudXLuX6++57vHXO/LgRSO7nRjeXNJLlw39TqXg7wsj0gHi a0MYvwDq5CMLOXdSjz8HUUzhyCB/qxfwEhC/ByQM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maurizio Lombardi , Chris Leech , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 004/293] scsi: iscsi: set auth_protocol back to NULL if CHAP_A value is not supported Date: Mon, 29 Jul 2019 21:18:15 +0200 Message-Id: <20190729190820.686197057@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 5dd6c49339126c2c8df2179041373222362d6e49 ] If the CHAP_A value is not supported, the chap_server_open() function should free the auth_protocol pointer and set it to NULL, or we will leave a dangling pointer around. [ 66.010905] Unsupported CHAP_A value [ 66.011660] Security negotiation failed. [ 66.012443] iSCSI Login negotiation failed. [ 68.413924] general protection fault: 0000 [#1] SMP PTI [ 68.414962] CPU: 0 PID: 1562 Comm: targetcli Kdump: loaded Not tainted 4.18.0-80.el8.x86_64 #1 [ 68.416589] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 [ 68.417677] RIP: 0010:__kmalloc_track_caller+0xc2/0x210 Signed-off-by: Maurizio Lombardi Reviewed-by: Chris Leech Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/target/iscsi/iscsi_target_auth.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 4e680d753941..e2fa3a3bc81d 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c @@ -89,6 +89,12 @@ static int chap_check_algorithm(const char *a_str) return CHAP_DIGEST_UNKNOWN; } +static void chap_close(struct iscsi_conn *conn) +{ + kfree(conn->auth_protocol); + conn->auth_protocol = NULL; +} + static struct iscsi_chap *chap_server_open( struct iscsi_conn *conn, struct iscsi_node_auth *auth, @@ -126,7 +132,7 @@ static struct iscsi_chap *chap_server_open( case CHAP_DIGEST_UNKNOWN: default: pr_err("Unsupported CHAP_A value\n"); - kfree(conn->auth_protocol); + chap_close(conn); return NULL; } @@ -141,19 +147,13 @@ static struct iscsi_chap *chap_server_open( * Generate Challenge. */ if (chap_gen_challenge(conn, 1, aic_str, aic_len) < 0) { - kfree(conn->auth_protocol); + chap_close(conn); return NULL; } return chap; } -static void chap_close(struct iscsi_conn *conn) -{ - kfree(conn->auth_protocol); - conn->auth_protocol = NULL; -} - static int chap_server_compute_md5( struct iscsi_conn *conn, struct iscsi_node_auth *auth, -- 2.20.1