qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
@ 2013-12-11 15:54 Gerd Hoffmann
  2013-12-11 16:06 ` Paolo Bonzini
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2013-12-11 15:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Current code silently changes the authentication settings
in case you try to set a password without password authentication
turned on.  This is bad.  Return an error instead.

If we want allow changing auth settings at runtime this should
be done explicitly using a separate monitor command, not as
side effect of set_passwd.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 5601cc3..79efb80 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2971,26 +2971,6 @@ static void vnc_display_close(DisplayState *ds)
 #endif
 }
 
-static int vnc_display_disable_login(DisplayState *ds)
-{
-    VncDisplay *vs = vnc_display;
-
-    if (!vs) {
-        return -1;
-    }
-
-    if (vs->password) {
-        g_free(vs->password);
-    }
-
-    vs->password = NULL;
-    if (vs->auth == VNC_AUTH_NONE) {
-        vs->auth = VNC_AUTH_VNC;
-    }
-
-    return 0;
-}
-
 int vnc_display_password(DisplayState *ds, const char *password)
 {
     VncDisplay *vs = vnc_display;
@@ -2998,20 +2978,18 @@ int vnc_display_password(DisplayState *ds, const char *password)
     if (!vs) {
         return -EINVAL;
     }
-
-    if (!password) {
-        /* This is not the intention of this interface but err on the side
-           of being safe */
-        return vnc_display_disable_login(ds);
+    if (vs->auth == VNC_AUTH_NONE) {
+        error_printf_unless_qmp("If you want use passwords please enable "
+                                "password auth using '-vnc ${dpy},password'.");
+        return -EINVAL;
     }
 
     if (vs->password) {
         g_free(vs->password);
         vs->password = NULL;
     }
-    vs->password = g_strdup(password);
-    if (vs->auth == VNC_AUTH_NONE) {
-        vs->auth = VNC_AUTH_VNC;
+    if (password) {
+        vs->password = g_strdup(password);
     }
 
     return 0;
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2013-12-11 15:54 [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE Gerd Hoffmann
@ 2013-12-11 16:06 ` Paolo Bonzini
  2013-12-11 16:29   ` Gerd Hoffmann
  0 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2013-12-11 16:06 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Anthony Liguori

Il 11/12/2013 16:54, Gerd Hoffmann ha scritto:
> Current code silently changes the authentication settings
> in case you try to set a password without password authentication
> turned on.  This is bad.  Return an error instead.
> 
> If we want allow changing auth settings at runtime this should
> be done explicitly using a separate monitor command, not as
> side effect of set_passwd.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Isn't this backwards-incompatible?

Paolo

> ---
>  ui/vnc.c | 34 ++++++----------------------------
>  1 file changed, 6 insertions(+), 28 deletions(-)
> 
> diff --git a/ui/vnc.c b/ui/vnc.c
> index 5601cc3..79efb80 100644
> --- a/ui/vnc.c
> +++ b/ui/vnc.c
> @@ -2971,26 +2971,6 @@ static void vnc_display_close(DisplayState *ds)
>  #endif
>  }
>  
> -static int vnc_display_disable_login(DisplayState *ds)
> -{
> -    VncDisplay *vs = vnc_display;
> -
> -    if (!vs) {
> -        return -1;
> -    }
> -
> -    if (vs->password) {
> -        g_free(vs->password);
> -    }
> -
> -    vs->password = NULL;
> -    if (vs->auth == VNC_AUTH_NONE) {
> -        vs->auth = VNC_AUTH_VNC;
> -    }
> -
> -    return 0;
> -}
> -
>  int vnc_display_password(DisplayState *ds, const char *password)
>  {
>      VncDisplay *vs = vnc_display;
> @@ -2998,20 +2978,18 @@ int vnc_display_password(DisplayState *ds, const char *password)
>      if (!vs) {
>          return -EINVAL;
>      }
> -
> -    if (!password) {
> -        /* This is not the intention of this interface but err on the side
> -           of being safe */
> -        return vnc_display_disable_login(ds);
> +    if (vs->auth == VNC_AUTH_NONE) {
> +        error_printf_unless_qmp("If you want use passwords please enable "
> +                                "password auth using '-vnc ${dpy},password'.");
> +        return -EINVAL;
>      }
>  
>      if (vs->password) {
>          g_free(vs->password);
>          vs->password = NULL;
>      }
> -    vs->password = g_strdup(password);
> -    if (vs->auth == VNC_AUTH_NONE) {
> -        vs->auth = VNC_AUTH_VNC;
> +    if (password) {
> +        vs->password = g_strdup(password);
>      }
>  
>      return 0;
> 

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2013-12-11 16:06 ` Paolo Bonzini
@ 2013-12-11 16:29   ` Gerd Hoffmann
  2013-12-11 16:43     ` Paolo Bonzini
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2013-12-11 16:29 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Anthony Liguori

