linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/vdso: Make clock_getres() POSIX compliant again
       [not found]                   ` <87eez7glre.fsf@igel.home>
@ 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
  0 siblings, 2 replies; 3+ 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] 3+ messages in thread

* Re: [PATCH] lib/vdso: Make clock_getres() POSIX compliant again
  2019-10-21 10:07                     ` [PATCH] lib/vdso: Make clock_getres() POSIX compliant again Thomas Gleixner
@ 2019-10-21 15:23                       ` Christophe Leroy
  2019-10-23 12:50                       ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 3+ 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] 3+ messages in thread

* [tip: timers/urgent] lib/vdso: Make clock_getres() POSIX compliant again
  2019-10-21 10:07                     ` [PATCH] lib/vdso: Make clock_getres() POSIX compliant again Thomas Gleixner
  2019-10-21 15:23                       ` Christophe Leroy
@ 2019-10-23 12:50                       ` tip-bot2 for Thomas Gleixner
  1 sibling, 0 replies; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2019-10-23 12:51 UTC | newest]

Thread overview: 3+ 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>
     [not found] ` <87v9skcznp.fsf@igel.home>
     [not found]   ` <ed65e4c6-2fe0-2f5c-f667-5a81b19eb073@c-s.fr>
     [not found]     ` <87tv83zqt1.fsf@hase.home>
     [not found]       ` <b64c367b-d1e5-bf26-d452-145c0be6e30a@c-s.fr>
     [not found]         ` <alpine.DEB.2.21.1910201243580.2090@nanos.tec.linutronix.de>
     [not found]           ` <875zkjipra.fsf@igel.home>
     [not found]             ` <alpine.DEB.2.21.1910201731070.2090@nanos.tec.linutronix.de>
     [not found]               ` <87r237h01a.fsf@igel.home>
     [not found]                 ` <alpine.DEB.2.21.1910202145160.2090@nanos.tec.linutronix.de>
     [not found]                   ` <87eez7glre.fsf@igel.home>
2019-10-21 10:07                     ` [PATCH] lib/vdso: Make clock_getres() POSIX compliant again Thomas Gleixner
2019-10-21 15:23                       ` Christophe Leroy
2019-10-23 12:50                       ` [tip: timers/urgent] " tip-bot2 for Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).