Skip to contentSkip to conversation

CIFS: avoid using MID 0xFFFF

PATCH In review Roberto Bergantinos Corpas 3 participants 3 messages Oct 14, 2019

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

PATCH 1/1 CIFS: avoid using MID 0xFFFF

According to MS-CIFS specification MID 0xFFFF should not be used by the CIFS client, but we actually do. Besides, this has proven to cause races leading to oops between SendReceive2/cifs_demultiplex_thread. On SMB1, MID is a 2 byte value easy to reach in CurrentMid which may conflict with an oplock break notification request coming from server

---
 fs/cifs/smb1ops.c | 3 +++
 1 file changed, 3 insertions(+)
fs/cifs/smb1ops.c +3 -0
index c4e75afa3258..c8d96230cbd2 100644
@@ -183,6 +183,9 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
 	/* we do not want to loop forever */
 	last_mid = cur_mid;
 	cur_mid++;
+	/* avoid 0xFFFF MID */
+	if (cur_mid == 0xffff)
+		cur_mid++;
 
 	/*
 	 * This nested loop looks more expensive than it is.
Signature · 1 line
2.14.5
reviewer Reviewed-by [email protected] on v1 1/1
#1 lore raw
Quoted 17 lines · Roberto Bergantinos Corpas

According to MS-CIFS specification MID 0xFFFF should not be used by the CIFS client, but we actually do. Besides, this has proven to cause races leading to oops between SendReceive2/cifs_demultiplex_thread. On SMB1, MID is a 2 byte value easy to reach in CurrentMid which may conflict with an oplock break notification request coming from server

---
 fs/cifs/smb1ops.c | 3 +++
 1 file changed, 3 insertions(+)
fs/cifs/smb1ops.c +0 -0
index c4e75afa3258..c8d96230cbd2 100644

fs/cifs/smb1ops.c cifs_get_next_mid(struct TCP_Server_Info *server)

Quoted 10 lines
fs/cifs/smb1ops.c +3 -1
@@ -183,6 +183,9 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
        /* we do not want to loop forever */
        last_mid = cur_mid;
        cur_mid++;
+       /* avoid 0xFFFF MID */
+       if (cur_mid == 0xffff)
+               cur_mid++;
 
        /*
         * This nested loop looks more expensive than it is.
--

Steve, can we get this pushed to linus soonish? It is a bad issue.

#2 lore raw
Quoted 1 line · ronnie sahlberg

Steve, can we get this pushed to linus soonish? It is a bad issue.

Probably a good idea to CC: stable

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)