]> git.baikalelectronics.ru Git - kernel.git/commit
x86: gettimeofday() vDSO: fix segfault when tv == NULL
authorJohn Wright <john.wright@hp.com>
Wed, 29 Apr 2009 20:32:01 +0000 (14:32 -0600)
committerIngo Molnar <mingo@elte.hu>
Thu, 30 Apr 2009 10:31:45 +0000 (12:31 +0200)
commit650d79c37c518536807b898cfd4a1e88b02707ba
treeea094eebb66277be8f5d67884f3dd55a609d1bc4
parent1a1265eecfaf92593506edad6a71f2e069a7da76
x86: gettimeofday() vDSO: fix segfault when tv == NULL

According to the gettimeofday(2) manual:

       If either tv or tz is NULL, the corresponding structure is not
       set or returned.

Since it is legal to give NULL as the tv argument, the code should make
sure tv is not NULL before trying to dereference it.

This issue manifests itself on x86_64 when vdso=0 is not on the kernel
command-line and libc uses the vDSO for gettimeofday() (e.g. glibc >=
2.7).  A simple reproducer:

  #include <stdio.h>
  #include <sys/time.h>

  int main(void)
  {
      struct timezone tz;

      gettimeofday(NULL, &tz);

      return 0;
  }

See http://bugs.debian.org/466491 for more details.

[ Impact: fix gettimeofday(NULL, &tz) segfault ]

Signed-off-by: John Wright <john.wright@hp.com>
Cc: Andi Kleen <ak@suse.de>
Cc: John Wright <john.wright@hp.com>
LKML-Reference: <1241037121-14805-1-git-send-email-john.wright@hp.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/vdso/vclock_gettime.c