@@ -1914,14 +1914,16 @@ int smb2_sess_setup(struct ksmbd_work *work)
19141914int smb2_tree_connect (struct ksmbd_work * work )
19151915{
19161916 struct ksmbd_conn * conn = work -> conn ;
1917- struct smb2_tree_connect_req * req = smb2_get_msg ( work -> request_buf ) ;
1918- struct smb2_tree_connect_rsp * rsp = smb2_get_msg ( work -> response_buf ) ;
1917+ struct smb2_tree_connect_req * req ;
1918+ struct smb2_tree_connect_rsp * rsp ;
19191919 struct ksmbd_session * sess = work -> sess ;
19201920 char * treename = NULL , * name = NULL ;
19211921 struct ksmbd_tree_conn_status status ;
19221922 struct ksmbd_share_config * share ;
19231923 int rc = - EINVAL ;
19241924
1925+ WORK_BUFFERS (work , req , rsp );
1926+
19251927 treename = smb_strndup_from_utf16 (req -> Buffer ,
19261928 le16_to_cpu (req -> PathLength ), true,
19271929 conn -> local_nls );
@@ -2090,19 +2092,19 @@ static int smb2_create_open_flags(bool file_present, __le32 access,
20902092 */
20912093int smb2_tree_disconnect (struct ksmbd_work * work )
20922094{
2093- struct smb2_tree_disconnect_rsp * rsp = smb2_get_msg (work -> response_buf );
2095+ struct smb2_tree_disconnect_rsp * rsp ;
2096+ struct smb2_tree_disconnect_req * req ;
20942097 struct ksmbd_session * sess = work -> sess ;
20952098 struct ksmbd_tree_connect * tcon = work -> tcon ;
20962099
2100+ WORK_BUFFERS (work , req , rsp );
2101+
20972102 rsp -> StructureSize = cpu_to_le16 (4 );
20982103 inc_rfc1001_len (work -> response_buf , 4 );
20992104
21002105 ksmbd_debug (SMB , "request\n" );
21012106
21022107 if (!tcon || test_and_set_bit (TREE_CONN_EXPIRE , & tcon -> status )) {
2103- struct smb2_tree_disconnect_req * req =
2104- smb2_get_msg (work -> request_buf );
2105-
21062108 ksmbd_debug (SMB , "Invalid tid %d\n" , req -> hdr .Id .SyncId .TreeId );
21072109
21082110 rsp -> hdr .Status = STATUS_NETWORK_NAME_DELETED ;
@@ -2125,10 +2127,14 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
21252127int smb2_session_logoff (struct ksmbd_work * work )
21262128{
21272129 struct ksmbd_conn * conn = work -> conn ;
2128- struct smb2_logoff_rsp * rsp = smb2_get_msg (work -> response_buf );
2130+ struct smb2_logoff_req * req ;
2131+ struct smb2_logoff_rsp * rsp ;
21292132 struct ksmbd_session * sess ;
2130- struct smb2_logoff_req * req = smb2_get_msg (work -> request_buf );
2131- u64 sess_id = le64_to_cpu (req -> hdr .SessionId );
2133+ u64 sess_id ;
2134+
2135+ WORK_BUFFERS (work , req , rsp );
2136+
2137+ sess_id = le64_to_cpu (req -> hdr .SessionId );
21322138
21332139 rsp -> StructureSize = cpu_to_le16 (4 );
21342140 inc_rfc1001_len (work -> response_buf , 4 );
@@ -2168,12 +2174,14 @@ int smb2_session_logoff(struct ksmbd_work *work)
21682174 */
21692175static noinline int create_smb2_pipe (struct ksmbd_work * work )
21702176{
2171- struct smb2_create_rsp * rsp = smb2_get_msg ( work -> response_buf ) ;
2172- struct smb2_create_req * req = smb2_get_msg ( work -> request_buf ) ;
2177+ struct smb2_create_rsp * rsp ;
2178+ struct smb2_create_req * req ;
21732179 int id ;
21742180 int err ;
21752181 char * name ;
21762182
2183+ WORK_BUFFERS (work , req , rsp );
2184+
21772185 name = smb_strndup_from_utf16 (req -> Buffer , le16_to_cpu (req -> NameLength ),
21782186 1 , work -> conn -> local_nls );
21792187 if (IS_ERR (name )) {
@@ -5306,8 +5314,10 @@ int smb2_query_info(struct ksmbd_work *work)
53065314static noinline int smb2_close_pipe (struct ksmbd_work * work )
53075315{
53085316 u64 id ;
5309- struct smb2_close_req * req = smb2_get_msg (work -> request_buf );
5310- struct smb2_close_rsp * rsp = smb2_get_msg (work -> response_buf );
5317+ struct smb2_close_req * req ;
5318+ struct smb2_close_rsp * rsp ;
5319+
5320+ WORK_BUFFERS (work , req , rsp );
53115321
53125322 id = req -> VolatileFileId ;
53135323 ksmbd_session_rpc_close (work -> sess , id );
@@ -5449,6 +5459,9 @@ int smb2_echo(struct ksmbd_work *work)
54495459{
54505460 struct smb2_echo_rsp * rsp = smb2_get_msg (work -> response_buf );
54515461
5462+ if (work -> next_smb2_rcv_hdr_off )
5463+ rsp = ksmbd_resp_buf_next (work );
5464+
54525465 rsp -> StructureSize = cpu_to_le16 (4 );
54535466 rsp -> Reserved = 0 ;
54545467 inc_rfc1001_len (work -> response_buf , 4 );
@@ -6083,8 +6096,10 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
60836096 int nbytes = 0 , err ;
60846097 u64 id ;
60856098 struct ksmbd_rpc_command * rpc_resp ;
6086- struct smb2_read_req * req = smb2_get_msg (work -> request_buf );
6087- struct smb2_read_rsp * rsp = smb2_get_msg (work -> response_buf );
6099+ struct smb2_read_req * req ;
6100+ struct smb2_read_rsp * rsp ;
6101+
6102+ WORK_BUFFERS (work , req , rsp );
60886103
60896104 id = req -> VolatileFileId ;
60906105
@@ -6332,14 +6347,16 @@ int smb2_read(struct ksmbd_work *work)
63326347 */
63336348static noinline int smb2_write_pipe (struct ksmbd_work * work )
63346349{
6335- struct smb2_write_req * req = smb2_get_msg ( work -> request_buf ) ;
6336- struct smb2_write_rsp * rsp = smb2_get_msg ( work -> response_buf ) ;
6350+ struct smb2_write_req * req ;
6351+ struct smb2_write_rsp * rsp ;
63376352 struct ksmbd_rpc_command * rpc_resp ;
63386353 u64 id = 0 ;
63396354 int err = 0 , ret = 0 ;
63406355 char * data_buf ;
63416356 size_t length ;
63426357
6358+ WORK_BUFFERS (work , req , rsp );
6359+
63436360 length = le32_to_cpu (req -> Length );
63446361 id = req -> VolatileFileId ;
63456362
@@ -6608,6 +6625,9 @@ int smb2_cancel(struct ksmbd_work *work)
66086625 struct ksmbd_work * iter ;
66096626 struct list_head * command_list ;
66106627
6628+ if (work -> next_smb2_rcv_hdr_off )
6629+ hdr = ksmbd_resp_buf_next (work );
6630+
66116631 ksmbd_debug (SMB , "smb2 cancel called on mid %llu, async flags 0x%x\n" ,
66126632 hdr -> MessageId , hdr -> Flags );
66136633
@@ -6767,8 +6787,8 @@ static inline bool lock_defer_pending(struct file_lock *fl)
67676787 */
67686788int smb2_lock (struct ksmbd_work * work )
67696789{
6770- struct smb2_lock_req * req = smb2_get_msg ( work -> request_buf ) ;
6771- struct smb2_lock_rsp * rsp = smb2_get_msg ( work -> response_buf ) ;
6790+ struct smb2_lock_req * req ;
6791+ struct smb2_lock_rsp * rsp ;
67726792 struct smb2_lock_element * lock_ele ;
67736793 struct ksmbd_file * fp = NULL ;
67746794 struct file_lock * flock = NULL ;
@@ -6785,6 +6805,8 @@ int smb2_lock(struct ksmbd_work *work)
67856805 LIST_HEAD (rollback_list );
67866806 int prior_lock = 0 ;
67876807
6808+ WORK_BUFFERS (work , req , rsp );
6809+
67886810 ksmbd_debug (SMB , "Received lock request\n" );
67896811 fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
67906812 if (!fp ) {
@@ -7898,8 +7920,8 @@ int smb2_ioctl(struct ksmbd_work *work)
78987920 */
78997921static void smb20_oplock_break_ack (struct ksmbd_work * work )
79007922{
7901- struct smb2_oplock_break * req = smb2_get_msg ( work -> request_buf ) ;
7902- struct smb2_oplock_break * rsp = smb2_get_msg ( work -> response_buf ) ;
7923+ struct smb2_oplock_break * req ;
7924+ struct smb2_oplock_break * rsp ;
79037925 struct ksmbd_file * fp ;
79047926 struct oplock_info * opinfo = NULL ;
79057927 __le32 err = 0 ;
@@ -7908,6 +7930,8 @@ static void smb20_oplock_break_ack(struct ksmbd_work *work)
79087930 char req_oplevel = 0 , rsp_oplevel = 0 ;
79097931 unsigned int oplock_change_type ;
79107932
7933+ WORK_BUFFERS (work , req , rsp );
7934+
79117935 volatile_id = req -> VolatileFid ;
79127936 persistent_id = req -> PersistentFid ;
79137937 req_oplevel = req -> OplockLevel ;
@@ -8042,15 +8066,17 @@ static int check_lease_state(struct lease *lease, __le32 req_state)
80428066static void smb21_lease_break_ack (struct ksmbd_work * work )
80438067{
80448068 struct ksmbd_conn * conn = work -> conn ;
8045- struct smb2_lease_ack * req = smb2_get_msg ( work -> request_buf ) ;
8046- struct smb2_lease_ack * rsp = smb2_get_msg ( work -> response_buf ) ;
8069+ struct smb2_lease_ack * req ;
8070+ struct smb2_lease_ack * rsp ;
80478071 struct oplock_info * opinfo ;
80488072 __le32 err = 0 ;
80498073 int ret = 0 ;
80508074 unsigned int lease_change_type ;
80518075 __le32 lease_state ;
80528076 struct lease * lease ;
80538077
8078+ WORK_BUFFERS (work , req , rsp );
8079+
80548080 ksmbd_debug (OPLOCK , "smb21 lease break, lease state(0x%x)\n" ,
80558081 le32_to_cpu (req -> LeaseState ));
80568082 opinfo = lookup_lease_in_table (conn , req -> LeaseKey );
@@ -8176,8 +8202,10 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
81768202 */
81778203int smb2_oplock_break (struct ksmbd_work * work )
81788204{
8179- struct smb2_oplock_break * req = smb2_get_msg (work -> request_buf );
8180- struct smb2_oplock_break * rsp = smb2_get_msg (work -> response_buf );
8205+ struct smb2_oplock_break * req ;
8206+ struct smb2_oplock_break * rsp ;
8207+
8208+ WORK_BUFFERS (work , req , rsp );
81818209
81828210 switch (le16_to_cpu (req -> StructureSize )) {
81838211 case OP_BREAK_STRUCT_SIZE_20 :
0 commit comments