All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait()
@ 2021-07-29 14:40 Florian Bezdeka
  2021-07-29 14:42 ` Bezdeka, Florian
  2021-07-29 14:47 ` Philippe Gerum
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Bezdeka @ 2021-07-29 14:40 UTC (permalink / raw)
  To: xenomai

According to the POSIX spec the value of the timeout parameter needs
not to be validated if the mutex/semaphore could be taken immediately.

While the implementation of the semaphore timedwait (sem_timedwait())
allowed an invalid timeout pthread_mutex_timedlock() was failing with
-EFAULT in case the mutex could be taken immediately.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---

This was detected while preparing y2038 stuff. Not sure if that should
go into 3.2. Comments welcome...

CCed Philippe because he was already involved some (long) time ago.

Regards,
Florian

 testsuite/smokey/posix-mutex/posix-mutex.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c
index 0f4dbe739..4aad24964 100644
--- a/testsuite/smokey/posix-mutex/posix-mutex.c
+++ b/testsuite/smokey/posix-mutex/posix-mutex.c
@@ -1007,7 +1007,7 @@ static void *mutex_timed_locker_inv_timeout(void *arg)
 	struct locker_context *p = arg;
 	int ret;
 
-	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void*) 0xdeadbeef)) &&
+	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void *) 0xdeadbeef)) &&
 	    __Tassert(ret == -EFAULT))
 		return (void *)1;
 
@@ -1032,7 +1032,7 @@ static int check_timedlock_abstime_validation(void)
 	 * The second parameter of phtread_mutex_timedlock() is flagged as
 	 * __nonnull so we take an invalid address instead of NULL.
 	 */
-	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void*) 0xdeadbeef)))
+	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void *) 0xdeadbeef)))
 		return ret;
 
 	/*
-- 
2.30.2



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

* Re: [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait()
  2021-07-29 14:40 [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait() Florian Bezdeka
@ 2021-07-29 14:42 ` Bezdeka, Florian
  2021-07-29 14:47 ` Philippe Gerum
  1 sibling, 0 replies; 3+ messages in thread
From: Bezdeka, Florian @ 2021-07-29 14:42 UTC (permalink / raw)
  To: xenomai

Please ignore this one... Local tooling bug.

On Thu, 2021-07-29 at 16:40 +0200, Florian Bezdeka wrote:
> According to the POSIX spec the value of the timeout parameter needs
> not to be validated if the mutex/semaphore could be taken immediately.
> 
> While the implementation of the semaphore timedwait (sem_timedwait())
> allowed an invalid timeout pthread_mutex_timedlock() was failing with
> -EFAULT in case the mutex could be taken immediately.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
> 
> This was detected while preparing y2038 stuff. Not sure if that should
> go into 3.2. Comments welcome...
> 
> CCed Philippe because he was already involved some (long) time ago.
> 
> Regards,
> Florian
> 
>  testsuite/smokey/posix-mutex/posix-mutex.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c
> index 0f4dbe739..4aad24964 100644
> --- a/testsuite/smokey/posix-mutex/posix-mutex.c
> +++ b/testsuite/smokey/posix-mutex/posix-mutex.c
> @@ -1007,7 +1007,7 @@ static void *mutex_timed_locker_inv_timeout(void *arg)
>  	struct locker_context *p = arg;
>  	int ret;
>  
> 
> -	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void*) 0xdeadbeef)) &&
> +	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void *) 0xdeadbeef)) &&
>  	    __Tassert(ret == -EFAULT))
>  		return (void *)1;
>  
> 
> @@ -1032,7 +1032,7 @@ static int check_timedlock_abstime_validation(void)
>  	 * The second parameter of phtread_mutex_timedlock() is flagged as
>  	 * __nonnull so we take an invalid address instead of NULL.
>  	 */
> -	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void*) 0xdeadbeef)))
> +	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void *) 0xdeadbeef)))
>  		return ret;
>  
> 
>  	/*


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

* Re: [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait()
  2021-07-29 14:40 [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait() Florian Bezdeka
  2021-07-29 14:42 ` Bezdeka, Florian
@ 2021-07-29 14:47 ` Philippe Gerum
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Gerum @ 2021-07-29 14:47 UTC (permalink / raw)
  To: Florian Bezdeka; +Cc: xenomai, jan.kiszka, chensong_2000


Florian Bezdeka <florian.bezdeka@siemens.com> writes:

> According to the POSIX spec the value of the timeout parameter needs
> not to be validated if the mutex/semaphore could be taken immediately.
>
> While the implementation of the semaphore timedwait (sem_timedwait())
> allowed an invalid timeout pthread_mutex_timedlock() was failing with
> -EFAULT in case the mutex could be taken immediately.
>
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>
> This was detected while preparing y2038 stuff. Not sure if that should
> go into 3.2. Comments welcome...
>
> CCed Philippe because he was already involved some (long) time ago.
>

I do agree wholeheartedly with the fundamental whitespace cleanup!

> Regards,
> Florian
>
>  testsuite/smokey/posix-mutex/posix-mutex.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/testsuite/smokey/posix-mutex/posix-mutex.c b/testsuite/smokey/posix-mutex/posix-mutex.c
> index 0f4dbe739..4aad24964 100644
> --- a/testsuite/smokey/posix-mutex/posix-mutex.c
> +++ b/testsuite/smokey/posix-mutex/posix-mutex.c
> @@ -1007,7 +1007,7 @@ static void *mutex_timed_locker_inv_timeout(void *arg)
>  	struct locker_context *p = arg;
>  	int ret;
>  
> -	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void*) 0xdeadbeef)) &&
> +	if (__F(ret, pthread_mutex_timedlock(p->mutex, (void *) 0xdeadbeef)) &&
>  	    __Tassert(ret == -EFAULT))
>  		return (void *)1;
>  
> @@ -1032,7 +1032,7 @@ static int check_timedlock_abstime_validation(void)
>  	 * The second parameter of phtread_mutex_timedlock() is flagged as
>  	 * __nonnull so we take an invalid address instead of NULL.
>  	 */
> -	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void*) 0xdeadbeef)))
> +	if (!__T(ret, pthread_mutex_timedlock(&mutex, (void *) 0xdeadbeef)))
>  		return ret;
>  
>  	/*

-- 
Philippe.


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

end of thread, other threads:[~2021-07-29 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 14:40 [PATCH 2/2] cobalt/posix/mutex: Harmonize pthread_mutex_timedlock() and sem_timedwait() Florian Bezdeka
2021-07-29 14:42 ` Bezdeka, Florian
2021-07-29 14:47 ` Philippe Gerum

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.