Skip to contentSkip to conversation

CIFS: fix max ea value size

PATCH In review Murphy Zhou 3 participants 5 messages Sep 21, 2019 – Sep 24, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CIFS: fix max ea value size

It should not be larger then the slab max buf size. If user specifies a larger size, it passes this check and goes straightly to SMB2_set_info_init performing an insecure memcpy.

---
 fs/cifs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/xattr.c +1 -1
index 9076150758d8..db4ba8f6077e 100644
@@ -31,7 +31,7 @@
 #include "cifs_fs_sb.h"
 #include "cifs_unicode.h"
 
-#define MAX_EA_VALUE_SIZE 65535
+#define MAX_EA_VALUE_SIZE CIFSMaxBufSize
 #define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
 #define CIFS_XATTR_ATTRIB "cifs.dosattrib"  /* full name: user.cifs.dosattrib */
 #define CIFS_XATTR_CREATETIME "cifs.creationtime"  /* user.cifs.creationtime */
Signature · 1 line
2.21.0
#1 lore raw
Quoted 3 lines · Murphy Zhou

It should not be larger then the slab max buf size. If user specifies a larger size, it passes this check and goes straightly to SMB2_set_info_init performing an insecure memcpy.

It's even smaller than that as CIFSMaxBufSize is the max size for the whole packet IIRC. The EA payload needs to fit into that. So it should be CIFSMaxBufSize-(largest SMB2 header size + Set EA initial header). And if we set multiple EA at the same time it has to be divided by the number of EAs etc...

Cheers,

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
#2 lore raw
Quoted 8 lines · Aurélien Aptel
Quoted 3 lines · Murphy Zhou

It should not be larger then the slab max buf size. If user specifies a larger size, it passes this check and goes straightly to SMB2_set_info_init performing an insecure memcpy.

It's even smaller than that as CIFSMaxBufSize is the max size for the whole packet IIRC. The EA payload needs to fit into that. So it should be CIFSMaxBufSize-(largest SMB2 header size + Set EA initial header).

No need. Slab size includes the bufzise and the header size.

Quoted 2 lines

And if we set multiple EA at the same time it has to be divided by the number of EAs etc...

They will be handled separately and slab will work well.

Quoted 7 lines

Cheers,

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
#3 lore raw

Your patch looks correct - added cc:stable and merged to cifs-2.6.git for-next

Quoted 25 lines · Murphy Zhou
Quoted 8 lines · Aurélien Aptel
Quoted 3 lines · Murphy Zhou

It should not be larger then the slab max buf size. If user specifies a larger size, it passes this check and goes straightly to SMB2_set_info_init performing an insecure memcpy.

It's even smaller than that as CIFSMaxBufSize is the max size for the whole packet IIRC. The EA payload needs to fit into that. So it should be CIFSMaxBufSize-(largest SMB2 header size + Set EA initial header).

No need. Slab size includes the bufzise and the header size.

Quoted 2 lines

And if we set multiple EA at the same time it has to be divided by the number of EAs etc...

They will be handled separately and slab will work well.

Quoted 7 lines

Cheers,
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)

Signature · 3 lines
Thanks,

Steve
#4 lore raw
In reply to Murphy Zhou
Quoted 6 lines · Murphy Zhou

No need. Slab size includes the bufzise and the header size.

Quoted 2 lines

And if we set multiple EA at the same time it has to be divided by the number of EAs etc...

They will be handled separately and slab will work well.

Oh, you are right, I have no more remarks then.
We reviewed this with steve.

Thanks

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)