From patchwork Fri Aug 3 18:39:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Moore X-Patchwork-Id: 175038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0294A2C0089 for ; Sat, 4 Aug 2012 04:39:38 +1000 (EST) Received: from localhost ([::1]:43230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxMmd-0000qr-Lk for incoming@patchwork.ozlabs.org; Fri, 03 Aug 2012 14:39:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxMmU-0000kj-GL for qemu-devel@nongnu.org; Fri, 03 Aug 2012 14:39:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SxMmT-0005kG-3n for qemu-devel@nongnu.org; Fri, 03 Aug 2012 14:39:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SxMmS-0005jx-Rk for qemu-devel@nongnu.org; Fri, 03 Aug 2012 14:39:25 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q73IdNVD007812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 3 Aug 2012 14:39:23 -0400 Received: from [127.0.0.1] (vpn-11-111.rdu.redhat.com [10.11.11.111]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q73IdL4x031981; Fri, 3 Aug 2012 14:39:22 -0400 To: qemu-devel@nongnu.org From: Paul Moore Date: Fri, 03 Aug 2012 14:39:21 -0400 Message-ID: <20120803183920.4928.95381.stgit@sifl> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v5] vnc: disable VNC password authentication (security type 2) when in FIPS mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org FIPS 140-2 requires disabling certain ciphers, including DES, which is used by VNC to obscure passwords when they are sent over the network. The solution for FIPS users is to disable the use of VNC password auth when the host system is operating in FIPS compliance mode and the user has specified '-enable-fips' on the QEMU command line. This patch causes QEMU to emit a message to stderr when the host system is running in FIPS mode and a VNC password was specified on the commend line. If the system is not running in FIPS mode, or is running in FIPS mode but VNC password authentication was not requested, QEMU operates normally. Signed-off-by: Paul Moore --- Changelog * v5 - Added the '-enable-fips' command line option * v4 - Removed the use of syslog * v3 - Use fgetc() instead of fgets() in fips_enabled - Only emit a syslog message if the caller tries to use VNC password auth - Suggest alternative auth methods in the stderr notice * v2 - Protected syslog with _WIN32 - Protected the guts of fips_enabled() with __linux__ - Converted fips_enabled() and the fips flag from int to bool *v1 - Initial draft --- osdep.c | 29 +++++++++++++++++++++++++++++ osdep.h | 4 ++++ qemu-doc.texi | 8 +++++--- qemu-options.hx | 11 +++++++++++ ui/vnc.c | 10 ++++++++++ vl.c | 4 ++++ 6 files changed, 63 insertions(+), 3 deletions(-) diff --git a/osdep.c b/osdep.c index 03817f0..c07faf5 100644 --- a/osdep.c +++ b/osdep.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -48,6 +49,8 @@ extern int madvise(caddr_t, size_t, int); #include "trace.h" #include "qemu_socket.h" +static bool fips_enabled = false; + static const char *qemu_version = QEMU_VERSION; int socket_set_cork(int fd, int v) @@ -253,3 +256,29 @@ const char *qemu_get_version(void) { return qemu_version; } + +void fips_set_state(bool requested) +{ +#ifdef __linux__ + if (requested) { + FILE *fds = fopen("/proc/sys/crypto/fips_enabled", "r"); + if (fds != NULL) { + fips_enabled = (fgetc(fds) == '1'); + fclose(fds); + } + } +#else + fips_enabled = false; +#endif /* __linux__ */ + +#ifdef _FIPS_DEBUG + fprintf(stderr, "FIPS mode %s (requested %s)\n", + (fips_enabled ? "enabled" : "disabled"), + (requested ? "enabled" : "disabled")); +#endif +} + +bool fips_get_state(void) +{ + return fips_enabled; +} diff --git a/osdep.h b/osdep.h index 1e15a4b..d4b887d 100644 --- a/osdep.h +++ b/osdep.h @@ -3,6 +3,7 @@ #include #include +#include #ifdef __OpenBSD__ #include #include @@ -154,4 +155,7 @@ void qemu_set_cloexec(int fd); void qemu_set_version(const char *); const char *qemu_get_version(void); +void fips_set_state(bool requested); +bool fips_get_state(void); + #endif diff --git a/qemu-doc.texi b/qemu-doc.texi index 84dad19..f482fed 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -1124,9 +1124,11 @@ the protocol limits passwords to 8 characters it should not be considered to provide high security. The password can be fairly easily brute-forced by a client making repeat connections. For this reason, a VNC server using password authentication should be restricted to only listen on the loopback interface -or UNIX domain sockets. Password authentication is requested with the @code{password} -option, and then once QEMU is running the password is set with the monitor. Until -the monitor is used to set the password all clients will be rejected. +or UNIX domain sockets. Password authentication is not supported when operating +in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password +authentication is requested with the @code{password} option, and then once QEMU +is running the password is set with the monitor. Until the monitor is used to +set the password all clients will be rejected. @example qemu-system-i386 [...OPTIONS...] -vnc :1,password -monitor stdio diff --git a/qemu-options.hx b/qemu-options.hx index dc68e15..1f114ad 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2783,6 +2783,17 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "-qtest-log LOG specify tracing options\n", QEMU_ARCH_ALL) +#ifdef __linux__ +DEF("enable-fips", 0, QEMU_OPTION_enablefips, + "-enable-fips enable FIPS 140-2 compliance\n", + QEMU_ARCH_ALL) +#endif +STEXI +@item -enable-fips +@findex -enable-fips +Enable FIPS 140-2 compliance mode. +ETEXI + HXCOMM This is the last statement. Insert new options before this line! STEXI @end table diff --git a/ui/vnc.c b/ui/vnc.c index cfc61a7..312ad7f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -32,6 +32,7 @@ #include "acl.h" #include "qemu-objects.h" #include "qmp-commands.h" +#include "osdep.h" #define VNC_REFRESH_INTERVAL_BASE 30 #define VNC_REFRESH_INTERVAL_INC 50 @@ -2875,6 +2876,15 @@ int vnc_display_open(DisplayState *ds, const char *display) while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { + if (fips_get_state()) { + fprintf(stderr, + "VNC password auth disabled due to FIPS mode, " + "consider using the VeNCrypt or SASL authentication " + "methods as an alternative\n"); + g_free(vs->display); + vs->display = NULL; + return -1; + } password = 1; /* Require password auth */ } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; diff --git a/vl.c b/vl.c index 9fea320..c9bd7b7 100644 --- a/vl.c +++ b/vl.c @@ -159,6 +159,7 @@ int main(int argc, char **argv) #include "qemu-queue.h" #include "cpus.h" #include "arch_init.h" +#include "osdep.h" #include "ui/qemu-spice.h" @@ -3198,6 +3199,9 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_qtest_log: qtest_log = optarg; break; + case QEMU_OPTION_enablefips: + fips_set_state(true); + break; default: os_parse_cmd_args(popt->index, optarg); }