WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-4.0-testing] hvm: Handle extreme wallclock offsets

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-4.0-testing] hvm: Handle extreme wallclock offsets safely.
From: "Xen patchbot-4.0-testing" <patchbot-4.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 02 Jun 2010 02:45:16 -0700
Delivery-date: Wed, 02 Jun 2010 02:45:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1274858751 -3600
# Node ID 5fe5361d58dad7082b777cd29e7e58ea0358bca9
# Parent  12422806a0792ab7d74bd378f496059cae280589
hvm: Handle extreme wallclock offsets safely.

When a VM's wallclock offset is negative enough, gmtime() can be
called
with an underflowed uint64, which it then tries to divide into years
by subtraction.  Handle the input as a 40-bit signed integer instead.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
xen-unstable changeset:   21452:459f35d8cac4
xen-unstable date:        Wed May 26 07:59:52 2010 +0100
---
 xen/common/time.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletion(-)

diff -r 12422806a079 -r 5fe5361d58da xen/common/time.c
--- a/xen/common/time.c Wed May 26 08:17:31 2010 +0100
+++ b/xen/common/time.c Wed May 26 08:25:51 2010 +0100
@@ -42,6 +42,18 @@ struct tm gmtime(unsigned long t)
     int y;
     const unsigned short int *ip;
 
+    y = 1970;
+#ifdef __x86_64__
+    /* Allow the concept of time before 1970.  64-bit only; for 32-bit
+     * time after 2038 seems more important than time before 1970. */
+    while ( t & (1UL<<39) )
+    {
+        y -= 400;
+        t += ((unsigned long)(365 * 303 + 366 * 97)) * SECS_PER_DAY;
+    }
+    t &= (1UL << 40) - 1;
+#endif
+
     days = t / SECS_PER_DAY;
     rem = t % SECS_PER_DAY;
 
@@ -53,7 +65,6 @@ struct tm gmtime(unsigned long t)
     tbuf.tm_wday = (4 + days) % 7;
     if ( tbuf.tm_wday < 0 )
         tbuf.tm_wday += 7;
-    y = 1970;
     while ( days >= (rem = __isleap(y) ? 366 : 365) )
     {
         ++y;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-4.0-testing] hvm: Handle extreme wallclock offsets safely., Xen patchbot-4.0-testing <=