Skip to contentSkip to conversation

ksmbd: limit read/write/trans buffer size not to exceed MAX_STREAM_PROT_LEN

PATCH Superseded Namjae Jeon 2 participants 3 messages Oct 8, 2021 – Oct 11, 2021

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Namjae Jeon

author maintainer
#0 lore raw

PATCH v2 1/1 ksmbd: limit read/write/trans buffer size not to exceed MAX_STREAM_PROT_LEN

ksmbd limit read/write/trans buffer size not to exceed maximum stream protocol length(0x00FFFFFF).

Cc Tom Talpey <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Hyunchul Lee <[email protected]>
Cc Steve French <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---
v2:
- change 8MB limitation to MAX_STREAM_PROT_LEN.

 fs/ksmbd/smb2ops.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ksmbd/smb2ops.c +3 -0
index b06456eb587b..63289872da97 100644
@@ -284,6 +284,7 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
 
 void init_smb2_max_read_size(unsigned int sz)
 {
+	sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
 	smb21_server_values.max_read_size = sz;
 	smb30_server_values.max_read_size = sz;
 	smb302_server_values.max_read_size = sz;
@@ -292,6 +293,7 @@ void init_smb2_max_read_size(unsigned int sz)
 
 void init_smb2_max_write_size(unsigned int sz)
 {
+	sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
 	smb21_server_values.max_write_size = sz;
 	smb30_server_values.max_write_size = sz;
 	smb302_server_values.max_write_size = sz;
@@ -300,6 +302,7 @@ void init_smb2_max_write_size(unsigned int sz)
 
 void init_smb2_max_trans_size(unsigned int sz)
 {
+	sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
 	smb21_server_values.max_trans_size = sz;
 	smb30_server_values.max_trans_size = sz;
 	smb302_server_values.max_trans_size = sz;
Signature · 1 line
2.25.1
#1 lore raw

2021년 10월 8일 (금) 오후 12:29, Namjae Jeon <[email protected]>님이 작성:

Quoted 23 lines

ksmbd limit read/write/trans buffer size not to exceed maximum stream protocol length(0x00FFFFFF).

Cc Tom Talpey <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Hyunchul Lee <[email protected]>
Cc Steve French <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---
v2:
- change 8MB limitation to MAX_STREAM_PROT_LEN.

 fs/ksmbd/smb2ops.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ksmbd/smb2ops.c +0 -0
index b06456eb587b..63289872da97 100644

fs/ksmbd/smb2ops.c int init_smb3_11_server(struct ksmbd_conn *conn) · line 287

Quoted 4 lines
fs/ksmbd/smb2ops.c +1 -0
@@ -284,6 +284,7 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
 
 void init_smb2_max_read_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);

If the maximum read size is MAX_STREAM_PROT_LEN, couldn't headers + data exceed MAX_STREAM_PROT_LEN?

Quoted 22 lines
fs/ksmbd/smb2ops.c +2 -1
        smb21_server_values.max_read_size = sz;
        smb30_server_values.max_read_size = sz;
        smb302_server_values.max_read_size = sz;
@@ -292,6 +293,7 @@ void init_smb2_max_read_size(unsigned int sz)
 
 void init_smb2_max_write_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
        smb21_server_values.max_write_size = sz;
        smb30_server_values.max_write_size = sz;
        smb302_server_values.max_write_size = sz;
@@ -300,6 +302,7 @@ void init_smb2_max_write_size(unsigned int sz)
 
 void init_smb2_max_trans_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
        smb21_server_values.max_trans_size = sz;
        smb30_server_values.max_trans_size = sz;
        smb302_server_values.max_trans_size = sz;
--

2.25.1

Signature · 2 lines
Thanks,
Hyunchul
author maintainer
#2 lore raw

2021-10-11 21:28 GMT+09:00, Hyunchul Lee <[email protected]>:

Quoted 25 lines

2021년 10월 8일 (금) 오후 12:29, Namjae Jeon <[email protected]>님이 작성:

Quoted 24 lines

ksmbd limit read/write/trans buffer size not to exceed maximum stream protocol length(0x00FFFFFF).

Cc Tom Talpey <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc Ralph Böhme <[email protected]>
Cc Hyunchul Lee <[email protected]>
Cc Steve French <[email protected]>
Cc Sergey Senozhatsky <[email protected]>

---
v2:
- change 8MB limitation to MAX_STREAM_PROT_LEN.

 fs/ksmbd/smb2ops.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ksmbd/smb2ops.c +0 -0
index b06456eb587b..63289872da97 100644
@@ -284,6 +284,7 @@ int init_smb3_11_server(struct ksmbd_conn *conn)
 
Quoted 6 lines

fs/ksmbd/smb2ops.c int init_smb3_11_server(struct ksmbd_conn *conn) · line 287

Quoted 3 lines
fs/ksmbd/smb2ops.c +1 -0
 void init_smb2_max_read_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);

If the maximum read size is MAX_STREAM_PROT_LEN, couldn't headers + data exceed MAX_STREAM_PROT_LEN?

Right, I will fix it on v3.

Thanks!

Quoted 29 lines
Quoted 21 lines
fs/ksmbd/smb2ops.c +2 -1
        smb21_server_values.max_read_size = sz;
        smb30_server_values.max_read_size = sz;
        smb302_server_values.max_read_size = sz;
@@ -292,6 +293,7 @@ void init_smb2_max_read_size(unsigned int sz)
 
 void init_smb2_max_write_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
        smb21_server_values.max_write_size = sz;
        smb30_server_values.max_write_size = sz;
        smb302_server_values.max_write_size = sz;
@@ -300,6 +302,7 @@ void init_smb2_max_write_size(unsigned int sz)
 
 void init_smb2_max_trans_size(unsigned int sz)
 {
+       sz = min_t(u32, sz, MAX_STREAM_PROT_LEN);
        smb21_server_values.max_trans_size = sz;
        smb30_server_values.max_trans_size = sz;
        smb302_server_values.max_trans_size = sz;
--
Quoted 2 lines

2.25.1

--
Thanks,
Hyunchul