Skip to contentSkip to conversation

vnc: clear vs->tlscreds after unparenting it

PATCH In review Wolfgang Bumiller 3 participants 4 messages Jan 12, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vnc: clear vs->tlscreds after unparenting it

This pointer should be cleared in vnc_display_close() otherwise a use-after-free can happen when when using the old style 'x509' and 'tls' options rather than a persistent tls-creds -object, by issuing monitor commands to change the vnc server like so:

Start with: -vnc unix:test.socket,x509,tls
Then use the following monitor command:
change vnc unix:test.socket

After this the pointer is still set but invalid and a crash can be triggered for instance by issuing the same command a second time which will try to object_unparent() the same pointer again.

---
 ui/vnc.c | 1 +
 1 file changed, 1 insertion(+)
ui/vnc.c +1 -0
index 09756cd..35843b5 100644
@@ -3134,6 +3134,7 @@ static void vnc_display_close(VncDisplay *vs)
     vs->subauth = VNC_AUTH_INVALID;
     if (vs->tlscreds) {
         object_unparent(OBJECT(vs->tlscreds));
+        vs->tlscreds = NULL;
     }
     g_free(vs->tlsaclname);
     vs->tlsaclname = NULL;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Wolfgang Bumiller

This pointer should be cleared in vnc_display_close() otherwise a use-after-free can happen when when using the old style 'x509' and 'tls' options rather than a persistent tls-creds -object, by issuing monitor commands to change the vnc server like so:

Start with: -vnc unix:test.socket,x509,tls
Then use the following monitor command:
change vnc unix:test.socket

After this the pointer is still set but invalid and a crash can be triggered for instance by issuing the same command a second time which will try to object_unparent() the same pointer again.

---
 ui/vnc.c | 1 +
 1 file changed, 1 insertion(+)
ui/vnc.c +0 -0
index 09756cd..35843b5 100644

ui/vnc.c static void vnc_display_close(VncDisplay *vs) · line 3140

Quoted 7 lines
ui/vnc.c +1 -0
@@ -3134,6 +3134,7 @@ static void vnc_display_close(VncDisplay *vs)
     vs->subauth = VNC_AUTH_INVALID;
     if (vs->tlscreds) {
         object_unparent(OBJECT(vs->tlscreds));
+        vs->tlscreds = NULL;
     }
     g_free(vs->tlsaclname);
     vs->tlsaclname = NULL;

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#2 lore raw
In reply to Wolfgang Bumiller

Ah I forgot to --signoff, sorry

Quoted 9 lines · Wolfgang Bumiller

This pointer should be cleared in vnc_display_close() otherwise a use-after-free can happen when when using the old style 'x509' and 'tls' options rather than a persistent tls-creds -object, by issuing monitor commands to change the vnc server like so:

Quoted 8 lines

Start with: -vnc unix:test.socket,x509,tls
Then use the following monitor command:
change vnc unix:test.socket

After this the pointer is still set but invalid and a crash can be triggered for instance by issuing the same command a second time which will try to object_unparent() the same pointer again.

Quoted 18 lines
---
 ui/vnc.c | 1 +
 1 file changed, 1 insertion(+)
ui/vnc.c +1 -0
index 09756cd..35843b5 100644
@@ -3134,6 +3134,7 @@ static void vnc_display_close(VncDisplay *vs)
     vs->subauth = VNC_AUTH_INVALID;
     if (vs->tlscreds) {
         object_unparent(OBJECT(vs->tlscreds));
+        vs->tlscreds = NULL;
     }
     g_free(vs->tlsaclname);
     vs->tlsaclname = NULL;
Signature · 1 line
2.1.4
#3 lore raw
In reply to Wolfgang Bumiller
Quoted 6 lines · Wolfgang Bumiller

This pointer should be cleared in vnc_display_close() otherwise a use-after-free can happen when when using the old style 'x509' and 'tls' options rather than a persistent tls-creds -object, by issuing monitor commands to change the vnc server like so:

Quoted 8 lines

Start with: -vnc unix:test.socket,x509,tls
Then use the following monitor command:
change vnc unix:test.socket

After this the pointer is still set but invalid and a crash can be triggered for instance by issuing the same command a second time which will try to object_unparent() the same pointer again.

Added to patch queue.

thanks,
Gerd