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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 BBFABC3A5A8 for ; Wed, 4 Sep 2019 16:02:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8CCE023404 for ; Wed, 4 Sep 2019 16:02:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567612969; bh=WTkBljxolxbt6IIdUyLpknTO5H3oWViPH4OupxZfFBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=YnG4eXfquiEp4UaxciQmNenunNUbfMb2ysQ+XS/AzIGAjv6eZ26NzDTa7gNYwaIqV zlK3i/Ycx5Yk+tEPN4CTRTVtQ0jj1wGyWJtSSJpz4vKRMx5UL75ppMnOdbqU0GjoJv 0XyOHy6d3euiyIE8j+9cBRmgmIKA1ZZLFTFHODhA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387500AbfIDQCs (ORCPT ); Wed, 4 Sep 2019 12:02:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387491AbfIDQCs (ORCPT ); Wed, 4 Sep 2019 12:02:48 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 606EF2087E; Wed, 4 Sep 2019 16:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567612967; bh=WTkBljxolxbt6IIdUyLpknTO5H3oWViPH4OupxZfFBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=voyArnrKSzbKYk1cG3UZdvJc3HqmvZ+qt9Zxlaj/uJaPX+JobS5wGK31ZmIb+CiGt QjIsbJYWqPSjuPWA7Q/Ck2aJ6o3X+lERYsu0ccsLiFCC4oh2nFxo8LvISmcUUvh/uN EeZkmsS7qnWUnVxGm4vCiPN1uyuLbpm4/ofzJyvI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ronnie Sahlberg , Steve French , Sasha Levin , linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 18/27] cifs: set domainName when a domain-key is used in multiuser Date: Wed, 4 Sep 2019 12:02:11 -0400 Message-Id: <20190904160220.4545-18-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190904160220.4545-1-sashal@kernel.org> References: <20190904160220.4545-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Ronnie Sahlberg [ Upstream commit f2aee329a68f5a907bcff11a109dfe17c0b41aeb ] RHBZ: 1710429 When we use a domain-key to authenticate using multiuser we must also set the domainnmame for the new volume as it will be used and passed to the server in the NTLMSSP Domain-name. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/connect.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index f291ed0c155db..2a199f4b663bf 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2447,6 +2447,7 @@ static int cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) { int rc = 0; + int is_domain = 0; const char *delim, *payload; char *desc; ssize_t len; @@ -2494,6 +2495,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) rc = PTR_ERR(key); goto out_err; } + is_domain = 1; } down_read(&key->sem); @@ -2551,6 +2553,26 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses) goto out_key_put; } + /* + * If we have a domain key then we must set the domainName in the + * for the request. + */ + if (is_domain && ses->domainName) { + vol->domainname = kstrndup(ses->domainName, + strlen(ses->domainName), + GFP_KERNEL); + if (!vol->domainname) { + cifs_dbg(FYI, "Unable to allocate %zd bytes for " + "domain\n", len); + rc = -ENOMEM; + kfree(vol->username); + vol->username = NULL; + kfree(vol->password); + vol->password = NULL; + goto out_key_put; + } + } + out_key_put: up_read(&key->sem); key_put(key); -- 2.20.1