All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
       [not found] <0fc22a08-31d9-e4d1-557e-bf5b482a9a20__6444.28012180782$1571503753$gmane$org@c-s.fr>
@ 2019-10-19 19:18 ` Andreas Schwab
  2019-10-20  9:20   ` Christophe Leroy
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2019-10-19 19:18 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino

On Okt 19 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:

> Hi Nathan,
>
> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm
> getting the following kind of error with vdsotest:
>
> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>
> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
> pointer checks"), it seems that signal 11 is expected when passing NULL
> pointer.
>
> Any plan to fix vdsotest ?

Passing NULL to clock_getres is valid, and required to return
successfully if the clock id is valid.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-19 19:18 ` passing NULL to clock_getres (VDSO): terminated by unexpected signal 11 Andreas Schwab
@ 2019-10-20  9:20   ` Christophe Leroy
  2019-10-20  9:53     ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Christophe Leroy @ 2019-10-20  9:20 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino



Le 19/10/2019 à 21:18, Andreas Schwab a écrit :
> On Okt 19 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> 
>> Hi Nathan,
>>
>> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm
>> getting the following kind of error with vdsotest:
>>
>> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>>
>> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
>> pointer checks"), it seems that signal 11 is expected when passing NULL
>> pointer.
>>
>> Any plan to fix vdsotest ?
> 
> Passing NULL to clock_getres is valid, and required to return
> successfully if the clock id is valid.
> 

Do you mean the following commit is wrong ?

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/lib/vdso?id=a9446a906f52292c52ecbd5be78eaa4d8395756c

Christophe

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20  9:20   ` Christophe Leroy
@ 2019-10-20  9:53     ` Andreas Schwab
  2019-10-20 10:25       ` Christophe Leroy
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2019-10-20  9:53 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino

On Okt 20 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:

> Le 19/10/2019 à 21:18, Andreas Schwab a écrit :
>> On Okt 19 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>>
>>> Hi Nathan,
>>>
>>> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm
>>> getting the following kind of error with vdsotest:
>>>
>>> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>>>
>>> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
>>> pointer checks"), it seems that signal 11 is expected when passing NULL
>>> pointer.
>>>
>>> Any plan to fix vdsotest ?
>>
>> Passing NULL to clock_getres is valid, and required to return
>> successfully if the clock id is valid.
>>
>
> Do you mean the following commit is wrong ?
>
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/lib/vdso?id=a9446a906f52292c52ecbd5be78eaa4d8395756c

If it causes a valid call to clock_getres to fail, then yes.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20  9:53     ` Andreas Schwab
@ 2019-10-20 10:25       ` Christophe Leroy
  2019-10-20 11:44         ` Thomas Gleixner
  0 siblings, 1 reply; 18+ messages in thread
From: Christophe Leroy @ 2019-10-20 10:25 UTC (permalink / raw)
  To: Andreas Schwab, Thomas Gleixner
  Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino

Adding Thomas to the discussion as the commit is from him.

Le 20/10/2019 à 11:53, Andreas Schwab a écrit :
> On Okt 20 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> 
>> Le 19/10/2019 à 21:18, Andreas Schwab a écrit :
>>> On Okt 19 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
>>>
>>>> Hi Nathan,
>>>>
>>>> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm
>>>> getting the following kind of error with vdsotest:
>>>>
>>>> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>>>>
>>>> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
>>>> pointer checks"), it seems that signal 11 is expected when passing NULL
>>>> pointer.
>>>>
>>>> Any plan to fix vdsotest ?
>>>
>>> Passing NULL to clock_getres is valid, and required to return
>>> successfully if the clock id is valid.
>>>
>>
>> Do you mean the following commit is wrong ?
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/lib/vdso?id=a9446a906f52292c52ecbd5be78eaa4d8395756c
> 
> If it causes a valid call to clock_getres to fail, then yes.
> 
> Andreas.
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 10:25       ` Christophe Leroy
@ 2019-10-20 11:44         ` Thomas Gleixner
  2019-10-20 12:07           ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Thomas Gleixner @ 2019-10-20 11:44 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino, Andreas Schwab

