s3: smbd: Fix SMB1 use-after-free crash bug. CVE-2017-14746
authorJeremy Allison <jra@samba.org>
Tue, 19 Sep 2017 23:11:33 +0000 (16:11 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 21 Nov 2017 14:46:12 +0000 (15:46 +0100)
When setting up the chain, always use 'next->' variables
not the 'req->' one.

Bug discovered by 连一汉 <lianyihan@360.cn>

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13041

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/smbd/process.c
source3/smbd/reply.c

index 11a5ae8314c5c2741b7b95ad323d432d181fc574..b5f528fc78ad8292dbd820b612cd693bfb3aa585 100644 (file)
@@ -1855,12 +1855,13 @@ void smb_request_done(struct smb_request *req)
 
                next->vuid = SVAL(req->outbuf, smb_uid);
                next->tid  = SVAL(req->outbuf, smb_tid);
-               status = smb1srv_tcon_lookup(req->xconn, req->tid,
+               status = smb1srv_tcon_lookup(req->xconn, next->tid,
                                             now, &tcon);
+
                if (NT_STATUS_IS_OK(status)) {
-                       req->conn = tcon->compat;
+                       next->conn = tcon->compat;
                } else {
-                       req->conn = NULL;
+                       next->conn = NULL;
                }
                next->chain_fsp = req->chain_fsp;
                next->inbuf = req->inbuf;
index 9c82ebff03fca6453a8e3920088742b330cb31d2..623f83b1250e787b4d363cd4382abe72f836913b 100644 (file)
@@ -923,6 +923,11 @@ void reply_tcon_and_X(struct smb_request *req)
                }
 
                TALLOC_FREE(tcon);
+               /*
+                * This tree id is gone. Make sure we can't re-use it
+                * by accident.
+                */
+               req->tid = 0;
        }
 
        if ((passlen > MAX_PASS_LEN) || (passlen >= req->buflen)) {