From patchwork Wed Aug 15 12:08:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Pelletier X-Patchwork-Id: 10566509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D452139A for ; Wed, 15 Aug 2018 12:09:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6367D29ECF for ; Wed, 15 Aug 2018 12:09:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53AD529ED1; Wed, 15 Aug 2018 12:09:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDAC229ECC for ; Wed, 15 Aug 2018 12:09:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729223AbeHOPA6 (ORCPT ); Wed, 15 Aug 2018 11:00:58 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36025 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728810AbeHOPA5 (ORCPT ); Wed, 15 Aug 2018 11:00:57 -0400 Received: by mail-pf1-f194.google.com with SMTP id b11-v6so447945pfo.3; Wed, 15 Aug 2018 05:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/Ra4PqJo59b24qEhDTuPhyA2NyfAEzRF3QwbHSU8gsE=; b=t7V4fR4AAuBBHhhZV8b5O5q2ovUgMLN3q9wYSaH01fHalvW3G3zXCb9qkE8ZsPsT4G TUfanyFTOJ5/wWnrdtjD1Gb4EByABjXDy4/QGNiZe+A2mcQMTwXTugYryjlwavT0l19q ZxBcwOTTOD8O4qzka6ON9WfRQV+4w+n/FLNse5TQQGWho9pfuSGfMDP1asdElydekYC8 hIpiSHeQLNfYt0vxtLBSncZ2z8FK0Kq2NUioHY/h7ctUyLKV+Z34mOIrVf5X6GK5YRtL iIs6vtjqufuNStbSBgrzFgQ7C0aOIr9nyOTZYrWR1jfOYk2dQblboTLwGRBtcaHmpf+m V0hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/Ra4PqJo59b24qEhDTuPhyA2NyfAEzRF3QwbHSU8gsE=; b=IKRdxjt1+uEdYVeUiutR/phElK3Uz4NCmR9N4GuEkHnxkw6/8OPmHxHNOwF1Yc81VO c0cDR1GugT16c6cowiyJOjw+y/BHpEFRdOePsnuk+1eXc5B5FLweBXbEK/tUq6jTmuie v8BlaiHAL599n8aGM1yJ3Nrgluc4MogKNhcckdxaAzedvfDaxXR1NAvZfviqujuTzfYL +D/Af84TIqAYxllag8olboe5oKiVKrm6n6VZmN1+2ECVVKL7BUA+USlBm281dyl3GaII x11JDb2UZPs1cu2AzpqaUD/P9AjOuYWAjvuECHNU2cunWEp6OAIHYJUfgjTHp736Gt2T uL3w== X-Gm-Message-State: AOUpUlHsOU9YSBmxLgf3XzRW5qRo2SQV+Khgb9dNPbTElEtHmE0aOEUE gZ4sRnCuDmuPrTNySO+zdJ8= X-Google-Smtp-Source: AA+uWPwr8/VjJvSPQhKiwbF3lQDgNBPrdeIF1VMDyZpCwoBbewwB5v6yGA3vXhuJhLAENVeaOdBLtg== X-Received: by 2002:a63:e647:: with SMTP id p7-v6mr24634577pgj.218.1534334942486; Wed, 15 Aug 2018 05:09:02 -0700 (PDT) Received: from x2.lan ([2400:406d:175b:7500::7d4b]) by smtp.gmail.com with ESMTPSA id y69-v6sm51431664pfd.36.2018.08.15.05.09.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Aug 2018 05:09:01 -0700 (PDT) From: Vincent Pelletier To: Mike Christie Cc: Bart Van Assche , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, nab@linux-iscsi.org Subject: iscsi target: Let initiator decide whether it wants to authenticate target Date: Wed, 15 Aug 2018 12:08:53 +0000 Message-Id: <97479a0ccf17d8ad7a8ba7a0f7e8190da6ddc72e.1534334933.git.plr.vincent@gmail.com> X-Mailer: git-send-email 2.18.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not fail authentication after target is happy with initiator's credentials, when target is configured to authenticate itself to an initiator but current initiator did not provide required values. Also, downgrade "Could not find CHAP_I." to a debug level message, as it will happen normally in such case. Signed-off-by: Vincent Pelletier --- drivers/target/iscsi/iscsi_target_auth.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 4e680d753941..8598eb00830a 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c @@ -290,18 +290,21 @@ static int chap_server_compute_md5( pr_debug("[server] MD5 Digests match, CHAP connection" " successful.\n\n"); /* - * One way authentication has succeeded, return now if mutual - * authentication is not enabled. + * One way authentication has succeeded + */ + auth_ret = 0; + *nr_out_len = 0; + /* + * Return now if mutual authentication is not enabled. */ if (!auth->authenticate_target) { - auth_ret = 0; goto out; } /* * Get CHAP_I. */ if (extract_param(nr_in_ptr, "CHAP_I", 10, identifier, &type) < 0) { - pr_err("Could not find CHAP_I.\n"); + pr_debug("Could not find CHAP_I.\n"); goto out; } @@ -407,7 +410,7 @@ static int chap_server_compute_md5( response); *nr_out_len += 1; pr_debug("[server] Sending CHAP_R=0x%s\n", response); - auth_ret = 0; + chap->chap_state = CHAP_STAGE_SERVER_NR; out: kzfree(desc); if (tfm) @@ -462,10 +465,6 @@ u32 chap_main_loop( chap_close(conn); return 2; } - if (auth->authenticate_target) - chap->chap_state = CHAP_STAGE_SERVER_NR; - else - *out_len = 0; chap_close(conn); return 1; }