[-- Attachment #1: Type: text/plain, Size: 2052 bytes --]

On Sun, 20 Oct 2019, Christophe Leroy wrote:
> Adding Thomas to the discussion as the commit is from him.
> 
> Le 20/10/2019 à 11:53, Andreas Schwab a écrit :
> > On Okt 20 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > 
> > > Le 19/10/2019 à 21:18, Andreas Schwab a écrit :
> > > > On Okt 19 2019, Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> > > > 
> > > > > Hi Nathan,
> > > > > 
> > > > > While trying to switch powerpc VDSO to C version of gettimeofday(),
> > > > > I'm
> > > > > getting the following kind of error with vdsotest:
> > > > > 
> > > > > passing NULL to clock_getres (VDSO): terminated by unexpected signal
> > > > > 11
> > > > > 
> > > > > Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
> > > > > pointer checks"), it seems that signal 11 is expected when passing
> > > > > NULL
> > > > > pointer.
> > > > > 
> > > > > Any plan to fix vdsotest ?
> > > > 
> > > > Passing NULL to clock_getres is valid, and required to return
> > > > successfully if the clock id is valid.
> > > > 
> > > 
> > > Do you mean the following commit is wrong ?
> > > 
> > > https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/lib/vdso?id=a9446a906f52292c52ecbd5be78eaa4d8395756c
> > 
> > If it causes a valid call to clock_getres to fail, then yes.

clock_getres(NULL) is hardly valid.

Fact is that 64bit did never check the pointer and unconditionally let the
NULL pointer dereference happen.

Also as documented in the change log, the vdso _cannot_ ever be fully
equivalent to the syscall.

The simple example:

    struct timespec *ts = (struct timespec *) 0xFF;

    clock_getres(clock, ts);

will fault in the VDSO, but not in the syscall.

VDSO can never ever guarantee that any of the clock_* functions will return
EFAULT if the provided pointer points outside of the accessible address
space, is mapped RO etc.

So special casing

    clock_getres(clock, NULL);

just to make a test case happy is a pointless exercise which does not make
any sense at all.

Thanks,

	tglx


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 11:44         ` Thomas Gleixner
@ 2019-10-20 12:07           ` Andreas Schwab
  2019-10-20 15:45             ` Thomas Gleixner
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2019-10-20 12:07 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Nathan Lynch, Vincenzo Frascino, linuxppc-dev

On Okt 20 2019, Thomas Gleixner <tglx@linutronix.de> wrote:

> clock_getres(NULL) is hardly valid.

Of course not, it lacks a parameter.

> So special casing
>
>     clock_getres(clock, NULL);
>
> just to make a test case happy is a pointless exercise which does not make
> any sense at all.

POSIX requires it to work.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 12:07           ` Andreas Schwab
@ 2019-10-20 15:45             ` Thomas Gleixner
  2019-10-20 16:08               ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Thomas Gleixner @ 2019-10-20 15:45 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Nathan Lynch, Vincenzo Frascino, linuxppc-dev

On Sun, 20 Oct 2019, Andreas Schwab wrote:

> On Okt 20 2019, Thomas Gleixner <tglx@linutronix.de> wrote:
> 
> > clock_getres(NULL) is hardly valid.
> 
> Of course not, it lacks a parameter.

You know exactly what I mean.
 
> > So special casing
> >
> >     clock_getres(clock, NULL);
> >
> > just to make a test case happy is a pointless exercise which does not make
> > any sense at all.
> 
> POSIX requires it to work.

POSIX does not mention anything about the validity of the pointer handed to
clock_getres().

https://pubs.opengroup.org/onlinepubs/9699919799/

 "The clock_getres(), clock_gettime(), and clock_settime() functions shall fail if:

   [EINVAL]
     The clock_id argument does not specify a known clock."

EINVAL is the only documented error code for clock_getres(). 

Again. The VDSO is not a syscall and therefore neither address space
validation of the supplied pointer nor catching an invalid access works
like it does in a syscall.

The only invalid pointer it can catch is NULL, but that's ONE case out of a
gazillion. So what's the value of catching NULL and only NULL?

If you can come up with a solution to handle invalid pointers in the VDSO
gracefully, then I'm surely all ears.

If not then can you please explain why VDSO usage worked without pointer
validation since the time VDSO was invented more than a decade ago and just
now requires full invalid pointer handling?

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 15:45             ` Thomas Gleixner
@ 2019-10-20 16:08               ` Andreas Schwab
  2019-10-20 19:53                 ` Thomas Gleixner
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2019-10-20 16:08 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Nathan Lynch, Vincenzo Frascino, linuxppc-dev

On Okt 20 2019, Thomas Gleixner wrote:

> POSIX does not mention anything about the validity of the pointer handed to
> clock_getres().

Sure it does: "If the argument res is not NULL, the resolution of the
specified clock shall be stored in the location pointed to by res.  If
res is NULL, the clock resolution is not returned.".

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 16:08               ` Andreas Schwab
@ 2019-10-20 19:53                 ` Thomas Gleixner
  2019-10-20 21:17                   ` Andreas Schwab
  2019-10-21  9:03                   ` passing NULL to clock_getres (VDSO): terminated by unexpected signal 11 David Laight
  0 siblings, 2 replies; 18+ messages in thread
From: Thomas Gleixner @ 2019-10-20 19:53 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Nathan Lynch, Vincenzo Frascino, linuxppc-dev

On Sun, 20 Oct 2019, Andreas Schwab wrote:
> On Okt 20 2019, Thomas Gleixner wrote:
> 
> > POSIX does not mention anything about the validity of the pointer handed to
> > clock_getres().
> 
> Sure it does: "If the argument res is not NULL, the resolution of the
> specified clock shall be stored in the location pointed to by res.  If
> res is NULL, the clock resolution is not returned.".

Sigh, that makes a lot of sense - NOT.

But for the sake of making a non-sensical specification happy we can add a
NULL pointer check for this. The interesting question is what should be
returned in this case. The kernel returns EFAULT which is probably not
POSIX compliant either.

Patches are welcome.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 19:53                 ` Thomas Gleixner
@ 2019-10-20 21:17                   ` Andreas Schwab
  2019-10-21 10:07                       ` Thomas Gleixner
  2019-10-21  9:03                   ` passing NULL to clock_getres (VDSO): terminated by unexpected signal 11 David Laight
  1 sibling, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2019-10-20 21:17 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Nathan Lynch, Vincenzo Frascino, linuxppc-dev

On Okt 20 2019, Thomas Gleixner wrote:

> But for the sake of making a non-sensical specification happy we can add a
> NULL pointer check for this. The interesting question is what should be
> returned in this case.

0 if the clock id is valid, EINVAL otherwise.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-20 19:53                 ` Thomas Gleixner
  2019-10-20 21:17                   ` Andreas Schwab
@ 2019-10-21  9:03                   ` David Laight
  1 sibling, 0 replies; 18+ messages in thread
From: David Laight @ 2019-10-21  9:03 UTC (permalink / raw)
  To: 'Thomas Gleixner', Andreas Schwab
  Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino

From: Thomas Gleixner
> Sent: 20 October 2019 20:53
> On Sun, 20 Oct 2019, Andreas Schwab wrote:
> > On Okt 20 2019, Thomas Gleixner wrote:
> >
> > > POSIX does not mention anything about the validity of the pointer handed to
> > > clock_getres().
> >
> > Sure it does: "If the argument res is not NULL, the resolution of the
> > specified clock shall be stored in the location pointed to by res.  If
> > res is NULL, the clock resolution is not returned.".
> 
> Sigh, that makes a lot of sense - NOT.
> 
> But for the sake of making a non-sensical specification happy we can add a
> NULL pointer check for this. The interesting question is what should be
> returned in this case. The kernel returns EFAULT which is probably not
> POSIX compliant either.

The application won't see errno == EFAULT.
EFAULT gets converted to SIGSEGV (probably) in the return-to-user code path.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] lib/vdso: Make clock_getres() POSIX compliant again
  2019-10-20 21:17                   ` Andreas Schwab
@ 2019-10-21 10:07                       ` Thomas Gleixner
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Gleixner @ 2019-10-21 10:07 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Christophe Leroy, Nathan Lynch, linuxppc-dev, Vincenzo Frascino,
	LKML, Andy Lutomirski

A recent commit removed the NULL pointer check from the clock_getres()
implementation causing a test case to fault.

POSIX requires an explicit NULL pointer check for clock_getres() aside of
the validity check of the clock_id argument for obscure reasons.

Add it back for both 32bit and 64bit.

Note, this is only a partial revert of the offending commit which does not
bring back the broken fallback invocation in the the 32bit compat
implementations of clock_getres() and clock_gettime().

Fixes: a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks")
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
 lib/vdso/gettimeofday.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_
 		return -1;
 	}
 
-	res->tv_sec = 0;
-	res->tv_nsec = ns;
-
+	if (likely(res)) {
+		res->tv_sec = 0;
+		res->tv_nsec = ns;
+	}
 	return 0;
 }
 
@@ -245,7 +246,7 @@ static __maybe_unused int
 		ret = clock_getres_fallback(clock, &ts);
 #endif
 
-	if (likely(!ret)) {
+	if (likely(!ret && res)) {
 		res->tv_sec = ts.tv_sec;
 		res->tv_nsec = ts.tv_nsec;
 	}

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH] lib/vdso: Make clock_getres() POSIX compliant again
@ 2019-10-21 10:07                       ` Thomas Gleixner
  0 siblings, 0 replies; 18+ messages in thread
From: Thomas Gleixner @ 2019-10-21 10:07 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: Nathan Lynch, LKML, linuxppc-dev, Andy Lutomirski, Vincenzo Frascino

A recent commit removed the NULL pointer check from the clock_getres()
implementation causing a test case to fault.

POSIX requires an explicit NULL pointer check for clock_getres() aside of
the validity check of the clock_id argument for obscure reasons.

Add it back for both 32bit and 64bit.

Note, this is only a partial revert of the offending commit which does not
bring back the broken fallback invocation in the the 32bit compat
implementations of clock_getres() and clock_gettime().

Fixes: a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks")
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
 lib/vdso/gettimeofday.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_
 		return -1;
 	}
 
