aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTony Breeds <tony@bakeyournoodle.com>2007-06-25 19:50:32 -0400
committerPaul Mackerras <paulus@samba.org>2007-06-26 00:41:19 -0400
commit74609f4536f2b8fd6a48381bbbe3cd37da20a527 (patch)
treef73c0abf05df85497b0323290e6cfff948a7fadd /arch
parentca74c013441200b162f6a384b23b833d1865a9e8 (diff)
[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 <tony@bakeyournoodle.com> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/kernel/vdso32/gettimeofday.S4
-rw-r--r--arch/powerpc/kernel/vdso64/gettimeofday.S7
2 files changed, 7 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
index 05909f754307..72ca26df457e 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -32,6 +32,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
32 mr r11,r4 /* r11 saves tz */ 32 mr r11,r4 /* r11 saves tz */
33 bl __get_datapage@local /* get data page */ 33 bl __get_datapage@local /* get data page */
34 mr r9, r3 /* datapage ptr in r9 */ 34 mr r9, r3 /* datapage ptr in r9 */
35 cmplwi r10,0 /* check if tv is NULL */
36 beq 3f
35 bl __do_get_xsec@local /* get xsec from tb & kernel */ 37 bl __do_get_xsec@local /* get xsec from tb & kernel */
36 bne- 2f /* out of line -> do syscall */ 38 bne- 2f /* out of line -> do syscall */
37 39
@@ -50,7 +52,7 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
50 mulhwu r5,r5,r6 52 mulhwu r5,r5,r6
51 stw r5,TVAL32_TV_USEC(r10) 53 stw r5,TVAL32_TV_USEC(r10)
52 54
53 cmpli cr0,r11,0 /* check if tz is NULL */ 553: cmplwi r11,0 /* check if tz is NULL */
54 beq 1f 56 beq 1f
55 lwz r4,CFG_TZ_MINUTEWEST(r9)/* fill tz */ 57 lwz r4,CFG_TZ_MINUTEWEST(r9)/* fill tz */
56 lwz r5,CFG_TZ_DSTTIME(r9) 58 lwz r5,CFG_TZ_DSTTIME(r9)
diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S
index 40ffd9b6cef7..2d7a5104c666 100644
--- a/arch/powerpc/kernel/vdso64/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso64/gettimeofday.S
@@ -1,5 +1,4 @@
1 1/*
2 /*
3 * Userland implementation of gettimeofday() for 64 bits processes in a 2 * Userland implementation of gettimeofday() for 64 bits processes in a
4 * ppc64 kernel for use in the vDSO 3 * ppc64 kernel for use in the vDSO
5 * 4 *
@@ -32,6 +31,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
32 mr r11,r3 /* r11 holds tv */ 31 mr r11,r3 /* r11 holds tv */
33 mr r10,r4 /* r10 holds tz */ 32 mr r10,r4 /* r10 holds tz */
34 bl V_LOCAL_FUNC(__get_datapage) /* get data page */ 33 bl V_LOCAL_FUNC(__get_datapage) /* get data page */
34 cmpldi r10,0 /* check if tv is NULL */
35 beq 2f
35 bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */ 36 bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */
36 lis r7,15 /* r7 = 1000000 = USEC_PER_SEC */ 37 lis r7,15 /* r7 = 1000000 = USEC_PER_SEC */
37 ori r7,r7,16960 38 ori r7,r7,16960
@@ -43,8 +44,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
43 * XSEC_PER_SEC 44 * XSEC_PER_SEC
44 */ 45 */
45 rldicl r0,r0,44,20 46 rldicl r0,r0,44,20
46 cmpldi cr0,r10,0 /* check if tz is NULL */
47 std r0,TVAL64_TV_USEC(r11) /* store usec in tv */ 47 std r0,TVAL64_TV_USEC(r11) /* store usec in tv */
482: cmpldi r10,0 /* check if tz is NULL */
48 beq 1f 49 beq 1f
49 lwz r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */ 50 lwz r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */
50 lwz r5,CFG_TZ_DSTTIME(r3) 51 lwz r5,CFG_TZ_DSTTIME(r3)