[PATCH v2] Fix VDSO gettimeofday() when called with NULL struct timeval.
Will Schmidt
will_schmidt at vnet.ibm.com
Sat Jun 30 06:39:44 EST 2007
On Tue, 2007-06-26 at 09:50 +1000, Tony Breeds wrote:
> Updated to include feedback from Ben and Segher, also reposition the
> compare in the 64bit VDSO to catch all the references to tv.
> --- working.orig/arch/powerpc/kernel/vdso64/gettimeofday.S
> +++ working/arch/powerpc/kernel/vdso64/gettimeofday.S
<snippage>
> @@ -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 */
Whoops! r10 holds tz value, not tv. This should be r11.
As is, a (64-bit) userspace app calling gettimeofday(&tv,NULL); will
"silently fail", and the application is left using whatever old data
happens to be in the tv structure.
This affected my G5 (gentoo), most noticable when apps like 'ping' and
nfs-mounts quit working properly. :-)
patch follows momentarily...
> + 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)
>
> Yours Tony
>
> linux.conf.au http://linux.conf.au/ || http://lca2008.linux.org.au/
> Jan 28 - Feb 02 2008 The Australian Linux Technical Conference!
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
More information about the Linuxppc-dev
mailing list