qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none".
@ 2016-08-03 15:35 Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 1/3] vnc: don't crash getting server info if lsock is NULL Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-08-03 15:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

vnc patch queue, with three patches fixing "-vnc none" with
connects via monitor fd passing.

cheers,
  Gerd

The following changes since commit cc0100f464c94bf80ad36cd432f4a1ed58126b60:

  MAINTAINERS: Update the Xilinx maintainers (2016-08-01 15:31:32 +0100)

are available in the git repository at:

  git://git.kraxel.org/qemu tags/pull-vnc-20160803-1

for you to fetch changes up to 12e29b1682e0a50ed57c324152addb585ae5ce69:

  vnc: ensure connection sharing/limits is always configured (2016-08-03 15:06:32 +0200)

----------------------------------------------------------------
vnc: fixes for "-vnc none".

----------------------------------------------------------------
Daniel P. Berrange (3):
      vnc: don't crash getting server info if lsock is NULL
      vnc: fix crash when vnc_server_info_get has an error
      vnc: ensure connection sharing/limits is always configured

 ui/vnc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 1/3] vnc: don't crash getting server info if lsock is NULL
  2016-08-03 15:35 [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Gerd Hoffmann
@ 2016-08-03 15:35 ` Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 2/3] vnc: fix crash when vnc_server_info_get has an error Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-08-03 15:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrange, Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

When VNC is started with '-vnc none' there will be no
listener socket present. When we try to populate the
VncServerInfo we'll crash accessing a NULL 'lsock'
field.

 #0  qio_channel_socket_get_local_address (ioc=0x0, errp=errp@entry=0x7ffd5b8aa0f0) at io/channel-socket.c:33
 #1  0x00007f4b9a297d6f in vnc_init_basic_info_from_server_addr (errp=0x7ffd5b8aa0f0, info=0x7f4b9d425460, ioc=<optimized out>)  at ui/vnc.c:146
 #2  vnc_server_info_get (vd=0x7f4b9e858000) at ui/vnc.c:223
 #3  0x00007f4b9a29d318 in vnc_qmp_event (vs=0x7f4b9ef82000, vs=0x7f4b9ef82000, event=QAPI_EVENT_VNC_CONNECTED) at ui/vnc.c:279
 #4  vnc_connect (vd=vd@entry=0x7f4b9e858000, sioc=sioc@entry=0x7f4b9e8b3a20, skipauth=skipauth@entry=true, websocket=websocket @entry=false) at ui/vnc.c:2994
 #5  0x00007f4b9a29e8c8 in vnc_display_add_client (id=<optimized out>, csock=<optimized out>, skipauth=<optimized out>) at ui/v nc.c:3825
 #6  0x00007f4b9a18d8a1 in qmp_marshal_add_client (args=<optimized out>, ret=<optimized out>, errp=0x7ffd5b8aa230) at qmp-marsh al.c:123
 #7  0x00007f4b9a0b53f5 in handle_qmp_command (parser=<optimized out>, tokens=<optimized out>) at /usr/src/debug/qemu-2.6.0/mon itor.c:3922
 #8  0x00007f4b9a348580 in json_message_process_token (lexer=0x7f4b9c78dfe8, input=0x7f4b9c7350e0, type=JSON_RCURLY, x=111, y=5 9) at qobject/json-streamer.c:94
 #9  0x00007f4b9a35cfeb in json_lexer_feed_char (lexer=lexer@entry=0x7f4b9c78dfe8, ch=125 '}', flush=flush@entry=false) at qobj ect/json-lexer.c:310
 #10 0x00007f4b9a35d0ae in json_lexer_feed (lexer=0x7f4b9c78dfe8, buffer=<optimized out>, size=<optimized out>) at qobject/json -lexer.c:360
 #11 0x00007f4b9a348679 in json_message_parser_feed (parser=<optimized out>, buffer=<optimized out>, size=<optimized out>) at q object/json-streamer.c:114
 #12 0x00007f4b9a0b3a1b in monitor_qmp_read (opaque=<optimized out>, buf=<optimized out>, size=<optimized out>) at /usr/src/deb ug/qemu-2.6.0/monitor.c:3938
 #13 0x00007f4b9a186751 in tcp_chr_read (chan=<optimized out>, cond=<optimized out>, opaque=0x7f4b9c7add40) at qemu-char.c:2895
 #14 0x00007f4b92b5c79a in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
 #15 0x00007f4b9a2bb0c0 in glib_pollfds_poll () at main-loop.c:213
 #16 os_host_main_loop_wait (timeout=<optimized out>) at main-loop.c:258
 #17 main_loop_wait (nonblocking=<optimized out>) at main-loop.c:506
 #18 0x00007f4b9a0835cf in main_loop () at vl.c:1934
 #19 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4667

Do an upfront check for a NULL lsock and report an error to
the caller, which matches behaviour from before

  commit 04d2529da27db512dcbd5e99d0e26d333f16efcc
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Fri Feb 27 16:20:57 2015 +0000

    ui: convert VNC server to use QIOChannelSocket

where getsockname() would be given a FD value -1 and thus report
an error to the caller.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1470134726-15697-2-git-send-email-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index 3ce3a5b..f183d00 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -143,6 +143,11 @@ static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
 {
     SocketAddress *addr = NULL;
 
+    if (!ioc) {
+        error_setg(errp, "No listener socket available");
+        return;
+    }
+
     addr = qio_channel_socket_get_local_address(ioc, errp);
     if (!addr) {
         return;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 2/3] vnc: fix crash when vnc_server_info_get has an error
  2016-08-03 15:35 [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 1/3] vnc: don't crash getting server info if lsock is NULL Gerd Hoffmann
@ 2016-08-03 15:35 ` Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 3/3] vnc: ensure connection sharing/limits is always configured Gerd Hoffmann
  2016-08-04  9:24 ` [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-08-03 15:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrange, Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

The vnc_server_info_get will allocate the VncServerInfo
struct and then call vnc_init_basic_info_from_server_addr
to populate the basic fields. If this returns an error
though, the qapi_free_VncServerInfo call will then crash
because the VncServerInfo struct instance was not properly
NULL-initialized and thus contains random stack garbage.

 #0  0x00007f1987c8e6f5 in raise () at /lib64/libc.so.6
 #1  0x00007f1987c902fa in abort () at /lib64/libc.so.6
 #2  0x00007f1987ccf600 in __libc_message () at /lib64/libc.so.6
 #3  0x00007f1987cd7d4a in _int_free () at /lib64/libc.so.6
 #4  0x00007f1987cdb2ac in free () at /lib64/libc.so.6
 #5  0x00007f198b654f6e in g_free () at /lib64/libglib-2.0.so.0
 #6  0x0000559193cdcf54 in visit_type_str (v=v@entry=
     0x5591972f14b0, name=name@entry=0x559193de1e29 "host", obj=obj@entry=0x5591961dbfa0, errp=errp@entry=0x7fffd7899d80)
     at qapi/qapi-visit-core.c:255
 #7  0x0000559193cca8f3 in visit_type_VncBasicInfo_members (v=v@entry=
     0x5591972f14b0, obj=obj@entry=0x5591961dbfa0, errp=errp@entry=0x7fffd7899dc0) at qapi-visit.c:12307
 #8  0x0000559193ccb523 in visit_type_VncServerInfo_members (v=v@entry=
     0x5591972f14b0, obj=0x5591961dbfa0, errp=errp@entry=0x7fffd7899e00) at qapi-visit.c:12632
 #9  0x0000559193ccb60b in visit_type_VncServerInfo (v=v@entry=
     0x5591972f14b0, name=name@entry=0x0, obj=obj@entry=0x7fffd7899e48, errp=errp@entry=0x0) at qapi-visit.c:12658
 #10 0x0000559193cb53d8 in qapi_free_VncServerInfo (obj=<optimized out>) at qapi-types.c:3970
 #11 0x0000559193c1e6ba in vnc_server_info_get (vd=0x7f1951498010) at ui/vnc.c:233
 #12 0x0000559193c24275 in vnc_connect (vs=0x559197b2f200, vs=0x559197b2f200, event=QAPI_EVENT_VNC_CONNECTED) at ui/vnc.c:284
 #13 0x0000559193c24275 in vnc_connect (vd=vd@entry=0x7f1951498010, sioc=sioc@entry=0x559196bf9c00, skipauth=skipauth@entry=tru e, websocket=websocket@entry=false) at ui/vnc.c:3039
 #14 0x0000559193c25806 in vnc_display_add_client (id=<optimized out>, csock=<optimized out>, skipauth=<optimized out>)
     at ui/vnc.c:3877
 #15 0x0000559193a90c28 in qmp_marshal_add_client (args=<optimized out>, ret=<optimized out>, errp=0x7fffd7899f90)
     at qmp-marshal.c:105
 #16 0x000055919399c2b7 in handle_qmp_command (parser=<optimized out>, tokens=<optimized out>)
     at /home/berrange/src/virt/qemu/monitor.c:3971
 #17 0x0000559193ce3307 in json_message_process_token (lexer=0x559194ab0838, input=0x559194a6d940, type=JSON_RCURLY, x=111, y=1 2) at qobject/json-streamer.c:105
 #18 0x0000559193cfa90d in json_lexer_feed_char (lexer=lexer@entry=0x559194ab0838, ch=125 '}', flush=flush@entry=false)
     at qobject/json-lexer.c:319
 #19 0x0000559193cfaa1e in json_lexer_feed (lexer=0x559194ab0838, buffer=<optimized out>, size=<optimized out>)
     at qobject/json-lexer.c:369
 #20 0x0000559193ce33c9 in json_message_parser_feed (parser=<optimized out>, buffer=<optimized out>, size=<optimized out>)
     at qobject/json-streamer.c:124
 #21 0x000055919399a85b in monitor_qmp_read (opaque=<optimized out>, buf=<optimized out>, size=<optimized out>)
     at /home/berrange/src/virt/qemu/monitor.c:3987
 #22 0x0000559193a87d00 in tcp_chr_read (chan=<optimized out>, cond=<optimized out>, opaque=0x559194a7d900)
     at qemu-char.c:2895
 #23 0x00007f198b64f703 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
 #24 0x0000559193c484b3 in main_loop_wait () at main-loop.c:213
 #25 0x0000559193c484b3 in main_loop_wait (timeout=<optimized out>) at main-loop.c:258
 #26 0x0000559193c484b3 in main_loop_wait (nonblocking=<optimized out>) at main-loop.c:506
 #27 0x0000559193964c55 in main () at vl.c:1908
 #28 0x0000559193964c55 in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4603

This was introduced in

  commit 98481bfcd661daa3c160cc87a297b0e60a307788
  Author: Eric Blake <eblake@redhat.com>
  Date:   Mon Oct 26 16:34:45 2015 -0600

    vnc: Hoist allocation of VncBasicInfo to callers

which added error reporting for vnc_init_basic_info_from_server_addr
but didn't change the g_malloc calls to g_malloc0.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1470134726-15697-3-git-send-email-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index f183d00..f2f5dc1 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -224,7 +224,7 @@ static VncServerInfo *vnc_server_info_get(VncDisplay *vd)
     VncServerInfo *info;
     Error *err = NULL;
 
-    info = g_malloc(sizeof(*info));
+    info = g_malloc0(sizeof(*info));
     vnc_init_basic_info_from_server_addr(vd->lsock,
                                          qapi_VncServerInfo_base(info), &err);
     info->has_auth = true;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PULL 3/3] vnc: ensure connection sharing/limits is always configured
  2016-08-03 15:35 [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 1/3] vnc: don't crash getting server info if lsock is NULL Gerd Hoffmann
  2016-08-03 15:35 ` [Qemu-devel] [PULL 2/3] vnc: fix crash when vnc_server_info_get has an error Gerd Hoffmann