On Mi, 2013-12-11 at 17:06 +0100, Paolo Bonzini wrote:
> Il 11/12/2013 16:54, Gerd Hoffmann ha scritto:
> > Current code silently changes the authentication settings
> > in case you try to set a password without password authentication
> > turned on.  This is bad.  Return an error instead.
> > 
> > If we want allow changing auth settings at runtime this should
> > be done explicitly using a separate monitor command, not as
> > side effect of set_passwd.
> > 
> > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> 
> Isn't this backwards-incompatible?

Yes.  I think it is the correct thing nevertheless.

Users which want a passwort protected guests should configure vnc
correctly to avoid a unprotected window between qemu start and setting
the password.

Also note that enabling passwd auth via "set_passwd" side-effect
bypasses fips restrictions.

So this is a clear security improvement IMHO.

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2013-12-11 16:29   ` Gerd Hoffmann
@ 2013-12-11 16:43     ` Paolo Bonzini
  2013-12-12 12:44       ` Gerd Hoffmann
  0 siblings, 1 reply; 8+ messages in thread
From: Paolo Bonzini @ 2013-12-11 16:43 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: qemu-devel, Anthony Liguori

Il 11/12/2013 17:29, Gerd Hoffmann ha scritto:
> On Mi, 2013-12-11 at 17:06 +0100, Paolo Bonzini wrote:
>> Il 11/12/2013 16:54, Gerd Hoffmann ha scritto:
>>> Current code silently changes the authentication settings
>>> in case you try to set a password without password authentication
>>> turned on.  This is bad.  Return an error instead.
>>>
>>> If we want allow changing auth settings at runtime this should
>>> be done explicitly using a separate monitor command, not as
>>> side effect of set_passwd.
>>>
>>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>>
>> Isn't this backwards-incompatible?
> 
> Yes.  I think it is the correct thing nevertheless.

Fine by me, let's just make sure we document it well.  Can you start the
2.0 changelog wiki page?

> Users which want a passwort protected guests should configure vnc
> correctly to avoid a unprotected window between qemu start and setting
> the password.
> 
> Also note that enabling passwd auth via "set_passwd" side-effect
> bypasses fips restrictions.

That'd be a clear bug, even one that could be fixed in stable versions.

Paolo

> So this is a clear security improvement IMHO.
> 
> cheers,
>   Gerd
> 
> 
> 

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2013-12-11 16:43     ` Paolo Bonzini
@ 2013-12-12 12:44       ` Gerd Hoffmann
  0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2013-12-12 12:44 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Anthony Liguori

  Hi,

> >>
> >> Isn't this backwards-incompatible?
> > 
> > Yes.  I think it is the correct thing nevertheless.
> 
> Fine by me, let's just make sure we document it well.  Can you start the
> 2.0 changelog wiki page?

-ENOACCOUNT

Anthony?  Can you add me?  uid kraxel please.

cheers,
  Gerd

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

* [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
@ 2014-05-21 10:54 Gerd Hoffmann
  2014-05-22  4:05 ` Gonglei (Arei)
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2014-05-21 10:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Anthony Liguori

Current code silently changes the authentication settings
in case you try to set a password without password authentication
turned on.  This is bad.  Return an error instead.

If we want allow changing auth settings at runtime this should
be done explicitly using a separate monitor command, not as
side effect of set_passwd.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index 2d7def9..64aa2fa 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -2976,26 +2976,6 @@ static void vnc_display_close(DisplayState *ds)
 #endif
 }
 
