Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1411797yba; Tue, 2 Apr 2019 08:23:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxYsOqAb9iZcZMnQn1SpU4GeLV/csb9UAVAWimnA9sRjnahtcL9WNxNVjy/j3vXgOTwFtL X-Received: by 2002:a63:1203:: with SMTP id h3mr34547746pgl.164.1554218603847; Tue, 02 Apr 2019 08:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554218603; cv=none; d=google.com; s=arc-20160816; b=JblYq0Id/rdeCo+00vPZVDUHVjPtCNHgQDzckBeiCOdGBCcuNoZiyZM/y+cHgSUc1o RUnseSvRXvhO9kpQSb7lSpNH8GDDgarb+DSV4Px5xGXeQ19cd2SYE4KU721ZuKYnxKFK 4C7zdce1YkRd92xtVsAHFG2ep/9hDvCIeUX50QXN4ZTc/UD18JyvX2pshF4MX93gGFfX z2krfyW6qyPlk4M16Jx1sSkCHZRQJoTBt0v0yTY+sK07z6fpTUz+sxwxnbxDYMWneEld Vjr8icRaa8GWRVP4/XGAD+95FMpfJoGwts74iSi5Wl9d2v40JiwMZhXPDqvXdsUf1/nV DGPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=ssqs0VxVtudXnGg0Dmr1xPQTj/hq3I9WhsXdRF0P2tA=; b=JmQ8uMx3IgTEiRlEhZ7aTu/DhNkCTE5nrcb508gUU3YXbzFaX67d0I/FDNU7q+GiKL EFDjidGqvw6bfsdFC7lt75/5royHArsWuYoaGKUXPazT8XOH1UAJczinUGxEf3Rb/n4s Ujltj8QPugyx7S7Kh0NLetG+GkpMtB5ZPoObEjgfbmDKseSIzARYdbAHTkl3r+snwCQT jXeqigDVAucFHQp2e/mPNdkfJeSUjtOLSBhltuz5kP8L7KwEH3tBE6qesssLONooiizv 87DGDmRJ5WkVo/fNc6fvzE0+Zb3sJtGDa6uKO8xOL0S0ppMprfV8fjmpHFh7aAoA9W7+ 0WVQ== 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 b14si3784627pls.175.2019.04.02.08.23.07; Tue, 02 Apr 2019 08:23:23 -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 S1731683AbfDBNkf (ORCPT + 99 others); Tue, 2 Apr 2019 09:40:35 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43518 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731494AbfDBNkJ (ORCPT ); Tue, 2 Apr 2019 09:40:09 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJe3-0002no-Br; Tue, 02 Apr 2019 14:40:07 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdy-0004yR-8h; Tue, 02 Apr 2019 14:40:02 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Pavel Shilovsky" Date: Tue, 02 Apr 2019 14:38:28 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 99/99] CIFS: Enable encryption during session setup phase In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 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 [bwh: Backported to 3.16: - SMB2_sess_establish_session() has not been split out from SMB2_sess_setup() and there is additional cleanup to do on error, so keep the 'goto keygen_exit' - Adjust context] Signed-off-by: Ben Hutchings --- fs/cifs/sess.c | 22 ++++++++++------------ fs/cifs/smb2pdu.c | 12 ++---------- 2 files changed, 12 insertions(+), 22 deletions(-) --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c @@ -343,13 +343,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); @@ -412,13 +411,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 @@ -764,10 +764,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"); @@ -789,10 +787,6 @@ ssetup_exit: } keygen_exit: - if (!server->sign) { - kfree(ses->auth_key.response); - ses->auth_key.response = NULL; - } kfree(ses->ntlmssp); return rc;