cifs: fix potential double put of TCP session reference
Subsystems (2)
PATCH 1/1 cifs: fix potential double put of TCP session reference
cifs_get_smb_ses must be called on a server pointer on which it holds an active reference. It first does a search for an existing SMB session. If it finds one, it'll put the server reference and then try to ensure that the negprot is done, etc.
If it encounters an error at that point then it'll return an error. There's a potential problem here though. When cifs_get_smb_ses returns an error, the caller will also put the TCP server reference leading to a double-put.
Fix this by having cifs_get_smb_ses only put the server reference if it found an existing session that it could use and isn't returning an error.
--- fs/cifs/connect.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/connect.c +3 -3
@@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)if (ses) {cFYI (1 ,"Existing smb sess found (status=%d)" , ses->status); -/* existing SMB ses has a server reference already */ -cifs_put_tcp_session (server); -mutex_lock (&ses->session_mutex); rc =cifs_negotiate_protocol (xid, ses);if (rc) {
@@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) } }mutex_unlock (&ses->session_mutex); + +/* existing SMB ses has a server reference already */ +cifs_put_tcp_session (server);FreeXid (xid);return ses; }
Signature · 1 line
1.7.2.2
A message that is not in the archive (sent off-list or not yet received): 1284400930-24134-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Suresh Jayaraman
Reviewed-byQuoted 34 lines · Jeff Layton
cifs_get_smb_sesmust be called on a server pointer on which it holds an active reference. It first does a search for an existing SMB session. If it finds one, it'll put the server reference and then try to ensure that the negprot is done, etc.If it encounters an error at that point then it'll return an error. There's a potential problem here though. When
cifs_get_smb_sesreturns an error, the caller will also put the TCP server reference leading to a double-put.Fix this by having
cifs_get_smb_sesonly put the server reference if it found an existing session that it could use and isn't returning an error.Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/connect.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/cifs/connect.c +0
-3@@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)if (ses) {cFYI (1 ,"Existing smb sess found (status=%d)" , ses->status); -/* existing SMB ses has a server reference already */ -cifs_put_tcp_session (server); -mutex_lock (&ses->session_mutex); rc =cifs_negotiate_protocol (xid, ses);if (rc) {
fs/cifs/connect.c cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) · line 1736
Quoted 9 lines
fs/cifs/connect.c +3
-0@@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) } }mutex_unlock (&ses->session_mutex); + +/* existing SMB ses has a server reference already */ +cifs_put_tcp_session (server);FreeXid (xid);return ses; }
Looks correct to me.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 47 lines · On Tue, 14 Sep 2010 15:18:32 +0530 Suresh Jayaraman…
Quoted 34 lines · Jeff Layton
cifs_get_smb_sesmust be called on a server pointer on which it holds an active reference. It first does a search for an existing SMB session. If it finds one, it'll put the server reference and then try to ensure that the negprot is done, etc.If it encounters an error at that point then it'll return an error. There's a potential problem here though. When
cifs_get_smb_sesreturns an error, the caller will also put the TCP server reference leading to a double-put.Fix this by having
cifs_get_smb_sesonly put the server reference if it found an existing session that it could use and isn't returning an error.Signed-off-by Jeff Layton <[email protected]>--- fs/cifs/connect.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)fs/cifs/connect.c +0
-3@@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)if (ses) {cFYI (1 ,"Existing smb sess found (status=%d)" , ses->status); -/* existing SMB ses has a server reference already */ -cifs_put_tcp_session (server); -mutex_lock (&ses->session_mutex); rc =cifs_negotiate_protocol (xid, ses);if (rc) {fs/cifs/connect.c cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) · line 1736
Quoted 9 lines
fs/cifs/connect.c +3
-0@@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) } }mutex_unlock (&ses->session_mutex); + +/* existing SMB ses has a server reference already */ +cifs_put_tcp_session (server);FreeXid (xid);return ses; }Looks correct to me.
Quoted 1 line
Reviewed-by Suresh Jayaraman <[email protected]>
Thanks. In hindsight, I should have probably sent this to stable too.
Steve, would you like me to resend and cc stable? We probably want this in 2.6.36 too, if possible.
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20100914073954.5c818d3c-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org
Quoted 50 lines · Jeff Layton
Quoted 47 lines · On Tue, 14 Sep 2010 15:18:32 +0530 Suresh Jayaraman…
Quoted 34 lines · Jeff Layton
cifs_get_smb_sesmust be called on a server pointer on which it holds an active reference. It first does a search for an existing SMB session. If it finds one, it'll put the server reference and then try to ensure that the negprot is done, etc.If it encounters an error at that point then it'll return an error. There's a potential problem here though. When
cifs_get_smb_sesreturns an error, the caller will also put the TCP server reference leading to a double-put.Fix this by having
cifs_get_smb_sesonly put the server reference if it found an existing session that it could use and isn't returning an error.Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/connect.c | 6 +++---1 files changed, 3 insertions(+), 3 deletions(-)fs/cifs/connect.c +0
-3@@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) if (ses) { cFYI(1, "Existing smb sess found (status=%d)", ses->status); - /* existing SMB ses has a server reference already */ - cifs_put_tcp_session(server); - mutex_lock(&ses->session_mutex); rc = cifs_negotiate_protocol(xid, ses); if (rc) {fs/cifs/connect.c cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) · line 1736
Quoted 9 lines
fs/cifs/connect.c +3
-0@@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) } } mutex_unlock(&ses->session_mutex); + + /* existing SMB ses has a server reference already */ + cifs_put_tcp_session(server); FreeXid(xid); return ses; }Looks correct to me.
Quoted 6 lines
Quoted 1 line
Reviewed-by Suresh Jayaraman <[email protected]>Thanks. In hindsight, I should have probably sent this to stable too.
Steve, would you like me to resend and cc stable? We probably want this in 2.6.36 too, if possible.
Yes - I agree makes sense. Any other candidate patches for 2.6.36?
Signature · 3 lines
Thanks, Steve
A message that is not in the archive (sent off-list or not yet received): AANLkTi=RDgXd50Qu1G1ifZOdrzVEz2YC3f0z2pzyhrRn-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 51 lines · On Tue, 14 Sep 2010 10:19:56 -0500 Steve French…
Quoted 50 lines · Jeff Layton
Quoted 47 lines · On Tue, 14 Sep 2010 15:18:32 +0530 Suresh Jayaraman…
Quoted 34 lines · Jeff Layton
cifs_get_smb_sesmust be called on a server pointer on which it holds an active reference. It first does a search for an existing SMB session. If it finds one, it'll put the server reference and then try to ensure that the negprot is done, etc.If it encounters an error at that point then it'll return an error. There's a potential problem here though. When
cifs_get_smb_sesreturns an error, the caller will also put the TCP server reference leading to a double-put.Fix this by having
cifs_get_smb_sesonly put the server reference if it found an existing session that it could use and isn't returning an error.Signed-off-by Jeff Layton <[email protected]>---
fs/cifs/connect.c | 6 +++---1 files changed, 3 insertions(+), 3 deletions(-)fs/cifs/connect.c +0
-3@@ -1706,9 +1706,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) if (ses) { cFYI(1, "Existing smb sess found (status=%d)", ses->status); - /* existing SMB ses has a server reference already */ - cifs_put_tcp_session(server); - mutex_lock(&ses->session_mutex); rc = cifs_negotiate_protocol(xid, ses); if (rc) {fs/cifs/connect.c cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) · line 1736
Quoted 9 lines
fs/cifs/connect.c +3
-0@@ -1731,6 +1728,9 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) } } mutex_unlock(&ses->session_mutex); + + /* existing SMB ses has a server reference already */ + cifs_put_tcp_session(server); FreeXid(xid); return ses; }Looks correct to me.
Quoted 9 lines
Quoted 6 lines
Quoted 1 line
Reviewed-by Suresh Jayaraman <[email protected]>Thanks. In hindsight, I should have probably sent this to stable too.
Steve, would you like me to resend and cc stable? We probably want this in 2.6.36 too, if possible.
Yes - I agree makes sense. Any other candidate patches for 2.6.36?
No, that's all I've got for now. I'll resend in a bit and cc stable.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>