]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: change LeaseKey data type to u8 array
authorNamjae Jeon <linkinjeon@kernel.org>
Mon, 18 Dec 2023 15:32:27 +0000 (00:32 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:41:49 +0000 (10:41 +0100)
[ Upstream commit 2734b692f7b8167b93498dcd698067623d4267ca ]

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 <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ksmbd/oplock.c
fs/ksmbd/oplock.h
fs/ksmbd/smb2pdu.h

index e57b2aa718150ff8248d995838a0c10b1a166661..e1d854609195a3480d21a9dba2db46c4f72d4b95 100644 (file)
@@ -1336,19 +1336,16 @@ __u8 smb2_map_lease_to_oplock(__le32 lease_state)
  */
 void create_lease_buf(u8 *rbuf, struct lease *lease)
 {
-       char *LeaseKey = (char *)&lease->lease_key;
-
        if (lease->version == 2) {
                struct create_lease_v2 *buf = (struct create_lease_v2 *)rbuf;
-               char *ParentLeaseKey = (char *)&lease->parent_lease_key;
 
                memset(buf, 0, sizeof(struct create_lease_v2));
-               buf->lcontext.LeaseKeyLow = *((__le64 *)LeaseKey);
-               buf->lcontext.LeaseKeyHigh = *((__le64 *)(LeaseKey + 8));
+               memcpy(buf->lcontext.LeaseKey, lease->lease_key,
+                      SMB2_LEASE_KEY_SIZE);
                buf->lcontext.LeaseFlags = lease->flags;
                buf->lcontext.LeaseState = lease->state;
-               buf->lcontext.ParentLeaseKeyLow = *((__le64 *)ParentLeaseKey);
-               buf->lcontext.ParentLeaseKeyHigh = *((__le64 *)(ParentLeaseKey + 8));
+               memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
+                      SMB2_LEASE_KEY_SIZE);
                buf->ccontext.DataOffset = cpu_to_le16(offsetof
                                (struct create_lease_v2, lcontext));
                buf->ccontext.DataLength = cpu_to_le32(sizeof(struct lease_context_v2));
@@ -1363,8 +1360,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
                struct create_lease *buf = (struct create_lease *)rbuf;
 
                memset(buf, 0, sizeof(struct create_lease));
-               buf->lcontext.LeaseKeyLow = *((__le64 *)LeaseKey);
-               buf->lcontext.LeaseKeyHigh = *((__le64 *)(LeaseKey + 8));
+               memcpy(buf->lcontext.LeaseKey, lease->lease_key, SMB2_LEASE_KEY_SIZE);
                buf->lcontext.LeaseFlags = lease->flags;
                buf->lcontext.LeaseState = lease->state;
                buf->ccontext.DataOffset = cpu_to_le16(offsetof
@@ -1417,19 +1413,17 @@ struct lease_ctx_info *parse_lease_state(void *open_req)
                if (sizeof(struct lease_context_v2) == le32_to_cpu(cc->DataLength)) {
                        struct create_lease_v2 *lc = (struct create_lease_v2 *)cc;
 
-                       *((__le64 *)lreq->lease_key) = lc->lcontext.LeaseKeyLow;
-                       *((__le64 *)(lreq->lease_key + 8)) = lc->lcontext.LeaseKeyHigh;
+                       memcpy(lreq->lease_key, lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
                        lreq->req_state = lc->lcontext.LeaseState;
                        lreq->flags = lc->lcontext.LeaseFlags;
                        lreq->duration = lc->lcontext.LeaseDuration;
-                       *((__le64 *)lreq->parent_lease_key) = lc->lcontext.ParentLeaseKeyLow;
-                       *((__le64 *)(lreq->parent_lease_key + 8)) = lc->lcontext.ParentLeaseKeyHigh;
+                       memcpy(lreq->parent_lease_key, lc->lcontext.ParentLeaseKey,
+                              SMB2_LEASE_KEY_SIZE);
                        lreq->version = 2;
                } else {
                        struct create_lease *lc = (struct create_lease *)cc;
 
-                       *((__le64 *)lreq->lease_key) = lc->lcontext.LeaseKeyLow;
-                       *((__le64 *)(lreq->lease_key + 8)) = lc->lcontext.LeaseKeyHigh;
+                       memcpy(lreq->lease_key, lc->lcontext.LeaseKey, SMB2_LEASE_KEY_SIZE);
                        lreq->req_state = lc->lcontext.LeaseState;
                        lreq->flags = lc->lcontext.LeaseFlags;
                        lreq->duration = lc->lcontext.LeaseDuration;
index 2c4f4a0512b713218f741aaf38ebc13817a4c218..e1ba363b412a3ce24dc8a3d5b63c35eb13f7e2bf 100644 (file)
@@ -28,8 +28,6 @@
 #define OPLOCK_WRITE_TO_NONE           0x04
 #define OPLOCK_READ_TO_NONE            0x08
 
-#define SMB2_LEASE_KEY_SIZE            16
-
 struct lease_ctx_info {
        __u8                    lease_key[SMB2_LEASE_KEY_SIZE];
        __le32                  req_state;
index 2175ab5fb55711a0e674866fa06c3a821a7cf384..3ae27ccfc20d80e79e756e84203e1122af9c9ff5 100644 (file)
@@ -734,22 +734,21 @@ struct create_posix_rsp {
 
 #define SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE   cpu_to_le32(0x02)
 
+#define SMB2_LEASE_KEY_SIZE                    16
+
 struct lease_context {
-       __le64 LeaseKeyLow;
-       __le64 LeaseKeyHigh;
+       __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
        __le32 LeaseState;
        __le32 LeaseFlags;
        __le64 LeaseDuration;
 } __packed;
 
 struct lease_context_v2 {
-       __le64 LeaseKeyLow;
-       __le64 LeaseKeyHigh;
+       __u8 LeaseKey[SMB2_LEASE_KEY_SIZE];
        __le32 LeaseState;
        __le32 LeaseFlags;
        __le64 LeaseDuration;
-       __le64 ParentLeaseKeyLow;
-       __le64 ParentLeaseKeyHigh;
+       __u8 ParentLeaseKey[SMB2_LEASE_KEY_SIZE];
        __le16 Epoch;
        __le16 Reserved;
 } __packed;