@@ -6183,6 +6183,8 @@ int smb2_read(struct ksmbd_work *work)
61836183 size_t length , mincount ;
61846184 ssize_t nbytes = 0 , remain_bytes = 0 ;
61856185 int err = 0 ;
6186+ bool is_rdma_channel = false;
6187+ unsigned int max_read_size = conn -> vals -> max_read_size ;
61866188
61876189 WORK_BUFFERS (work , req , rsp );
61886190
@@ -6194,6 +6196,11 @@ int smb2_read(struct ksmbd_work *work)
61946196
61956197 if (req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
61966198 req -> Channel == SMB2_CHANNEL_RDMA_V1 ) {
6199+ is_rdma_channel = true;
6200+ max_read_size = get_smbd_max_read_write_size ();
6201+ }
6202+
6203+ if (is_rdma_channel == true) {
61976204 unsigned int ch_offset = le16_to_cpu (req -> ReadChannelInfoOffset );
61986205
61996206 if (ch_offset < offsetof(struct smb2_read_req , Buffer )) {
@@ -6225,9 +6232,9 @@ int smb2_read(struct ksmbd_work *work)
62256232 length = le32_to_cpu (req -> Length );
62266233 mincount = le32_to_cpu (req -> MinimumCount );
62276234
6228- if (length > conn -> vals -> max_read_size ) {
6235+ if (length > max_read_size ) {
62296236 ksmbd_debug (SMB , "limiting read size to max size(%u)\n" ,
6230- conn -> vals -> max_read_size );
6237+ max_read_size );
62316238 err = - EINVAL ;
62326239 goto out ;
62336240 }
@@ -6259,8 +6266,7 @@ int smb2_read(struct ksmbd_work *work)
62596266 ksmbd_debug (SMB , "nbytes %zu, offset %lld mincount %zu\n" ,
62606267 nbytes , offset , mincount );
62616268
6262- if (req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ||
6263- req -> Channel == SMB2_CHANNEL_RDMA_V1 ) {
6269+ if (is_rdma_channel == true) {
62646270 /* write data to the client using rdma channel */
62656271 remain_bytes = smb2_read_rdma_channel (work , req ,
62666272 work -> aux_payload_buf ,
@@ -6421,8 +6427,9 @@ int smb2_write(struct ksmbd_work *work)
64216427 size_t length ;
64226428 ssize_t nbytes ;
64236429 char * data_buf ;
6424- bool writethrough = false;
6430+ bool writethrough = false, is_rdma_channel = false ;
64256431 int err = 0 ;
6432+ unsigned int max_write_size = work -> conn -> vals -> max_write_size ;
64266433
64276434 WORK_BUFFERS (work , req , rsp );
64286435
@@ -6431,8 +6438,17 @@ int smb2_write(struct ksmbd_work *work)
64316438 return smb2_write_pipe (work );
64326439 }
64336440
6441+ offset = le64_to_cpu (req -> Offset );
6442+ length = le32_to_cpu (req -> Length );
6443+
64346444 if (req -> Channel == SMB2_CHANNEL_RDMA_V1 ||
64356445 req -> Channel == SMB2_CHANNEL_RDMA_V1_INVALIDATE ) {
6446+ is_rdma_channel = true;
6447+ max_write_size = get_smbd_max_read_write_size ();
6448+ length = le32_to_cpu (req -> RemainingBytes );
6449+ }
6450+
6451+ if (is_rdma_channel == true) {
64366452 unsigned int ch_offset = le16_to_cpu (req -> WriteChannelInfoOffset );
64376453
64386454 if (req -> Length != 0 || req -> DataOffset != 0 ||
@@ -6467,21 +6483,17 @@ int smb2_write(struct ksmbd_work *work)
64676483 goto out ;
64686484 }
64696485
6470- offset = le64_to_cpu (req -> Offset );
6471- length = le32_to_cpu (req -> Length );
6472-
6473- if (length > work -> conn -> vals -> max_write_size ) {
6486+ if (length > max_write_size ) {
64746487 ksmbd_debug (SMB , "limiting write size to max size(%u)\n" ,
6475- work -> conn -> vals -> max_write_size );
6488+ max_write_size );
64766489 err = - EINVAL ;
64776490 goto out ;
64786491 }
64796492
64806493 if (le32_to_cpu (req -> Flags ) & SMB2_WRITEFLAG_WRITE_THROUGH )
64816494 writethrough = true;
64826495
6483- if (req -> Channel != SMB2_CHANNEL_RDMA_V1 &&
6484- req -> Channel != SMB2_CHANNEL_RDMA_V1_INVALIDATE ) {
6496+ if (is_rdma_channel == false) {
64856497 if ((u64 )le16_to_cpu (req -> DataOffset ) + length >
64866498 get_rfc1002_len (work -> request_buf )) {
64876499 pr_err ("invalid write data offset %u, smb_len %u\n" ,
@@ -6507,8 +6519,7 @@ int smb2_write(struct ksmbd_work *work)
65076519 /* read data from the client using rdma channel, and
65086520 * write the data.
65096521 */
6510- nbytes = smb2_write_rdma_channel (work , req , fp , offset ,
6511- le32_to_cpu (req -> RemainingBytes ),
6522+ nbytes = smb2_write_rdma_channel (work , req , fp , offset , length ,
65126523 writethrough );
65136524 if (nbytes < 0 ) {
65146525 err = (int )nbytes ;
0 commit comments