-	res->tv_sec = 0;
-	res->tv_nsec = ns;
-
+	if (likely(res)) {
+		res->tv_sec = 0;
+		res->tv_nsec = ns;
+	}
 	return 0;
 }
 
@@ -245,7 +246,7 @@ static __maybe_unused int
 		ret = clock_getres_fallback(clock, &ts);
 #endif
 
-	if (likely(!ret)) {
+	if (likely(!ret && res)) {
 		res->tv_sec = ts.tv_sec;
 		res->tv_nsec = ts.tv_nsec;
 	}

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] lib/vdso: Make clock_getres() POSIX compliant again
  2019-10-21 10:07                       ` Thomas Gleixner
  (?)
@ 2019-10-21 15:23                       ` Christophe Leroy
  -1 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-10-21 15:23 UTC (permalink / raw)
  To: Thomas Gleixner, Andreas Schwab
  Cc: Nathan Lynch, linuxppc-dev, Vincenzo Frascino, LKML, Andy Lutomirski



Le 21/10/2019 à 12:07, Thomas Gleixner a écrit :
> A recent commit removed the NULL pointer check from the clock_getres()
> implementation causing a test case to fault.
> 
> POSIX requires an explicit NULL pointer check for clock_getres() aside of
> the validity check of the clock_id argument for obscure reasons.
> 
> Add it back for both 32bit and 64bit.
> 
> Note, this is only a partial revert of the offending commit which does not
> bring back the broken fallback invocation in the the 32bit compat
> implementations of clock_getres() and clock_gettime().
> 
> Fixes: a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks")
> Reported-by: Andreas Schwab <schwab@linux-m68k.org>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>

