@@ -629,10 +629,10 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
629629 return ;
630630 }
631631
632- rsp_hdr = work -> response_buf ;
632+ rsp_hdr = smb2_get_msg ( work -> response_buf ) ;
633633 memset (rsp_hdr , 0 , sizeof (struct smb2_hdr ) + 2 );
634- rsp_hdr -> smb2_buf_length =
635- cpu_to_be32 (smb2_hdr_size_no_buflen ( conn -> vals ) );
634+ * ( __be32 * ) work -> response_buf =
635+ cpu_to_be32 (conn -> vals -> header_size );
636636 rsp_hdr -> ProtocolId = SMB2_PROTO_NUMBER ;
637637 rsp_hdr -> StructureSize = SMB2_HEADER_STRUCTURE_SIZE ;
638638 rsp_hdr -> CreditRequest = cpu_to_le16 (0 );
@@ -645,7 +645,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
645645 rsp_hdr -> SessionId = 0 ;
646646 memset (rsp_hdr -> Signature , 0 , 16 );
647647
648- rsp = work -> response_buf ;
648+ rsp = smb2_get_msg ( work -> response_buf ) ;
649649
650650 rsp -> StructureSize = cpu_to_le16 (24 );
651651 if (!br_info -> open_trunc &&
@@ -659,7 +659,7 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
659659 rsp -> PersistentFid = cpu_to_le64 (fp -> persistent_id );
660660 rsp -> VolatileFid = cpu_to_le64 (fp -> volatile_id );
661661
662- inc_rfc1001_len (rsp , 24 );
662+ inc_rfc1001_len (work -> response_buf , 24 );
663663
664664 ksmbd_debug (OPLOCK ,
665665 "sending oplock break v_id %llu p_id = %llu lock level = %d\n" ,
@@ -736,10 +736,10 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
736736 return ;
737737 }
738738
739- rsp_hdr = work -> response_buf ;
739+ rsp_hdr = smb2_get_msg ( work -> response_buf ) ;
740740 memset (rsp_hdr , 0 , sizeof (struct smb2_hdr ) + 2 );
741- rsp_hdr -> smb2_buf_length =
742- cpu_to_be32 (smb2_hdr_size_no_buflen ( conn -> vals ) );
741+ * ( __be32 * ) work -> response_buf =
742+ cpu_to_be32 (conn -> vals -> header_size );
743743 rsp_hdr -> ProtocolId = SMB2_PROTO_NUMBER ;
744744 rsp_hdr -> StructureSize = SMB2_HEADER_STRUCTURE_SIZE ;
745745 rsp_hdr -> CreditRequest = cpu_to_le16 (0 );
@@ -752,7 +752,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
752752 rsp_hdr -> SessionId = 0 ;
753753 memset (rsp_hdr -> Signature , 0 , 16 );
754754
755- rsp = work -> response_buf ;
755+ rsp = smb2_get_msg ( work -> response_buf ) ;
756756 rsp -> StructureSize = cpu_to_le16 (44 );
757757 rsp -> Epoch = br_info -> epoch ;
758758 rsp -> Flags = 0 ;
@@ -768,7 +768,7 @@ static void __smb2_lease_break_noti(struct work_struct *wk)
768768 rsp -> AccessMaskHint = 0 ;
769769 rsp -> ShareMaskHint = 0 ;
770770
771- inc_rfc1001_len (rsp , 44 );
771+ inc_rfc1001_len (work -> response_buf , 44 );
772772
773773 ksmbd_conn_write (work );
774774 ksmbd_free_work_struct (work );
@@ -1335,19 +1335,16 @@ __u8 smb2_map_lease_to_oplock(__le32 lease_state)
13351335 */
13361336void 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
@@ -1398,7 +1394,7 @@ struct lease_ctx_info *parse_lease_state(void *open_req)
13981394 if (!lreq )
13991395 return NULL ;
14001396
1401- data_offset = (char * )req + 4 + le32_to_cpu (req -> CreateContextsOffset );
1397+ data_offset = (char * )req + le32_to_cpu (req -> CreateContextsOffset );
14021398 cc = (struct create_context * )data_offset ;
14031399 do {
14041400 cc = (struct create_context * )((char * )cc + next );
@@ -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 ;
@@ -1462,7 +1456,7 @@ struct create_context *smb2_find_context_vals(void *open_req, const char *tag)
14621456 * CreateContextsOffset and CreateContextsLength are guaranteed to
14631457 * be valid because of ksmbd_smb2_check_message().
14641458 */
1465- cc = (struct create_context * )((char * )req + 4 +
1459+ cc = (struct create_context * )((char * )req +
14661460 le32_to_cpu (req -> CreateContextsOffset ));
14671461 remain_len = le32_to_cpu (req -> CreateContextsLength );
14681462 do {
0 commit comments