y2038:mutex_timedlock for timespec64
v3 cover y2038:mutex_timedlock for timespec64
This patch serial is aimed to introduce a new syscall mutex_timedlock64 which is specific for 64-bit time_t.
---
v2:
1, new revision regarding review comments
v3:
1, return -errno
2, throw a warning if timeout is NULL
Song Chen (3):
y2038: cobalt/posix/mutex: Adding mutex_timedlock64
y2038: lib/cobalt/mutex: dispatch mutex_timedlock
y2038: testsuite/smokey/y2038: testcase for mutex_timedlock64
include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 + testsuite/smokey/y2038/syscall-tests.c | 136 +++++++++++++++++++++++++++++++++ 7 files changed, 180 insertions(+), 1 deletion(-)
Signature · 1 line
2.7.4
Hi Song,
Quoted 10 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsv3:
1, return -errno
2, throw a warning if timeout is NULL
Will you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
Quoted 15 lines
Song Chen (3):
y2038: cobalt/posix/mutex: Addingmutex_timedlock64
y2038:lib/cobalt/mutex: dispatchmutex_timedlock
y2038: testsuite/smokey/y2038: testcase formutex_timedlock64include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 + testsuite/smokey/y2038/syscall-tests.c | 136 +++++++++++++++++++++++++++++++++ 7 files changed, 180 insertions(+), 1 deletion(-)
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review comments
Quoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
+ /* Timeout is never read by the kernel, so NULL should be OK */
+ ret = XENOMAI_SYSCALL2(sr_nc, &lock, NULL);
+ if (!smokey_assert(!ret))
+ smokey_warning("POSIX mutex_timedlock64 violation detected");
+
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
Quoted 18 lines
Quoted 16 lines
Song Chen (3):
y2038: cobalt/posix/mutex: Addingmutex_timedlock64
y2038:lib/cobalt/mutex: dispatchmutex_timedlock
y2038: testsuite/smokey/y2038: testcase formutex_timedlock64include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 + testsuite/smokey/y2038/syscall-tests.c | 136 +++++++++++++++++++++++++++++++++ 7 files changed, 180 insertions(+), 1 deletion(-)
Quoted 30 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret =
XENOMAI_SYSCALL2(sr_nc, &lock, NULL);
+ if (!smokey_assert(!ret))
+smokey_warning("POSIX mutex_timedlock64 violation detected"); +
Quoted 3 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
Quoted 22 lines
Quoted 20 lines
Quoted 18 lines
Song Chen (3):
y2038: cobalt/posix/mutex: Addingmutex_timedlock64
y2038:lib/cobalt/mutex: dispatchmutex_timedlock
y2038: testsuite/smokey/y2038: testcase formutex_timedlock64include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 +
testsuite/smokey/y2038/syscall-tests.c| 136
+++++++++++++++++++++++++++++++++7 files changed, 180 insertions(+), 1 deletion(-)
Quoted 33 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 30 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret =
XENOMAI_SYSCALL2(sr_nc, &lock, NULL);
+ if (!smokey_assert(!ret))
+smokey_warning("POSIX mutex_timedlock64 violation detected"); +
Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the sem_timedwait syscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:
Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the abs_timeout parameter need not be checked if the mutex can be locked immediately.
To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
[1] https://xenomai.org/pipermail/xenomai/2021-March/044668.html
Quoted 24 lines
Quoted 23 lines
Quoted 21 lines
Quoted 19 lines
Song Chen (3):
y2038: cobalt/posix/mutex: Addingmutex_timedlock64
y2038:lib/cobalt/mutex: dispatchmutex_timedlock
y2038: testsuite/smokey/y2038: testcase formutex_timedlock64include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 +
testsuite/smokey/y2038/syscall-tests.c| 136
+++++++++++++++++++++++++++++++++7 files changed, 180 insertions(+), 1 deletion(-)
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 54 lines · Florian Bezdeka
Quoted 33 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 30 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret =
XENOMAI_SYSCALL2(sr_nc, &lock, NULL);
+ if (!smokey_assert(!ret))
+smokey_warning("POSIX mutex_timedlock64 violation detected"); +Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the
sem_timedwaitsyscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.
Quoted 6 lines
To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
[1] https://xenomai.org/pipermail/xenomai/2021-March/044668.html
Thanks, i will take care of this case.
Song
Quoted 26 lines
Quoted 24 lines
Quoted 23 lines
Quoted 21 lines
Quoted 19 lines
Song Chen (3):
y2038: cobalt/posix/mutex: Addingmutex_timedlock64
y2038:lib/cobalt/mutex: dispatchmutex_timedlock
y2038: testsuite/smokey/y2038: testcase formutex_timedlock64include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/mutex.c | 22 +++++- kernel/cobalt/posix/mutex.h | 7 ++ kernel/cobalt/posix/syscall32.c | 7 ++ kernel/cobalt/posix/syscall32.h | 4 + lib/cobalt/mutex.c | 4 + testsuite/smokey/y2038/syscall-tests.c | 136 +++++++++++++++++++++++++++++++++ 7 files changed, 180 insertions(+), 1 deletion(-)
Quoted 59 lines
From: Xenomai <[email protected]> On Behalf Of Florian Bezdeka via Xenomai
Sent: Tuesday, June 8, 2021 1:04 PM
To: [email protected]; [email protected]
Subject: Re: [florian/y2038][PATCH v3 0/3] y2038:mutex_timedlock for timespec64Quoted 33 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 30 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
(quoted diff) +5
-0+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret = XENOMAI_SYSCALL2(sr_nc, &lock, NULL); + if (!smokey_assert(!ret)) + smokey_warning("POSIX mutex_timedlock64 violation detected"); +Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the
sem_timedwaitsyscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.
Quoted 5 lines
To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
[1] https://xenomai.org/pipermail/xenomai/2021-March/044668.html
Please excuse my jumping in the discussion - perhaps I'm missing something, but IMHO "need not be checked" does not mean "must not be checked", but rather implies "may be checked", so a mere validity check is not a violation of POSIX. You, Florian, in [1] just said about the validating: "Yes it does, and probably should not for consistency with other calls" - that's a different, also fair reason for avoiding the check.
--
Best regards,
Dietmar
________________________________
manroland Goss web systems GmbH | Managing Director: Franz Kriechbaum Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 32609 | VAT: DE815764857
Confidentiality note:
This message and any attached documents may contain confidential or proprietary information of manroland|Goss. These materials are intended only for the use of the intended recipient. If you are not the intended recipient of this transmission, you are hereby notified that any distribution, disclosure, printing, copying, storage, modification or the taking of any action in reliance upon this transmission is strictly prohibited. Delivery of this message to any person other than the intended recipient shall not compromise or waive such confidentiality, privilege or exemption from disclosure as to this communication. If you have received this communication in error, please immediately notify the sender and delete the message from your system. All liability for viruses is excluded to the fullest extent permitted by law.
________________________________
hi Dietmar,
Quoted 59 lines · Dietmar Schindler via Xenomai
Quoted 59 lines
From: Xenomai <[email protected]> On Behalf Of Florian Bezdeka via Xenomai
Sent: Tuesday, June 8, 2021 1:04 PM
To: [email protected]; [email protected]
Subject: Re: [florian/y2038][PATCH v3 0/3] y2038:mutex_timedlock for timespec64Quoted 33 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 30 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 10 lines · Florian Bezdeka
Hi Song,
Quoted 7 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
(quoted diff) +5
-0+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret = XENOMAI_SYSCALL2(sr_nc, &lock, NULL); + if (!smokey_assert(!ret)) + smokey_warning("POSIX mutex_timedlock64 violation detected"); +Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the
sem_timedwaitsyscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.
Quoted 7 lines
Quoted 5 lines
To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
[1] https://xenomai.org/pipermail/xenomai/2021-March/044668.html
Please excuse my jumping in the discussion - perhaps I'm missing something, but IMHO "need not be checked" does not mean "must not be checked", but rather implies "may be checked", so a mere validity check is not a violation of POSIX. You, Florian, in [1] just said about the validating: "Yes it does, and probably should not for consistency with other calls" - that's a different, also fair reason for avoiding the check.
you are so welcomed to join the discussion and your opinion is valued and helpful.
we have three cases about validating timeout:
1) sem_timedwait
it merely validates timeout, not returns error back to user space even it fails, same with what you said.
2) mutex_timedlock
it acts differently with sem_timedwait, if timeout is null, returns -EFAULT before trying to acquire
3) mq_timedsend/mq_timedreceive
if it manages to send msg to the queue, it even doesn't validate timeout at all.
however, in vanilla kernel, it validates timeout at the beginning and return EFAULT if it fails, as a result, mq_timedsend/mq_timedreceive has different semantics, returns different values and leads to different behaviors in user space.
I would suggest we should follow vanilla kernel, what do you think?
what's more, i didn't find implementation of sem_timedwait and mutex_timedlock, are they in glibc? then we should follow glibc.
Quoted 12 lines
--
Best regards,
Dietmar
________________________________
manroland Goss web systems GmbH | Managing Director: Franz Kriechbaum Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 32609 | VAT: DE815764857Confidentiality note:
This message and any attached documents may contain confidential or proprietary information of manroland|Goss. These materials are intended only for the use of the intended recipient. If you are not the intended recipient of this transmission, you are hereby notified that any distribution, disclosure, printing, copying, storage, modification or the taking of any action in reliance upon this transmission is strictly prohibited. Delivery of this message to any person other than the intended recipient shall not compromise or waive such confidentiality, privilege or exemption from disclosure as to this communication. If you have received this communication in error, please immediately notify the sender and delete the message from your system. All liability for viruses is excluded to the fullest extent permitted by law.
________________________________
Quoted 80 lines · On 11.06.21 04:17, chensong_2000--- via Xenomai wrote:
hi Dietmar,
Quoted 77 lines · Dietmar Schindler via Xenomai
Quoted 62 lines
From: Xenomai <[email protected]> On Behalf Of Florian Bezdeka via Xenomai
Sent: Tuesday, June 8, 2021 1:04 PM
To: [email protected]; [email protected]
Subject: Re: [florian/y2038][PATCH v3 0/3] y2038:mutex_timedlock for timespec64Quoted 34 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 31 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 11 lines · Florian Bezdeka
Hi Song,
Quoted 8 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64
which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret =
XENOMAI_SYSCALL2(sr_nc, &lock, NULL);
+ if (!smokey_assert(!ret))
+smokey_warning("POSIX mutex_timedlock64 violation detected"); +Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the
sem_timedwaitsyscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.Quoted 7 lines
To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
Please excuse my jumping in the discussion - perhaps I'm missing something, but IMHO "need not be checked" does not mean "must not be checked", but rather implies "may be checked", so a mere validity check is not a violation of POSIX. You, Florian, in [1] just said about the validating: "Yes it does, and probably should not for consistency with other calls" - that's a different, also fair reason for avoiding the check.
"Yes it does, and probably should not for consistency with other calls" were Philippe's words ;-)
Quoted 8 lines
you are so welcomed to join the discussion and your opinion is valued and helpful.
we have three cases about validating timeout:
1)sem_timedwait
it merely validates timeout, not returns error back to user space even it fails, same with what you said.
It validates the timeout before first use (not on kernel entry like below). If validation fails it will report the error.
Quoted 4 lines
2)
mutex_timedlock
it acts differently withsem_timedwait, if timeout is null, returns-EFAULTbefore trying to acquire
Let's focus on this one first. I haven't looked at the follwing (mq) yet.
POSIX again:
The validity of the abs_timeout parameter need not be checked if the mutex can be locked immediately.
IOW: Calling mutex_timedwait() on an mutex that is not taken for sure (the caller knows that) with an invalid/NULL timeout should succeed because there is no need to touch/validate the given timeout. Currently we fail.
Maybe the wording "violation" is to hard here...
Quoted 42 lines
3) mq_timedsend/mq_timedreceive
if it manages to send msg to the queue, it even doesn't validate timeout at all.however, in vanilla kernel, it validates timeout at the beginning and return EFAULT if it fails, as a result, mq_timedsend/mq_timedreceive has different semantics, returns different values and leads to different behaviors in user space.
I would suggest we should follow vanilla kernel, what do you think?
what's more, i didn't find implementation of
sem_timedwaitandmutex_timedlock, are they in glibc? then we should follow glibc.Quoted 25 lines
Signature · 23 lines
-- Best regards, Dietmar ________________________________ manroland Goss web systems GmbH | Managing Director: Franz Kriechbaum Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 32609 | VAT: DE815764857 Confidentiality note: This message and any attached documents may contain confidential or proprietary information of manroland|Goss. These materials are intended only for the use of the intended recipient. If you are not the intended recipient of this transmission, you are hereby notified that any distribution, disclosure, printing, copying, storage, modification or the taking of any action in reliance upon this transmission is strictly prohibited. Delivery of this message to any person other than the intended recipient shall not compromise or waive such confidentiality, privilege or exemption from disclosure as to this communication. If you have received this communication in error, please immediately notify the sender and delete the message from your system. All liability for viruses is excluded to the fullest extent permitted by law. ________________________________
Signature · 2 lines
Siemens AG, T RDA IOT Corporate Competence Center Embedded Linux
Quoted 93 lines
From: Florian Bezdeka <[email protected]>
Sent: Friday, June 11, 2021 9:29 AM
To: [email protected]; [email protected]; Schindler, Dietmar - OTPS <[email protected]>Quoted 71 lines · On 11.06.21 04:17, chensong_2000--- via Xenomai wrote:
hi Dietmar,
Quoted 68 lines · Dietmar Schindler via Xenomai
Quoted 68 lines
From: Xenomai <[email protected]> On Behalf Of Florian Bezdeka via Xenomai
Sent: Tuesday, June 8, 2021 1:04 PM
To: [email protected]; [email protected]
Subject: Re: [florian/y2038][PATCH v3 0/3] y2038:mutex_timedlock for timespec64Quoted 34 lines · On 08.06.21 09:51, chensong_2000--- via Xenomai wrote:
Quoted 31 lines · 在 2021/6/8 下午3:37, chensong_2000--- via Xenomai 写道:
Quoted 11 lines · Florian Bezdeka
Hi Song,
Quoted 8 lines · Song Chen
This patch serial is aimed to introduce a new syscall
mutex_timedlock64
which is specific for 64-bittime_t.---
v2:
1, new revision regarding review commentsQuoted 6 lines
Quoted 3 lines
v3:
1, return -errno
2, throw a warning if timeout is NULLWill you take care of the POSIX violation as well, or should I try to find a timeslot and do it?
I will take care of it.
POSIX violation, do you mean:
(quoted diff) +5
-0+ /* Timeout is never read by the kernel, so NULL should be OK */ + ret = XENOMAI_SYSCALL2(sr_nc, &lock, NULL); + if (!smokey_assert(!ret)) + smokey_warning("POSIX mutex_timedlock64 violation detected"); +Quoted 6 lines
Quoted 4 lines
what else should i do to take care of it, sorry if i missed some information in the past emails.
/Song
to find out the reason it returns 0 even if timeout is NULL?
I already had a short discussion with Philippe about that topic some time ago. See [1].
It's more or less the same as for the
sem_timedwaitsyscall. As long as the supplied timeout is not used / read by the kernel it should be treated as "optional argument". Reason: The POSIX spec, which says:Under no circumstance shall the function fail with a timeout if the mutex can be locked immediately. The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.To fix this violation (we return an error if no timeout is given independent from the fact if was used or not) a refactoring might be needed. Philippe already posted his idea in [1] how to do that.
[1]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fxenomai.org%2Fpipermail%
2Fxenomai%2F2021- March%2F044668.html&data=04%7C01%7Cflorian.bezdeka%40siemens.com%7Cb99e85555dbc4dbc8b6 208d92c7f1d5f%7C38ae3bcd95794fd4addab42e1495d55a%7C1%7C0%7C637589746739914122%7CUnknown%7C TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000& sdata=v6x0HYNAhBs%2FgVoSsuI8hkHwrItWfYbFWXMjtVdTHiU%3D&reserved=0Quoted 9 lines
Quoted 9 lines
Quoted 1 line
Please excuse my jumping in the discussion - perhaps I'm missing something, but IMHO "need not be checked" does not mean "must not be checked", but rather implies "may be checked", so a mere validity check is not a violation of POSIX. You, Florian, in [1] just said about the validating: "Yes it does, and probably should not for consistency with other calls" - that's a different, also fair reason for avoiding the check.
Quoted 2 lines
"Yes it does, and probably should not for consistency with other calls" were Philippe's words ;-)
My apologies to you and Philippe!
Quoted 3 lines
Quoted 3 lines
you are so welcomed to join the discussion and your opinion is valued and helpful.
Thank you, Song, for the friendly words!
Quoted 21 lines
Quoted 5 lines
we have three cases about validating timeout:
1)sem_timedwait
it merely validates timeout, not returns error back to user space even it fails, same with what you said.It validates the timeout before first use (not on kernel entry like below). If validation fails it will report the error.
Quoted 4 lines
2)
mutex_timedlock
it acts differently withsem_timedwait, if timeout is null, returns-EFAULTbefore trying to acquireLet's focus on this one first. I haven't looked at the follwing (mq) yet.
POSIX again:
The validity of the
abs_timeoutparameter need not be checked if the mutex can be locked immediately.
Quoted 6 lines
IOW: Calling
mutex_timedwait()on an mutex that is not taken for sure (the caller knows that) with an invalid/NULL timeout should succeed because there is no need to touch/validate the given timeout. Currently we fail.Maybe the wording "violation" is to hard here...
I agree, of course, since I don't see it as a violation at all. :-)
Quoted 9 lines
Quoted 9 lines
3) mq_timedsend/mq_timedreceive
if it manages to send msg to the queue, it even doesn't validate timeout at all.however, in vanilla kernel, it validates timeout at the beginning and return EFAULT if it fails, as a result, mq_timedsend/mq_timedreceive has different semantics, returns different values and leads to different behaviors in user space.
Quoted 4 lines
Quoted 4 lines
I would suggest we should follow vanilla kernel, what do you think?
what's more, i didn't find implementation of
sem_timedwaitandmutex_timedlock, are they in glibc? then we should follow glibc.
Again I agree that "consistency with other calls" is a good thing.
--
Best regards,
Dietmar Schindler
________________________________
manroland Goss web systems GmbH | Managing Director: Franz Kriechbaum Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 32609 | VAT: DE815764857
Confidentiality note:
This message and any attached documents may contain confidential or proprietary information of manroland|Goss. These materials are intended only for the use of the intended recipient. If you are not the intended recipient of this transmission, you are hereby notified that any distribution, disclosure, printing, copying, storage, modification or the taking of any action in reliance upon this transmission is strictly prohibited. Delivery of this message to any person other than the intended recipient shall not compromise or waive such confidentiality, privilege or exemption from disclosure as to this communication. If you have received this communication in error, please immediately notify the sender and delete the message from your system. All liability for viruses is excluded to the fullest extent permitted by law.
________________________________