@@ -1914,14 +1914,16 @@ int smb2_sess_setup(struct ksmbd_work *work)
1914
1914
int smb2_tree_connect (struct ksmbd_work * work )
1915
1915
{
1916
1916
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 ;
1919
1919
struct ksmbd_session * sess = work -> sess ;
1920
1920
char * treename = NULL , * name = NULL ;
1921
1921
struct ksmbd_tree_conn_status status ;
1922
1922
struct ksmbd_share_config * share ;
1923
1923
int rc = - EINVAL ;
1924
1924
1925
+ WORK_BUFFERS (work , req , rsp );
1926
+
1925
1927
treename = smb_strndup_from_utf16 (req -> Buffer ,
1926
1928
le16_to_cpu (req -> PathLength ), true,
1927
1929
conn -> local_nls );
@@ -2090,19 +2092,19 @@ static int smb2_create_open_flags(bool file_present, __le32 access,
2090
2092
*/
2091
2093
int smb2_tree_disconnect (struct ksmbd_work * work )
2092
2094
{
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 ;
2094
2097
struct ksmbd_session * sess = work -> sess ;
2095
2098
struct ksmbd_tree_connect * tcon = work -> tcon ;
2096
2099
2100
+ WORK_BUFFERS (work , req , rsp );
2101
+
2097
2102
rsp -> StructureSize = cpu_to_le16 (4 );
2098
2103
inc_rfc1001_len (work -> response_buf , 4 );
2099
2104
2100
2105
ksmbd_debug (SMB , "request\n" );
2101
2106
2102
2107
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
-
2106
2108
ksmbd_debug (SMB , "Invalid tid %d\n" , req -> hdr .Id .SyncId .TreeId );
2107
2109
2108
2110
rsp -> hdr .Status = STATUS_NETWORK_NAME_DELETED ;
@@ -2125,10 +2127,14 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
2125
2127
int smb2_session_logoff (struct ksmbd_work * work )
2126
2128
{
2127
2129
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 ;
2129
2132
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 );
2132
2138
2133
2139
rsp -> StructureSize = cpu_to_le16 (4 );
2134
2140
inc_rfc1001_len (work -> response_buf , 4 );
@@ -2168,12 +2174,14 @@ int smb2_session_logoff(struct ksmbd_work *work)
2168
2174
*/
2169
2175
static noinline int create_smb2_pipe (struct ksmbd_work * work )
2170
2176
{
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 ;
2173
2179
int id ;
2174
2180
int err ;
2175
2181
char * name ;
2176
2182
2183
+ WORK_BUFFERS (work , req , rsp );
2184
+
2177
2185
name = smb_strndup_from_utf16 (req -> Buffer , le16_to_cpu (req -> NameLength ),
2178
2186
1 , work -> conn -> local_nls );
2179
2187
if (IS_ERR (name )) {
@@ -5306,8 +5314,10 @@ int smb2_query_info(struct ksmbd_work *work)
5306
5314
static noinline int smb2_close_pipe (struct ksmbd_work * work )
5307
5315
{
5308
5316
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 );
5311
5321
5312
5322
id = req -> VolatileFileId ;
5313
5323
ksmbd_session_rpc_close (work -> sess , id );
@@ -5449,6 +5459,9 @@ int smb2_echo(struct ksmbd_work *work)
5449
5459
{
5450
5460
struct smb2_echo_rsp * rsp = smb2_get_msg (work -> response_buf );
5451
5461
5462
+ if (work -> next_smb2_rcv_hdr_off )
5463
+ rsp = ksmbd_resp_buf_next (work );
5464
+
5452
5465
rsp -> StructureSize = cpu_to_le16 (4 );
5453
5466
rsp -> Reserved = 0 ;
5454
5467
inc_rfc1001_len (work -> response_buf , 4 );
@@ -6083,8 +6096,10 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
6083
6096
int nbytes = 0 , err ;
6084
6097
u64 id ;
6085
6098
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 );
6088
6103
6089
6104
id = req -> VolatileFileId ;
6090
6105
@@ -6332,14 +6347,16 @@ int smb2_read(struct ksmbd_work *work)
6332
6347
*/
6333
6348
static noinline int smb2_write_pipe (struct ksmbd_work * work )
6334
6349
{
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 ;
6337
6352
struct ksmbd_rpc_command * rpc_resp ;
6338
6353
u64 id = 0 ;
6339
6354
int err = 0 , ret = 0 ;
6340
6355
char * data_buf ;
6341
6356
size_t length ;
6342
6357
6358
+ WORK_BUFFERS (work , req , rsp );
6359
+
6343
6360
length = le32_to_cpu (req -> Length );
6344
6361
id = req -> VolatileFileId ;
6345
6362
@@ -6608,6 +6625,9 @@ int smb2_cancel(struct ksmbd_work *work)
6608
6625
struct ksmbd_work * iter ;
6609
6626
struct list_head * command_list ;
6610
6627
6628
+ if (work -> next_smb2_rcv_hdr_off )
6629
+ hdr = ksmbd_resp_buf_next (work );
6630
+
6611
6631
ksmbd_debug (SMB , "smb2 cancel called on mid %llu, async flags 0x%x\n" ,
6612
6632
hdr -> MessageId , hdr -> Flags );
6613
6633
@@ -6767,8 +6787,8 @@ static inline bool lock_defer_pending(struct file_lock *fl)
6767
6787
*/
6768
6788
int smb2_lock (struct ksmbd_work * work )
6769
6789
{
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 ;
6772
6792
struct smb2_lock_element * lock_ele ;
6773
6793
struct ksmbd_file * fp = NULL ;
6774
6794
struct file_lock * flock = NULL ;
@@ -6785,6 +6805,8 @@ int smb2_lock(struct ksmbd_work *work)
6785
6805
LIST_HEAD (rollback_list );
6786
6806
int prior_lock = 0 ;
6787
6807
6808
+ WORK_BUFFERS (work , req , rsp );
6809
+
6788
6810
ksmbd_debug (SMB , "Received lock request\n" );
6789
6811
fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
6790
6812
if (!fp ) {
@@ -7898,8 +7920,8 @@ int smb2_ioctl(struct ksmbd_work *work)
7898
7920
*/
7899
7921
static void smb20_oplock_break_ack (struct ksmbd_work * work )
7900
7922
{
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 ;
7903
7925
struct ksmbd_file * fp ;
7904
7926
struct oplock_info * opinfo = NULL ;
7905
7927
__le32 err = 0 ;
@@ -7908,6 +7930,8 @@ static void smb20_oplock_break_ack(struct ksmbd_work *work)
7908
7930
char req_oplevel = 0 , rsp_oplevel = 0 ;
7909
7931
unsigned int oplock_change_type ;
7910
7932
7933
+ WORK_BUFFERS (work , req , rsp );
7934
+
7911
7935
volatile_id = req -> VolatileFid ;
7912
7936
persistent_id = req -> PersistentFid ;
7913
7937
req_oplevel = req -> OplockLevel ;
@@ -8042,15 +8066,17 @@ static int check_lease_state(struct lease *lease, __le32 req_state)
8042
8066
static void smb21_lease_break_ack (struct ksmbd_work * work )
8043
8067
{
8044
8068
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 ;
8047
8071
struct oplock_info * opinfo ;
8048
8072
__le32 err = 0 ;
8049
8073
int ret = 0 ;
8050
8074
unsigned int lease_change_type ;
8051
8075
__le32 lease_state ;
8052
8076
struct lease * lease ;
8053
8077
8078
+ WORK_BUFFERS (work , req , rsp );
8079
+
8054
8080
ksmbd_debug (OPLOCK , "smb21 lease break, lease state(0x%x)\n" ,
8055
8081
le32_to_cpu (req -> LeaseState ));
8056
8082
opinfo = lookup_lease_in_table (conn , req -> LeaseKey );
@@ -8176,8 +8202,10 @@ static void smb21_lease_break_ack(struct ksmbd_work *work)
8176
8202
*/
8177
8203
int smb2_oplock_break (struct ksmbd_work * work )
8178
8204
{
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 );
8181
8209
8182
8210
switch (le16_to_cpu (req -> StructureSize )) {
8183
8211
case OP_BREAK_STRUCT_SIZE_20 :
0 commit comments