diff mbox series

system.3: Indicate MT-Unsafe

Message ID 20201006161520.975-1-nate.karstens@garmin.com
State New
Headers show
Series system.3: Indicate MT-Unsafe | expand

Commit Message

Nate Karstens Oct. 6, 2020, 4:15 p.m. UTC
The fact that system(3) does not support pthread_atfork(3) also means
that it is not thread safe. See the discussion for the proposal of a
close-on-fork flag in the 2020 April and May timeframe, especially:

https://lkml.org/lkml/2020/5/15/1067

Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
---
 man3/system.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Adhemerval Zanella Oct. 6, 2020, 5:26 p.m. UTC | #1
On 06/10/2020 13:15, Nate Karstens via Libc-alpha wrote:
> The fact that system(3) does not support pthread_atfork(3) also means
> that it is not thread safe. See the discussion for the proposal of a
> close-on-fork flag in the 2020 April and May timeframe, especially:
> 
> https://lkml.org/lkml/2020/5/15/1067
> 
> Signed-off-by: Nate Karstens <nate.karstens@garmin.com>

Not sure if man pages characterizes file descriptor leak as mt-unsafe, at
least we don't have this concept on glibc manual.  In fact, I think adding
a MT-Unsafe mark to this potentially make any libc call that is not atomic
potentially MT-Unsafe, either when they do not concurrent trigger race
issues regarding memory semantic. At least I think it should add a 'race'
mark to indicate what exactly is MT-unsafe (as for other implementations).

> ---
>  man3/system.3 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/man3/system.3 b/man3/system.3
> index aef40417a..8730fabd3 100644
> --- a/man3/system.3
> +++ b/man3/system.3
> @@ -127,7 +127,7 @@ l l l.
>  Interface	Attribute	Value
>  T{
>  .BR system ()
> -T}	Thread safety	MT-Safe
> +T}	Thread safety	MT-Unsafe
>  .TE
>  .SH CONFORMING TO
>  POSIX.1-2001, POSIX.1-2008, C89, C99.
>
Michael Kerrisk \(man-pages\) via Libc-alpha Oct. 7, 2020, 2:35 p.m. UTC | #2
I'm fine with adding a "race" qualifier. Do you have any ideas on the type of race? I didn't see anything in the other man-pages that jumped out as being correct.

Thanks,

Nate

-----Original Message-----
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Sent: Tuesday, October 06, 2020 12:26
To: Karstens, Nate <Nate.Karstens@garmin.com>; mtk.manpages@gmail.com
Cc: linux-man@vger.kernel.org; libc-alpha@sourceware.org; willy@infradead.org
Subject: Re: [PATCH] system.3: Indicate MT-Unsafe

CAUTION - EXTERNAL EMAIL: Do not click any links or open any attachments unless you trust the sender and know the content is safe.


On 06/10/2020 13:15, Nate Karstens via Libc-alpha wrote:
> The fact that system(3) does not support pthread_atfork(3) also means
> that it is not thread safe. See the discussion for the proposal of a
> close-on-fork flag in the 2020 April and May timeframe, especially:
>
> https://urldefense.com/v3/__https://lkml.org/lkml/2020/5/15/1067__;!!E
> Jc4YC3iFmQ!D9YVAE760hT-YFoOT14KmIu4y2cjQb8ZflVgpX-3rxgBF2WvxyATUeQogZF
> Ffv2sIQ$
>
> Signed-off-by: Nate Karstens <nate.karstens@garmin.com>

Not sure if man pages characterizes file descriptor leak as mt-unsafe, at least we don't have this concept on glibc manual.  In fact, I think adding a MT-Unsafe mark to this potentially make any libc call that is not atomic potentially MT-Unsafe, either when they do not concurrent trigger race issues regarding memory semantic. At least I think it should add a 'race'
mark to indicate what exactly is MT-unsafe (as for other implementations).

> ---
>  man3/system.3 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/man3/system.3 b/man3/system.3 index aef40417a..8730fabd3
> 100644
> --- a/man3/system.3
> +++ b/man3/system.3
> @@ -127,7 +127,7 @@ l l l.
>  Interface    Attribute       Value
>  T{
>  .BR system ()
> -T}   Thread safety   MT-Safe
> +T}   Thread safety   MT-Unsafe
>  .TE
>  .SH CONFORMING TO
>  POSIX.1-2001, POSIX.1-2008, C89, C99.
>
Adhemerval Zanella Oct. 7, 2020, 6:06 p.m. UTC | #3
But calling system does not really incur in a race w.r.t the resources
of the caller itself and least glibc does handle concurrent sigactions 
calls and thread cancellation (by reaping the created process). I am
not sure about other libc implementation though.

The file leakage will be only for the spawn program itself and although 
it is might characterize as unsafe to call 'system' in multithread 
environment I don't think this characterize as MT-unsafe (and with 
FD_CLOEXEC/O_CLOEXEC system is indeed safe in this regarding).

So maybe document using a different markup to make it explicit?