> Cc: stable@vger.kernel.org
> ---
>   lib/vdso/gettimeofday.c |    9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> --- a/lib/vdso/gettimeofday.c
> +++ b/lib/vdso/gettimeofday.c
> @@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_
>   		return -1;
>   	}
>   
> -	res->tv_sec = 0;
> -	res->tv_nsec = ns;
> -
> +	if (likely(res)) {
> +		res->tv_sec = 0;
> +		res->tv_nsec = ns;
> +	}
>   	return 0;
>   }
>   
> @@ -245,7 +246,7 @@ static __maybe_unused int
>   		ret = clock_getres_fallback(clock, &ts);
>   #endif
>   
> -	if (likely(!ret)) {
> +	if (likely(!ret && res)) {
>   		res->tv_sec = ts.tv_sec;
>   		res->tv_nsec = ts.tv_nsec;
>   	}
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [tip: timers/urgent] lib/vdso: Make clock_getres() POSIX compliant again
  2019-10-21 10:07                       ` Thomas Gleixner
  (?)
  (?)
@ 2019-10-23 12:50                       ` tip-bot2 for Thomas Gleixner
  -1 siblings, 0 replies; 18+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2019-10-23 12:50 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Andreas Schwab, Thomas Gleixner, Christophe Leroy, stable,
	Ingo Molnar, Borislav Petkov, linux-kernel

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     1638b8f096ca165965189b9626564c933c79fe63
Gitweb:        https://git.kernel.org/tip/1638b8f096ca165965189b9626564c933c79fe63
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Mon, 21 Oct 2019 12:07:15 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 23 Oct 2019 14:48:23 +02:00

lib/vdso: Make clock_getres() POSIX compliant again

A recent commit removed the NULL pointer check from the clock_getres()
implementation causing a test case to fault.

POSIX requires an explicit NULL pointer check for clock_getres() aside of
the validity check of the clock_id argument for obscure reasons.

Add it back for both 32bit and 64bit.

Note, this is only a partial revert of the offending commit which does not
bring back the broken fallback invocation in the the 32bit compat
implementations of clock_getres() and clock_gettime().

Fixes: a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL pointer checks")
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1910211202260.1904@nanos.tec.linutronix.de

---
 lib/vdso/gettimeofday.c |  9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c
index e630e7f..45f57fd 100644
--- a/lib/vdso/gettimeofday.c
+++ b/lib/vdso/gettimeofday.c
@@ -214,9 +214,10 @@ int __cvdso_clock_getres_common(clockid_t clock, struct __kernel_timespec *res)
 		return -1;
 	}
 