-static int vnc_display_disable_login(DisplayState *ds)
-{
-    VncDisplay *vs = vnc_display;
-
-    if (!vs) {
-        return -1;
-    }
-
-    if (vs->password) {
-        g_free(vs->password);
-    }
-
-    vs->password = NULL;
-    if (vs->auth == VNC_AUTH_NONE) {
-        vs->auth = VNC_AUTH_VNC;
-    }
-
-    return 0;
-}
-
 int vnc_display_password(DisplayState *ds, const char *password)
 {
     VncDisplay *vs = vnc_display;
@@ -3003,20 +2983,18 @@ int vnc_display_password(DisplayState *ds, const char *password)
     if (!vs) {
         return -EINVAL;
     }
-
-    if (!password) {
-        /* This is not the intention of this interface but err on the side
-           of being safe */
-        return vnc_display_disable_login(ds);
+    if (vs->auth == VNC_AUTH_NONE) {
+        error_printf_unless_qmp("If you want use passwords please enable "
+                                "password auth using '-vnc ${dpy},password'.");
+        return -EINVAL;
     }
 
     if (vs->password) {
         g_free(vs->password);
         vs->password = NULL;
     }
-    vs->password = g_strdup(password);
-    if (vs->auth == VNC_AUTH_NONE) {
-        vs->auth = VNC_AUTH_VNC;
+    if (password) {
+        vs->password = g_strdup(password);
     }
 
     return 0;
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2014-05-21 10:54 Gerd Hoffmann
@ 2014-05-22  4:05 ` Gonglei (Arei)
  2014-05-22  5:47   ` Gerd Hoffmann
  0 siblings, 1 reply; 8+ messages in thread
From: Gonglei (Arei) @ 2014-05-22  4:05 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel@nongnu.org; +Cc: Anthony Liguori

> -----Original Message-----
> From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
> [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
> Behalf Of Gerd Hoffmann
> Sent: Wednesday, May 21, 2014 6:54 PM
> To: qemu-devel@nongnu.org
> Cc: Gerd Hoffmann; Anthony Liguori
> Subject: [Qemu-devel] [PATCH] vnc: refuse to set a password with
> VNC_AUTH_NONE
> 
> Current code silently changes the authentication settings
> in case you try to set a password without password authentication
> turned on.  This is bad.  Return an error instead.
> 
> If we want allow changing auth settings at runtime this should
> be done explicitly using a separate monitor command, not as
> side effect of set_passwd.
> 
Agreed. Do you have a plan to do this? Thanks.

> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  ui/vnc.c | 34 ++++++----------------------------
>  1 file changed, 6 insertions(+), 28 deletions(-)
> 

Reviewed-by: Gonglei <arei.gonglei@huawei.com>


Best regards,
-Gonglei

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

* Re: [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE
  2014-05-22  4:05 ` Gonglei (Arei)
@ 2014-05-22  5:47   ` Gerd Hoffmann
  0 siblings, 0 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2014-05-22  5:47 UTC (permalink / raw)
  To: Gonglei (Arei); +Cc: qemu-devel@nongnu.org, Anthony Liguori

On Do, 2014-05-22 at 04:05 +0000, Gonglei (Arei) wrote:
> > -----Original Message-----
> > From: qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org
> > [mailto:qemu-devel-bounces+arei.gonglei=huawei.com@nongnu.org] On
> > Behalf Of Gerd Hoffmann
> > Sent: Wednesday, May 21, 2014 6:54 PM
> > To: qemu-devel@nongnu.org
> > Cc: Gerd Hoffmann; Anthony Liguori
> > Subject: [Qemu-devel] [PATCH] vnc: refuse to set a password with
> > VNC_AUTH_NONE
> > 
> > Current code silently changes the authentication settings
> > in case you try to set a password without password authentication
> > turned on.  This is bad.  Return an error instead.
> > 
> > If we want allow changing auth settings at runtime this should
> > be done explicitly using a separate monitor command, not as
> > side effect of set_passwd.
> > 
> Agreed. Do you have a plan to do this? Thanks.

No, unless someone comes up with a reasonable use case for this.

cheers,
  Gerd

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

end of thread, other threads:[~2014-05-22  5:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 15:54 [Qemu-devel] [PATCH] vnc: refuse to set a password with VNC_AUTH_NONE Gerd Hoffmann
2013-12-11 16:06 ` Paolo Bonzini
2013-12-11 16:29   ` Gerd Hoffmann
2013-12-11 16:43     ` Paolo Bonzini
2013-12-12 12:44       ` Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2014-05-21 10:54 Gerd Hoffmann
2014-05-22  4:05 ` Gonglei (Arei)
2014-05-22  5:47   ` Gerd Hoffmann

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).