On 07/10/2020 11:35, Karstens, Nate wrote:
> I'm fine with adding a "race" qualifier. Do you have any ideas on the type of race? I didn't see anything in the other man-pages that jumped out as being correct.
> 
> Thanks,
> 
> Nate
> 
> -----Original Message-----
> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> Sent: Tuesday, October 06, 2020 12:26
> To: Karstens, Nate <Nate.Karstens@garmin.com>; mtk.manpages@gmail.com
> Cc: linux-man@vger.kernel.org; libc-alpha@sourceware.org; willy@infradead.org
> Subject: Re: [PATCH] system.3: Indicate MT-Unsafe
> 
> CAUTION - EXTERNAL EMAIL: Do not click any links or open any attachments unless you trust the sender and know the content is safe.
> 
> 
> On 06/10/2020 13:15, Nate Karstens via Libc-alpha wrote:
>> The fact that system(3) does not support pthread_atfork(3) also means
>> that it is not thread safe. See the discussion for the proposal of a
>> close-on-fork flag in the 2020 April and May timeframe, especially:
>>
>> https://urldefense.com/v3/__https://lkml.org/lkml/2020/5/15/1067__;!!E
>> Jc4YC3iFmQ!D9YVAE760hT-YFoOT14KmIu4y2cjQb8ZflVgpX-3rxgBF2WvxyATUeQogZF
>> Ffv2sIQ$
>>
>> Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
> 
> Not sure if man pages characterizes file descriptor leak as mt-unsafe, at least we don't have this concept on glibc manual.  In fact, I think adding a MT-Unsafe mark to this potentially make any libc call that is not atomic potentially MT-Unsafe, either when they do not concurrent trigger race issues regarding memory semantic. At least I think it should add a 'race'
> mark to indicate what exactly is MT-unsafe (as for other implementations).
> 
>> ---
>>  man3/system.3 | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/man3/system.3 b/man3/system.3 index aef40417a..8730fabd3
>> 100644
>> --- a/man3/system.3
>> +++ b/man3/system.3
>> @@ -127,7 +127,7 @@ l l l.
>>  Interface    Attribute       Value
>>  T{
>>  .BR system ()
>> -T}   Thread safety   MT-Safe
>> +T}   Thread safety   MT-Unsafe
>>  .TE
>>  .SH CONFORMING TO
>>  POSIX.1-2001, POSIX.1-2008, C89, C99.
>>
> 
> ________________________________
> 
> CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
>
Michael Kerrisk \(man-pages\) Oct. 27, 2020, 7:08 a.m. UTC | #4
On 10/7/20 8:06 PM, Adhemerval Zanella wrote:
> But calling system does not really incur in a race w.r.t the resources
> of the caller itself and least glibc does handle concurrent sigactions 
> calls and thread cancellation (by reaping the created process). I am
> not sure about other libc implementation though.
> 
> The file leakage will be only for the spawn program itself and although 
> it is might characterize as unsafe to call 'system' in multithread 
> environment I don't think this characterize as MT-unsafe (and with 
> FD_CLOEXEC/O_CLOEXEC system is indeed safe in this regarding).
> 
> So maybe document using a different markup to make it explicit?

Any further conclusions out of this?

Thanks,

Michael

> On 07/10/2020 11:35, Karstens, Nate wrote:
>> I'm fine with adding a "race" qualifier. Do you have any ideas on the type of race? I didn't see anything in the other man-pages that jumped out as being correct.
>>
>> Thanks,
>>
>> Nate
>>
>> -----Original Message-----
>> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>> Sent: Tuesday, October 06, 2020 12:26
>> To: Karstens, Nate <Nate.Karstens@garmin.com>; mtk.manpages@gmail.com
>> Cc: linux-man@vger.kernel.org; libc-alpha@sourceware.org; willy@infradead.org
>> Subject: Re: [PATCH] system.3: Indicate MT-Unsafe
>>
>> CAUTION - EXTERNAL EMAIL: Do not click any links or open any attachments unless you trust the sender and know the content is safe.
>>
>>
>> On 06/10/2020 13:15, Nate Karstens via Libc-alpha wrote:
>>> The fact that system(3) does not support pthread_atfork(3) also means
>>> that it is not thread safe. See the discussion for the proposal of a
>>> close-on-fork flag in the 2020 April and May timeframe, especially:
>>>
>>> https://urldefense.com/v3/__https://lkml.org/lkml/2020/5/15/1067__;!!E
>>> Jc4YC3iFmQ!D9YVAE760hT-YFoOT14KmIu4y2cjQb8ZflVgpX-3rxgBF2WvxyATUeQogZF
>>> Ffv2sIQ$
>>>
>>> Signed-off-by: Nate Karstens <nate.karstens@garmin.com>
>>
>> Not sure if man pages characterizes file descriptor leak as mt-unsafe, at least we don't have this concept on glibc manual.  In fact, I think adding a MT-Unsafe mark to this potentially make any libc call that is not atomic potentially MT-Unsafe, either when they do not concurrent trigger race issues regarding memory semantic. At least I think it should add a 'race'
>> mark to indicate what exactly is MT-unsafe (as for other implementations).
>>
>>> ---
>>>  man3/system.3 | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/man3/system.3 b/man3/system.3 index aef40417a..8730fabd3
>>> 100644
>>> --- a/man3/system.3
>>> +++ b/man3/system.3
>>> @@ -127,7 +127,7 @@ l l l.
>>>  Interface    Attribute       Value
>>>  T{
>>>  .BR system ()
>>> -T}   Thread safety   MT-Safe
>>> +T}   Thread safety   MT-Unsafe
>>>  .TE
>>>  .SH CONFORMING TO
>>>  POSIX.1-2001, POSIX.1-2008, C89, C99.
>>>
>>
>> ________________________________
>>
>> CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
>>
diff mbox series

Patch

diff --git a/man3/system.3 b/man3/system.3
index aef40417a..8730fabd3 100644
--- a/man3/system.3
+++ b/man3/system.3
@@ -127,7 +127,7 @@  l l l.
 Interface	Attribute	Value
 T{
 .BR system ()
-T}	Thread safety	MT-Safe
+T}	Thread safety	MT-Unsafe
 .TE
 .SH CONFORMING TO
 POSIX.1-2001, POSIX.1-2008, C89, C99.