Skip to content

Commit 2734b69

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: change LeaseKey data type to u8 array
cifs define LeaseKey as u8 array in structure. To move lease structure to smbfs_common, ksmbd change LeaseKey data type to u8 array. Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2dd9129 commit 2734b69

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
lines changed

fs/ksmbd/oplock.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,19 +1335,16 @@ __u8 smb2_map_lease_to_oplock(__le32 lease_state)
13351335
*/
13361336
void create_lease_buf(u8 *rbuf, struct lease *lease)
13371337
{
1338-
char *LeaseKey = (char *)&lease->lease_key;
1339-
13401338
if (lease->version == 2) {
13411339
struct create_lease_v2 *buf = (struct create_lease_v2 *)rbuf;
1342-
char *ParentLeaseKey = (char *)&lease->parent_lease_key;
13431340

13441341
memset(buf, 0, sizeof(struct create_lease_v2));
1345-
buf->lcontext.LeaseKeyLow = *((__le64 *)LeaseKey);
1346-
buf->lcontext.LeaseKeyHigh = *((__le64 *)(LeaseKey + 8));
1342+
memcpy(buf->lcontext.LeaseKey, lease->lease_key,
1343+
SMB2_LEASE_KEY_SIZE);
13471344
buf->lcontext.LeaseFlags = lease->flags;
13481345
buf->lcontext.LeaseState = lease->state;
1349-
buf->lcontext.ParentLeaseKeyLow = *((__le64 *)ParentLeaseKey);
1350-
buf->lcontext.ParentLeaseKeyHigh = *((__le64 *)(ParentLeaseKey + 8));
1346+
memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
1347+
SMB2_LEASE_KEY_SIZE);
13511348
buf->ccontext.DataOffset = cpu_to_le16(offsetof
13521349
(struct create_lease_v2, lcontext));
13531350
buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
@@ -1362,8 +1359,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
13621359
struct create_lease *buf = (struct create_lease *)rbuf;
13631360

13641361
memset(buf, 0, sizeof(struct create_lease));
1365-
buf->lcontext.LeaseKeyLow = *((__le64 *)LeaseKey);
1366-
buf->lcontext.LeaseKeyHigh = *((__le64 *)(LeaseKey + 8));
1362+
memcpy(buf->lcontext.LeaseKey, lease->lease_key, SMB2_LEASE_KEY_SIZE);
13671363
buf->lcontext.LeaseFlags = lease->flags;
13681364
buf->lcontext.LeaseState = lease->state;
13691365
buf->ccontext.DataOffset = cpu_to_le16(offsetof
@@ -1416,19 +1412,17 @@ struct lease_ctx_info *parse_lease_state(void *open_req)
14161412
if (sizeof(struct lease_context_v2) == le32_to_cpu(cc->DataLength)) {
14171413
struct create_lease_v2 *lc = (struct create_lease_v2 *)cc;
14181414

1419-
*((__le64 *)lreq->lease_key) = lc->lcontext.LeaseKeyLow;
1420-
*((__le64 *)(lreq->lease_key + 8)) = lc->lcontext.LeaseKeyHigh;
1415+
memcpy(lreq->lease_key, lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
14211416
lreq->req_state = lc->lcontext.LeaseState;
14221417
lreq->flags = lc->lcontext.LeaseFlags;
14231418
lreq->duration = lc->lcontext.LeaseDuration;
1424-
*((__le64 *)lreq->parent_lease_key) = lc->lcontext.ParentLeaseKeyLow;
1425-
*((__le64 *)(lreq->parent_lease_key + 8)) = lc->lcontext.ParentLeaseKeyHigh;
1419+
memcpy(lreq->parent_lease_key, lc->lcontext.ParentLeaseKey,
1420+
SMB2_LEASE_KEY_SIZE);
14261421
lreq->version = 2;
14271422
} else {
14281423
struct create_lease *lc = (struct create_lease *)cc;
14291424

1430-
*((__le64 *)lreq->lease_key) = lc->lcontext.LeaseKeyLow;
1431-
*((__le64 *)(lreq->lease_key + 8)) = lc->lcontext.LeaseKeyHigh;
1425+
memcpy(lreq->lease_key, lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
14321426
lreq->req_state = lc->lcontext.LeaseState;
14331427
lreq->flags = lc->lcontext.LeaseFlags;
14341428
lreq->duration = lc->lcontext.LeaseDuration;

fs/ksmbd/oplock.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#define OPLOCK_WRITE_TO_NONE 0x04
2929
#define OPLOCK_READ_TO_NONE 0x08
3030

31-
#define SMB2_LEASE_KEY_SIZE 16
32-
3331
struct lease_ctx_info {
3432
__u8 lease_key[SMB2_LEASE_KEY_SIZE];
3533
__le32 req_state;

fs/ksmbd/smb2pdu.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,22 +733,21 @@ struct create_posix_rsp {
733733

734734
#define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE cpu_to_le32(0x02)
735735

736+
#define SMB2_LEASE_KEY_SIZE 16
737+
736738
struct lease_context {
737-
__le64 LeaseKeyLow;
738-
__le64 LeaseKeyHigh;
739+
__u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
739740
__le32 LeaseState;
740741
__le32 LeaseFlags;
741742
__le64 LeaseDuration;
742743
} __packed;
743744

744745
struct lease_context_v2 {
745-
__le64 LeaseKeyLow;
746-
__le64 LeaseKeyHigh;
746+
__u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
747747
__le32 LeaseState;
748748
__le32 LeaseFlags;
749749
__le64 LeaseDuration;
750-
__le64 ParentLeaseKeyLow;
751-
__le64 ParentLeaseKeyHigh;
750+
__u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE];
752751
__le16 Epoch;
753752
__le16 Reserved;
754753
} __packed;

0 commit comments

Comments
 (0)