-	res->tv_sec = 0;
-	res->tv_nsec = ns;
-
+	if (likely(res)) {
+		res->tv_sec = 0;
+		res->tv_nsec = ns;
+	}
 	return 0;
 }
 
@@ -245,7 +246,7 @@ __cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res)
 		ret = clock_getres_fallback(clock, &ts);
 #endif
 
-	if (likely(!ret)) {
+	if (likely(!ret && res)) {
 		res->tv_sec = ts.tv_sec;
 		res->tv_nsec = ts.tv_nsec;
 	}

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-28 15:46 ` Nathan Lynch
@ 2019-10-28 15:50   ` Christophe Leroy
  0 siblings, 0 replies; 18+ messages in thread
From: Christophe Leroy @ 2019-10-28 15:50 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: linuxppc-dev, Vincenzo Frascino



Le 28/10/2019 à 16:46, Nathan Lynch a écrit :
> Hi Christophe,
> 
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>> Hi Nathan,
>>
>> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm
>> getting the following kind of error with vdsotest:
>>
>> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>>
>> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL
>> pointer checks"), it seems that signal 11 is expected when passing NULL
>> pointer.
>>
>> Any plan to fix vdsotest ?
> 
> I'm afraid other work has kept me from following up on this promptly,
> sorry. I've read the thread here:
> 
> https://lore.kernel.org/linuxppc-dev/87v9skcznp.fsf@igel.home/
> 
> And it looks like vdsotest does not need a fix (and in fact found a bug)
> -- correct?
> 

Yes that's correct, thanks.
Christophe

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
  2019-10-19 16:46 Christophe Leroy
@ 2019-10-28 15:46 ` Nathan Lynch
  2019-10-28 15:50   ` Christophe Leroy
  0 siblings, 1 reply; 18+ messages in thread
From: Nathan Lynch @ 2019-10-28 15:46 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, Vincenzo Frascino

Hi Christophe,

Christophe Leroy <christophe.leroy@c-s.fr> writes:
> Hi Nathan,
>
> While trying to switch powerpc VDSO to C version of gettimeofday(), I'm 
> getting the following kind of error with vdsotest:
>
> passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
>
> Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL 
> pointer checks"), it seems that signal 11 is expected when passing NULL 
> pointer.
>
> Any plan to fix vdsotest ?

I'm afraid other work has kept me from following up on this promptly,
sorry. I've read the thread here:

https://lore.kernel.org/linuxppc-dev/87v9skcznp.fsf@igel.home/

And it looks like vdsotest does not need a fix (and in fact found a bug)
-- correct?

^ permalink raw reply	[flat|nested] 18+ messages in thread

* passing NULL to clock_getres (VDSO): terminated by unexpected signal 11
@ 2019-10-19 16:46 Christophe Leroy
  2019-10-28 15:46 ` Nathan Lynch
  0 siblings, 1 reply; 18+ messages in thread
From: Christophe Leroy @ 2019-10-19 16:46 UTC (permalink / raw)
  To: Nathan Lynch; +Cc: linuxppc-dev, Vincenzo Frascino

Hi Nathan,

While trying to switch powerpc VDSO to C version of gettimeofday(), I'm 
getting the following kind of error with vdsotest:

passing NULL to clock_getres (VDSO): terminated by unexpected signal 11

Looking at commit a9446a906f52 ("lib/vdso/32: Remove inconsistent NULL 
pointer checks"), it seems that signal 11 is expected when passing NULL 
pointer.

Any plan to fix vdsotest ?

Thanks
Christophe

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-10-28 15:53 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <0fc22a08-31d9-e4d1-557e-bf5b482a9a20__6444.28012180782$1571503753$gmane$org@c-s.fr>
2019-10-19 19:18 ` passing NULL to clock_getres (VDSO): terminated by unexpected signal 11 Andreas Schwab
2019-10-20  9:20   ` Christophe Leroy
2019-10-20  9:53     ` Andreas Schwab
2019-10-20 10:25       ` Christophe Leroy
2019-10-20 11:44         ` Thomas Gleixner
2019-10-20 12:07           ` Andreas Schwab
2019-10-20 15:45             ` Thomas Gleixner
2019-10-20 16:08               ` Andreas Schwab
2019-10-20 19:53                 ` Thomas Gleixner
2019-10-20 21:17                   ` Andreas Schwab
2019-10-21 10:07                     ` [PATCH] lib/vdso: Make clock_getres() POSIX compliant again Thomas Gleixner
2019-10-21 10:07                       ` Thomas Gleixner
2019-10-21 15:23                       ` Christophe Leroy
2019-10-23 12:50                       ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner
2019-10-21  9:03                   ` passing NULL to clock_getres (VDSO): terminated by unexpected signal 11 David Laight
2019-10-19 16:46 Christophe Leroy
2019-10-28 15:46 ` Nathan Lynch
2019-10-28 15:50   ` Christophe Leroy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.