Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3307860imu; Sun, 11 Nov 2018 12:04:14 -0800 (PST) X-Google-Smtp-Source: AJdET5c89w7dcqIWFM3AEG6UNMftABCniWEq35evldOBusex3dGP9Vt6Ozo84GdKVuiaV2rW9Kfq X-Received: by 2002:a62:1954:: with SMTP id 81-v6mr17370388pfz.237.1541966654271; Sun, 11 Nov 2018 12:04:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966654; cv=none; d=google.com; s=arc-20160816; b=zZDP7y+r1ODTMT/MBtN1JjCoTLpEqno0mvgJYGLBk9xNuAIYBCG7FcUqLhWtETuBfo w/f8Fh0+IBAHArXh2TbXncBcsa79B8rZBfMJXNSw6bo6tO4vLiCCy0jbXyHoIUePx7Fz 8/t95GcnarnAJhypK1lxIpBbdYP1+OOYS2990uK+zam8oaaONhUDJxdv3/YFO2a3xVJx vRjoM9fAL7AD41g1auyaslYQ57mSReZgVtHrCh2hRvbOsLNg509sFZoDjKdFU1Ah3UDZ c1iEkNkFI+TDiF2Zzlbdl61HCxI6jxR2TK0iwXMXyFUUVum1tUo6itf45wrXSstQvLSK T+sQ== 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=HnICdwmXvuSM4ed8VNBh5MY+2Uo0jQBT9ld6vo+ETeM=; b=GL9DPZvnkkbbiQlnzBxHfP4Kw4GVXYpVZsYX4DGxcUjFqMbF3i0o8hjEsQd5u/ljCW Q1gosVjBZh5qjCvrZeyMEZAXYisnEpFOiUyh6fWBMy22giXUrmU/YnOFz3XhudKUaVCY dkeSHxZAxkdoWP18nEBfntuhszhyxZV3+5+LliiyWty7S4kx/nDLJfgWAxBmMLiNR93G 7NWeTusA7KKsaNet/S5gBblumI8ANQZv0JrHJnOGOGQFZjGSeOkXq89fr40HAJ8ME8Cw CHyud3uF9obLST0U0XurSa5doBMXHaJYJ1QsR0rNeOt+C/+iFuRyIG1Ra7HKMAkd0wjT KLeA== 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 w65-v6si17158159pfd.55.2018.11.11.12.03.59; Sun, 11 Nov 2018 12:04:14 -0800 (PST) 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 S1730975AbeKLFwR (ORCPT + 99 others); Mon, 12 Nov 2018 00:52:17 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51172 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730716AbeKLFsb (ORCPT ); Mon, 12 Nov 2018 00:48:31 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvss-0000oU-4F; Sun, 11 Nov 2018 19:59:02 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsV-0001gX-KZ; Sun, 11 Nov 2018 19:58:39 +0000 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, "Steve French" , "Ronnie Sahlberg" , "Pavel Shilovsky" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 233/366] cifs: store the leaseKey in the fid on SMB2_open In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 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.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Ronnie Sahlberg commit 96164ab2d880c9539989bea68d4790f6fd619b1f upstream. In SMB2_open(), if we got a lease we need to store this in the fid structure or else we will never be able to map a lease break back to which file/fid it applies to. Signed-off-by: Ronnie Sahlberg Reviewed-by: Pavel Shilovsky Signed-off-by: Steve French [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- fs/cifs/cifsglob.h | 2 +- fs/cifs/smb2ops.c | 7 +++++-- fs/cifs/smb2pdu.c | 8 +++++--- 3 files changed, 11 insertions(+), 6 deletions(-) --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -383,7 +383,7 @@ struct smb_version_operations { /* create lease context buffer for CREATE request */ char * (*create_lease_buf)(u8 *, u8); /* parse lease context buffer and return oplock/epoch info */ - __u8 (*parse_lease_buf)(void *, unsigned int *); + __u8 (*parse_lease_buf)(void *buf, unsigned int *epoch, char *lkey); int (*clone_range)(const unsigned int, struct cifsFileInfo *src_file, struct cifsFileInfo *target_file, u64 src_off, u64 len, u64 dest_off); --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1118,7 +1118,7 @@ smb3_create_lease_buf(u8 *lease_key, u8 } static __u8 -smb2_parse_lease_buf(void *buf, unsigned int *epoch) +smb2_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key) { struct create_lease *lc = (struct create_lease *)buf; @@ -1129,13 +1129,16 @@ smb2_parse_lease_buf(void *buf, unsigned } static __u8 -smb3_parse_lease_buf(void *buf, unsigned int *epoch) +smb3_parse_lease_buf(void *buf, unsigned int *epoch, char *lease_key) { struct create_lease_v2 *lc = (struct create_lease_v2 *)buf; *epoch = le16_to_cpu(lc->lcontext.Epoch); if (lc->lcontext.LeaseFlags & SMB2_LEASE_FLAG_BREAK_IN_PROGRESS) return SMB2_OPLOCK_LEVEL_NOCHANGE; + if (lease_key) + memcpy(lease_key, &lc->lcontext.LeaseKeyLow, + SMB2_LEASE_KEY_SIZE); return le32_to_cpu(lc->lcontext.LeaseState); } --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1054,7 +1054,7 @@ create_reconnect_durable_buf(struct cifs static __u8 parse_lease_state(struct TCP_Server_Info *server, struct smb2_create_rsp *rsp, - unsigned int *epoch) + unsigned int *epoch, char *lease_key) { char *data_offset; struct create_context *cc; @@ -1069,7 +1069,8 @@ parse_lease_state(struct TCP_Server_Info name = le16_to_cpu(cc->NameOffset) + (char *)cc; if (le16_to_cpu(cc->NameLength) == 4 && strncmp(name, "RqLs", 4) == 0) - return server->ops->parse_lease_buf(cc, epoch); + return server->ops->parse_lease_buf(cc, epoch, + lease_key); next = le32_to_cpu(cc->Next); if (!next) @@ -1262,7 +1263,8 @@ SMB2_open(const unsigned int xid, struct } if (rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) - *oplock = parse_lease_state(server, rsp, &oparms->fid->epoch); + *oplock = parse_lease_state(server, rsp, &oparms->fid->epoch, + oparms->fid->lease_key); else *oplock = rsp->OplockLevel; creat_exit: