Skip to content

Commit 691aae4

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: do not grant v2 lease if parent lease key and epoch are not set
This patch fix xfstests generic/070 test with smb2 leases = yes. cifs.ko doesn't set parent lease key and epoch in create context v2 lease. ksmbd suppose that parent lease and epoch are vaild if data length is v2 lease context size and handle directory lease using this values. ksmbd should hanle it as v1 lease not v2 lease if parent lease key and epoch are not set in create context v2 lease. Cc: [email protected] Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent d1c189c commit 691aae4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

fs/smb/server/oplock.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,9 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
12011201

12021202
/* Only v2 leases handle the directory */
12031203
if (S_ISDIR(file_inode(fp->filp)->i_mode)) {
1204-
if (!lctx || lctx->version != 2)
1204+
if (!lctx || lctx->version != 2 ||
1205+
(lctx->flags != SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE &&
1206+
!lctx->epoch))
12051207
return 0;
12061208
}
12071209

@@ -1466,8 +1468,9 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
14661468
buf->lcontext.LeaseFlags = lease->flags;
14671469
buf->lcontext.Epoch = cpu_to_le16(lease->epoch);
14681470
buf->lcontext.LeaseState = lease->state;
1469-
memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
1470-
SMB2_LEASE_KEY_SIZE);
1471+
if (lease->flags == SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE)
1472+
memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
1473+
SMB2_LEASE_KEY_SIZE);
14711474
buf->ccontext.DataOffset = cpu_to_le16(offsetof
14721475
(struct create_lease_v2, lcontext));
14731476
buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
@@ -1526,8 +1529,9 @@ struct lease_ctx_info *parse_lease_state(void *open_req)
15261529
lreq->flags = lc->lcontext.LeaseFlags;
15271530
lreq->epoch = lc->lcontext.Epoch;
15281531
lreq->duration = lc->lcontext.LeaseDuration;
1529-
memcpy(lreq->parent_lease_key, lc->lcontext.ParentLeaseKey,
1530-
SMB2_LEASE_KEY_SIZE);
1532+
if (lreq->flags == SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE)
1533+
memcpy(lreq->parent_lease_key, lc->lcontext.ParentLeaseKey,
1534+
SMB2_LEASE_KEY_SIZE);
15311535
lreq->version = 2;
15321536
} else {
15331537
struct create_lease *lc = (struct create_lease *)cc;

0 commit comments

Comments
 (0)