Received: by 10.213.65.68 with SMTP id h4csp249518imn; Fri, 23 Mar 2018 03:55:48 -0700 (PDT) X-Google-Smtp-Source: AG47ELutR3E5Nvql5zmz/z/LZgM0+T26UigGshRWAPMkBEeHp+sAcS/pPz/rf1dLiqvlLYC7oxJo X-Received: by 10.99.98.134 with SMTP id w128mr20566342pgb.217.1521802548159; Fri, 23 Mar 2018 03:55:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802548; cv=none; d=google.com; s=arc-20160816; b=EpF5pQw4zI21kO38ktafYsNHmBb+lZRwy3jP6/StNdo2YRrHXUDmW0zhC08JgEQ2rU WaNm9uOJXT8aW93IpY3fdnUPQPHCXgQfHZEYBKCMaDd5ldLDEHuLa45gsr9Xc+6YcBZM O0FCH8m0nrfm6FLZt3cewwpcFokfPLYSX3DTNhfNd1xHWC5zPwpFIzhdOJR0SoCbSoGC xOrVgGUP1nVH5zM8L6Sx/3wrtAagx9pBDQ4vtV9XQP6La2i2o8SR3LIGyHlAcukI+UWD xhruHwnIkTApIz1Dot9Jb//Ia5V+tDKbDLKM38EufdMcGM8Ufpz6k63LSdAiwt7C7OzT I5LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LWFvTOYBTU89bN+nZh3CEDhlEg+4XaZmYgQXDEPaGgk=; b=cczfDBXpR1skzpD5SWi7muNJ5LavTjvGu0cHNHrfwxf4mMhPs25IN/PgdseyhD34YL 63aARsKbOoENlibnJtOeVoUNLN5c0xgEnqInFSI8+MzZdZ59wu7TUVAyvCfEzhRtNB/e tj8hRoDRdezzn4koFKFRZCm74asamr6rQhTbEbPeikmVX1oazcoP380vFDsWjvOJNtGU uxpo0/2uYF14Z/BsjkPmc5QL5vWA+0OLf/ivZxi1up79DXqyBeCCI7pYgoWT88VemWb6 h3pl+eCg8OdXirfdZ5TYNEhm7qNqzkxLcUis9MjWUcx6blvjZUOsva7r8YrXYLVoagSs hxag== 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 o197si4190059pfg.380.2018.03.23.03.55.33; Fri, 23 Mar 2018 03:55:48 -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 S1755870AbeCWKN1 (ORCPT + 99 others); Fri, 23 Mar 2018 06:13:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44796 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755860AbeCWKNZ (ORCPT ); Fri, 23 Mar 2018 06:13:25 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8751011BF; Fri, 23 Mar 2018 10:13:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , "Srivatsa S. Bhat" , Steve French Subject: [PATCH 4.4 04/97] CIFS: Enable encryption during session setup phase Date: Fri, 23 Mar 2018 10:53:51 +0100 Message-Id: <20180323094157.798345134@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pavel Shilovsky commit cabfb3680f78981d26c078a26e5c748531257ebb upstream. In order to allow encryption on SMB connection we need to exchange a session key and generate encryption and decryption keys. Signed-off-by: Pavel Shilovsky Signed-off-by: Srivatsa S. Bhat Cc: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/sess.c | 22 ++++++++++------------ fs/cifs/smb2pdu.c | 8 +------- 2 files changed, 11 insertions(+), 19 deletions(-) --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -344,13 +344,12 @@ void build_ntlmssp_negotiate_blob(unsign /* BB is NTLMV2 session security format easier to use here? */ flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | - NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; - if (ses->server->sign) { + NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | + NTLMSSP_NEGOTIATE_SEAL; + if (ses->server->sign) flags |= NTLMSSP_NEGOTIATE_SIGN; - if (!ses->server->session_estab || - ses->ntlmssp->sesskey_per_smbsess) - flags |= NTLMSSP_NEGOTIATE_KEY_XCH; - } + if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) + flags |= NTLMSSP_NEGOTIATE_KEY_XCH; sec_blob->NegotiateFlags = cpu_to_le32(flags); @@ -407,13 +406,12 @@ int build_ntlmssp_auth_blob(unsigned cha flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | - NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC; - if (ses->server->sign) { + NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | + NTLMSSP_NEGOTIATE_SEAL; + if (ses->server->sign) flags |= NTLMSSP_NEGOTIATE_SIGN; - if (!ses->server->session_estab || - ses->ntlmssp->sesskey_per_smbsess) - flags |= NTLMSSP_NEGOTIATE_KEY_XCH; - } + if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) + flags |= NTLMSSP_NEGOTIATE_KEY_XCH; tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); sec_blob->NegotiateFlags = cpu_to_le32(flags); --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -832,10 +832,8 @@ ssetup_exit: if (!rc) { mutex_lock(&server->srv_mutex); - if (server->sign && server->ops->generate_signingkey) { + if (server->ops->generate_signingkey) { rc = server->ops->generate_signingkey(ses); - kfree(ses->auth_key.response); - ses->auth_key.response = NULL; if (rc) { cifs_dbg(FYI, "SMB3 session key generation failed\n"); @@ -857,10 +855,6 @@ ssetup_exit: } keygen_exit: - if (!server->sign) { - kfree(ses->auth_key.response); - ses->auth_key.response = NULL; - } if (spnego_key) { key_invalidate(spnego_key); key_put(spnego_key);