Skip to content

Commit 8d1bca3

Browse files
jtlaytonSteve French
authored andcommitted
cifs: correctly handle NULL tcon pointer in CIFSTCon
Long ago (in commit 00e485b), I added some code to handle share-level passwords in CIFSTCon. That code ignored the fact that it's legit to pass in a NULL tcon pointer when connecting to the IPC$ share on the server. This wasn't really a problem until recently as we only called CIFSTCon this way when the server returned -EREMOTE. With the introduction of commit c1508ca however, it gets called this way on every mount, causing an oops when share-level security is in effect. Fix this by simply treating a NULL tcon pointer as if user-level security were in effect. I'm not aware of any servers that protect the IPC$ share with a specific password anyway. Also, add a comment to the top of CIFSTCon to ensure that we don't make the same mistake again. Cc: <stable@kernel.org> Reported-by: Martijn Uffing <mp3project@sarijopen.student.utwente.nl> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent 3e71551 commit 8d1bca3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎fs/cifs/connect.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3174,6 +3174,10 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
31743174
return rc;
31753175
}
31763176

3177+
/*
3178+
* Issue a TREE_CONNECT request. Note that for IPC$ shares, that the tcon
3179+
* pointer may be NULL.
3180+
*/
31773181
int
31783182
CIFSTCon(unsigned int xid, struct cifs_ses *ses,
31793183
const char *tree, struct cifs_tcon *tcon,
@@ -3208,7 +3212,7 @@ CIFSTCon(unsigned int xid, struct cifs_ses *ses,
32083212
pSMB->AndXCommand = 0xFF;
32093213
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
32103214
bcc_ptr = &pSMB->Password[0];
3211-
if ((ses->server->sec_mode) & SECMODE_USER) {
3215+
if (!tcon || (ses->server->sec_mode & SECMODE_USER)) {
32123216
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
32133217
*bcc_ptr = 0; /* password is null byte */
32143218
bcc_ptr++; /* skip password */

0 commit comments

Comments
 (0)