@ 2016-08-03 15:35 ` Gerd Hoffmann
  2016-08-04  9:24 ` [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Gerd Hoffmann @ 2016-08-03 15:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Daniel P. Berrange, Gerd Hoffmann

From: "Daniel P. Berrange" <berrange@redhat.com>

The connection sharing / limits are only set in the
vnc_display_open() method and so missed when VNC is running
with '-vnc none'. This in turn prevents clients being added
to the VNC server with the QMP "add_client" command.

This was introduced in

  commit e5f34cdd2da54f28d90889a3afd15fad2d6105ff
  Author: Gerd Hoffmann <kraxel@redhat.com>
  Date:   Thu Oct 2 12:09:34 2014 +0200

      vnc: track & limit connections

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1470134726-15697-4-git-send-email-berrange@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index f2f5dc1..4ce9034 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3150,6 +3150,9 @@ void vnc_display_init(const char *id)
     if (!vs->kbd_layout)
         exit(1);
 
+    vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
+    vs->connections_limit = 32;
+
     qemu_mutex_init(&vs->mutex);
     vnc_start_worker_thread();
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none".
  2016-08-03 15:35 [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2016-08-03 15:35 ` [Qemu-devel] [PULL 3/3] vnc: ensure connection sharing/limits is always configured Gerd Hoffmann
@ 2016-08-04  9:24 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2016-08-04  9:24 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 3 August 2016 at 16:35, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> vnc patch queue, with three patches fixing "-vnc none" with
> connects via monitor fd passing.
>
> cheers,
>   Gerd
>
> The following changes since commit cc0100f464c94bf80ad36cd432f4a1ed58126b60:
>
>   MAINTAINERS: Update the Xilinx maintainers (2016-08-01 15:31:32 +0100)
>
> are available in the git repository at:
>
>   git://git.kraxel.org/qemu tags/pull-vnc-20160803-1
>
> for you to fetch changes up to 12e29b1682e0a50ed57c324152addb585ae5ce69:
>
>   vnc: ensure connection sharing/limits is always configured (2016-08-03 15:06:32 +0200)
>
> ----------------------------------------------------------------
> vnc: fixes for "-vnc none".
>
> ----------------------------------------------------------------
> Daniel P. Berrange (3):
>       vnc: don't crash getting server info if lsock is NULL
>       vnc: fix crash when vnc_server_info_get has an error
>       vnc: ensure connection sharing/limits is always configured

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-04  9:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03 15:35 [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Gerd Hoffmann
2016-08-03 15:35 ` [Qemu-devel] [PULL 1/3] vnc: don't crash getting server info if lsock is NULL Gerd Hoffmann
2016-08-03 15:35 ` [Qemu-devel] [PULL 2/3] vnc: fix crash when vnc_server_info_get has an error Gerd Hoffmann
2016-08-03 15:35 ` [Qemu-devel] [PULL 3/3] vnc: ensure connection sharing/limits is always configured Gerd Hoffmann
2016-08-04  9:24 ` [Qemu-devel] [PULL for-2.7 0/3] vnc: fixes for "-vnc none" Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).