public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ksmbd: limit read/write/trans buffer size not to exceed 8MB
@ 2021-10-07 22:31 Namjae Jeon
  2021-10-07 22:31 ` [PATCH v5] ksmbd: add validation in smb2_ioctl Namjae Jeon
  2021-10-12  1:01 ` [PATCH] ksmbd: limit read/write/trans buffer size not to exceed 8MB Sergey Senozhatsky
  0 siblings, 2 replies; 4+ messages in thread
From: Namjae Jeon @ 2021-10-07 22:31 UTC (permalink / raw)
  To: linux-cifs
  Cc: Namjae Jeon, Tom Talpey, Ronnie Sahlberg, Ralph Böhme,
	Hyunchul Lee, Steve French, Sergey Senozhatsky, Colin Ian King

ksmbd limit read/write/trans buffer size not to exceed 8MB like samba.

Cc: Tom Talpey <tom@talpey.com>
Cc: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Cc: Ralph Böhme <slow@samba.org>
Cc: Hyunchul Lee <hyc.lee@gmail.com>
Cc: Steve French <smfrench@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Colin Ian King <colin.king@canonical.com>

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ksmbd/smb2ops.c | 3 +++
 fs/ksmbd/smb2pdu.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/fs/ksmbd/smb2ops.c b/fs/ksmbd/smb2ops.c
index b06456eb587b..97027c0962d3 100644
--- a/fs/ksmbd/smb2ops.c
+++ b/fs/ksmbd/smb2ops.c
@@ -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, SMB_MAX_IOSIZE);
 	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, SMB_MAX_IOSIZE);
 	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, SMB_MAX_IOSIZE);
 	smb21_server_values.max_trans_size = sz;
 	smb30_server_values.max_trans_size = sz;
 	smb302_server_values.max_trans_size = sz;
diff --git a/fs/ksmbd/smb2pdu.h b/fs/ksmbd/smb2pdu.h
index a6dec5ec6a54..b66c562e90e3 100644
--- a/fs/ksmbd/smb2pdu.h
+++ b/fs/ksmbd/smb2pdu.h
@@ -113,6 +113,7 @@
 #define SMB21_DEFAULT_IOSIZE	(1024 * 1024)
 #define SMB3_DEFAULT_IOSIZE	(4 * 1024 * 1024)
 #define SMB3_DEFAULT_TRANS_SIZE	(1024 * 1024)
+#define SMB_MAX_IOSIZE	(8 * 1024 * 1024)
 
 /*
  * SMB2 Header Definition
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-12  1:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-07 22:31 [PATCH] ksmbd: limit read/write/trans buffer size not to exceed 8MB Namjae Jeon
2021-10-07 22:31 ` [PATCH v5] ksmbd: add validation in smb2_ioctl Namjae Jeon
2021-10-12  1:01 ` [PATCH] ksmbd: limit read/write/trans buffer size not to exceed 8MB Sergey Senozhatsky
2021-10-12  1:29   ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox