Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=74609f4536f2b8fd6a48381bbbe3cd37da20a527
Commit:     74609f4536f2b8fd6a48381bbbe3cd37da20a527
Parent:     ca74c013441200b162f6a384b23b833d1865a9e8
Author:     Tony Breeds <[EMAIL PROTECTED]>
AuthorDate: Tue Jun 26 09:50:32 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Tue Jun 26 14:41:19 2007 +1000

    [POWERPC] Fix VDSO gettimeofday() when called with NULL struct timeval
    
    Consider the prototype for gettimeofday():
        int gettimofday(struct timeval *tv, struct timezone *tz);
    
    Although it is valid to call with /either/ tv or tz being NULL, and
    the C version of sys_gettimeofday() supports this, the current version
    of gettimeofday() in the VDSO will SEGV if called with a NULL tv.
    
    This adds a check for tv being NULL so that it doesn't SEGV.
    
    Signed-off-by: Tony Breeds <[EMAIL PROTECTED]>
    Acked-by: Benjamin Herrenschmidt <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/vdso32/gettimeofday.S |    4 +++-
 arch/powerpc/kernel/vdso64/gettimeofday.S |    7 ++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S 
b/arch/powerpc/kernel/vdso32/gettimeofday.S
index 05909f7..72ca26d 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -32,6 +32,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
        mr      r11,r4                  /* r11 saves tz */
        bl      [EMAIL PROTECTED]       /* get data page */
        mr      r9, r3                  /* datapage ptr in r9 */
+       cmplwi  r10,0                   /* check if tv is NULL */
+       beq     3f
        bl      [EMAIL PROTECTED]       /* get xsec from tb & kernel */
        bne-    2f                      /* out of line -> do syscall */
 
@@ -50,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
        mulhwu  r5,r5,r6
        stw     r5,TVAL32_TV_USEC(r10)
 
-       cmpli   cr0,r11,0               /* check if tz is NULL */
+3:     cmplwi  r11,0                   /* check if tz is NULL */
        beq     1f
        lwz     r4,CFG_TZ_MINUTEWEST(r9)/* fill tz */
        lwz     r5,CFG_TZ_DSTTIME(r9)
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S 
b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 40ffd9b..2d7a510 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -1,5 +1,4 @@
-
-       /*
+/*
  * Userland implementation of gettimeofday() for 64 bits processes in a
  * ppc64 kernel for use in the vDSO
  *
@@ -32,6 +31,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
        mr      r11,r3                  /* r11 holds tv */
        mr      r10,r4                  /* r10 holds tz */
        bl      V_LOCAL_FUNC(__get_datapage)    /* get data page */
+       cmpldi  r10,0                   /* check if tv is NULL */
+       beq     2f
        bl      V_LOCAL_FUNC(__do_get_xsec)     /* get xsec from tb & kernel */
        lis     r7,15                   /* r7 = 1000000 = USEC_PER_SEC */
        ori     r7,r7,16960
@@ -43,8 +44,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
                                         * XSEC_PER_SEC
                                         */
        rldicl  r0,r0,44,20
-       cmpldi  cr0,r10,0               /* check if tz is NULL */
        std     r0,TVAL64_TV_USEC(r11)  /* store usec in tv */
+2:     cmpldi  r10,0                   /* check if tz is NULL */
        beq     1f
        lwz     r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */
        lwz     r5,CFG_TZ_DSTTIME(r3)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to