]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
set sshpam_ctxt to NULL after free
authorDamien Miller <djm@mindrot.org>
Tue, 11 Aug 2015 03:34:12 +0000 (13:34 +1000)
committerDamien Miller <djm@mindrot.org>
Tue, 11 Aug 2015 03:36:00 +0000 (13:36 +1000)
Avoids use-after-free in monitor when privsep child is compromised.
Reported by Moritz Jodeit; ok dtucker@

monitor.c

index f1b873dc4d7db3a59272dd64eccd83550731866c..a91420983ba86eda2619e629265897b3fefed53a 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1166,14 +1166,16 @@ mm_answer_pam_respond(int sock, Buffer *m)
 int
 mm_answer_pam_free_ctx(int sock, Buffer *m)
 {
+       int r = sshpam_authok != NULL && sshpam_authok == sshpam_ctxt;
 
        debug3("%s", __func__);
        (sshpam_device.free_ctx)(sshpam_ctxt);
+       sshpam_ctxt = sshpam_authok = NULL;
        buffer_clear(m);
        mm_request_send(sock, MONITOR_ANS_PAM_FREE_CTX, m);
        auth_method = "keyboard-interactive";
        auth_submethod = "pam";
-       return (sshpam_authok == sshpam_ctxt);
+       return r;
 }
 #endif