* [PATCH] clone.2: note EINVAL when exit_signal + bad flags
@ 2022-12-02 22:44 Jack Pearson
2022-12-09 19:49 ` Alejandro Colomar
0 siblings, 1 reply; 9+ messages in thread
From: Jack Pearson @ 2022-12-02 22:44 UTC (permalink / raw)
To: linux-man, alx.manpages, mtk.manpages; +Cc: Jack Pearson
Document that Linux will report EINVAL when exit_signal is specified and
either CLONE_THREAD or CLONE_PARENT is specified.
From clone3_args_valid in Linux:
```
if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
kargs->exit_signal)
return false;
```
I have verified that this happens on my kernel with a small program, and
that this doesn't happen with normal `clone` through the glibc helper.
The program:
```
#include <stdio.h>
#include <linux/sched.h>
#include <signal.h>
#include <sys/syscall.h>
#include <unistd.h>
int main() {
struct clone_args ca = {
.flags = CLONE_THREAD | CLONE_SIGHAND | CLONE_VM,
.exit_signal = SIGCHLD, // comment me out to fix error
.set_tid_size = 0,
};
syscall(SYS_clone3, &ca, sizeof(struct clone_args));
perror("");
}
```
Signed-off-by: Jack Pearson <jack@pearson.onl>
---
man2/clone.2 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/man2/clone.2 b/man2/clone.2
index 093630859..a0fa50d83 100644
--- a/man2/clone.2
+++ b/man2/clone.2
@@ -1433,6 +1433,16 @@ One of the PIDs specified in
.I set_tid
was an invalid.
.TP
+.BR EINVAL " (" clone3 "() only)"
+.\" commit 7f192e3cd316ba58c88dfa26796cf77789dd9872
+.B CLONE_THREAD
+or
+.B CLONE_PARENT
+was specified in the
+.I flags
+mask, but a signal was specified in
+.I exit_signal.
+.TP
.BR EINVAL " (AArch64 only, Linux 4.6 and earlier)"
.I stack
was not aligned to a 128-bit boundary.
--
2.35.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-02 22:44 [PATCH] clone.2: note EINVAL when exit_signal + bad flags Jack Pearson
@ 2022-12-09 19:49 ` Alejandro Colomar
2022-12-13 2:53 ` Carlos O'Donell
0 siblings, 1 reply; 9+ messages in thread
From: Alejandro Colomar @ 2022-12-09 19:49 UTC (permalink / raw)
To: Jack Pearson, Carlos O'Donell, H.J. Lu; +Cc: linux-man
[-- Attachment #1.1: Type: text/plain, Size: 1932 bytes --]
Hi Jack,
On 12/2/22 23:44, Jack Pearson wrote:
> Document that Linux will report EINVAL when exit_signal is specified and
> either CLONE_THREAD or CLONE_PARENT is specified.
>
> From clone3_args_valid in Linux:
> ```
> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
> kargs->exit_signal)
> return false;
> ```
>
> I have verified that this happens on my kernel with a small program, and
> that this doesn't happen with normal `clone` through the glibc helper.
Could you please also send a test program with the glibc wrapper?
BTW, glibc has a clone3(2) wrapper since last year. It would be interesting to
document it instead of the raw syscall.
Cheers,
Alex
>
> The program:
>
> ```
> #include <stdio.h>
> #include <linux/sched.h>
> #include <signal.h>
> #include <sys/syscall.h>
> #include <unistd.h>
>
> int main() {
> struct clone_args ca = {
> .flags = CLONE_THREAD | CLONE_SIGHAND | CLONE_VM,
> .exit_signal = SIGCHLD, // comment me out to fix error
> .set_tid_size = 0,
> };
> syscall(SYS_clone3, &ca, sizeof(struct clone_args));
> perror("");
> }
> ```
>
> Signed-off-by: Jack Pearson <jack@pearson.onl>
> ---
> man2/clone.2 | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/man2/clone.2 b/man2/clone.2
> index 093630859..a0fa50d83 100644
> --- a/man2/clone.2
> +++ b/man2/clone.2
> @@ -1433,6 +1433,16 @@ One of the PIDs specified in
> .I set_tid
> was an invalid.
> .TP
> +.BR EINVAL " (" clone3 "() only)"
> +.\" commit 7f192e3cd316ba58c88dfa26796cf77789dd9872
> +.B CLONE_THREAD
> +or
> +.B CLONE_PARENT
> +was specified in the
> +.I flags
> +mask, but a signal was specified in
> +.I exit_signal.
> +.TP
> .BR EINVAL " (AArch64 only, Linux 4.6 and earlier)"
> .I stack
> was not aligned to a 128-bit boundary.
> --
> 2.35.1
>
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-09 19:49 ` Alejandro Colomar
@ 2022-12-13 2:53 ` Carlos O'Donell
2022-12-13 22:59 ` Alejandro Colomar
2022-12-14 21:00 ` Jack Pearson
0 siblings, 2 replies; 9+ messages in thread
From: Carlos O'Donell @ 2022-12-13 2:53 UTC (permalink / raw)
To: Alejandro Colomar, Jack Pearson, H.J. Lu; +Cc: linux-man
On 12/9/22 14:49, Alejandro Colomar wrote:
> Hi Jack,
>
> On 12/2/22 23:44, Jack Pearson wrote:
>> Document that Linux will report EINVAL when exit_signal is specified and
>> either CLONE_THREAD or CLONE_PARENT is specified.
>>
>> From clone3_args_valid in Linux:
>> ```
>> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
>> kargs->exit_signal)
>> return false;
>> ```
>>
>> I have verified that this happens on my kernel with a small program, and
>> that this doesn't happen with normal `clone` through the glibc helper.
>
> Could you please also send a test program with the glibc wrapper?
>
> BTW, glibc has a clone3(2) wrapper since last year. It would be interesting to document it instead of the raw syscall.
glibc does not have a clone3 wrapper.
glibc has an internal non-exported __clone3 interface that we use for pthreads,
and likely soon for posix_spawn.
We have not yet chosen to export clone3 as a public global symbol that developers
can use.
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-13 2:53 ` Carlos O'Donell
@ 2022-12-13 22:59 ` Alejandro Colomar
2022-12-14 21:00 ` Jack Pearson
1 sibling, 0 replies; 9+ messages in thread
From: Alejandro Colomar @ 2022-12-13 22:59 UTC (permalink / raw)
To: Carlos O'Donell, Jack Pearson, H.J. Lu; +Cc: linux-man
[-- Attachment #1.1: Type: text/plain, Size: 1661 bytes --]
Hi Carlos,
On 12/13/22 03:53, Carlos O'Donell wrote:
> On 12/9/22 14:49, Alejandro Colomar wrote:
>> Hi Jack,
>>
>> On 12/2/22 23:44, Jack Pearson wrote:
>>> Document that Linux will report EINVAL when exit_signal is specified and
>>> either CLONE_THREAD or CLONE_PARENT is specified.
>>>
>>> From clone3_args_valid in Linux:
>>> ```
>>> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
>>> kargs->exit_signal)
>>> return false;
>>> ```
>>>
>>> I have verified that this happens on my kernel with a small program, and
>>> that this doesn't happen with normal `clone` through the glibc helper.
>>
>> Could you please also send a test program with the glibc wrapper?
>>
>> BTW, glibc has a clone3(2) wrapper since last year. It would be interesting to document it instead of the raw syscall.
>
> glibc does not have a clone3 wrapper.
>
> glibc has an internal non-exported __clone3 interface that we use for pthreads,
> and likely soon for posix_spawn.
>
> We have not yet chosen to export clone3 as a public global symbol that developers
> can use.
Ahh, thanks, I saw the following and thought that you had added it as a public
wrapper.
commit 5adb0e14a5cc9e011e58a7aaf193b598ecbd7b07
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 12 11:02:47 2021 -0700
i386: Add the clone3 wrapper
extern int clone3 (struct clone_args *__cl_args, size_t __size,
int (*__func) (void *__arg), void *__arg);
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Thanks!
Alex
>
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-13 2:53 ` Carlos O'Donell
2022-12-13 22:59 ` Alejandro Colomar
@ 2022-12-14 21:00 ` Jack Pearson
2022-12-14 21:02 ` Alejandro Colomar
1 sibling, 1 reply; 9+ messages in thread
From: Jack Pearson @ 2022-12-14 21:00 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man
On 12/12/22 18:53, Carlos O'Donell wrote:
> On 12/9/22 14:49, Alejandro Colomar wrote:
>> Hi Jack,
>>
>> On 12/2/22 23:44, Jack Pearson wrote:
>>> Document that Linux will report EINVAL when exit_signal is specified and
>>> either CLONE_THREAD or CLONE_PARENT is specified.
>>>
>>> From clone3_args_valid in Linux:
>>> ```
>>> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
>>> kargs->exit_signal)
>>> return false;
>>> ```
>>>
>>> I have verified that this happens on my kernel with a small program, and
>>> that this doesn't happen with normal `clone` through the glibc helper.
>>
>> Could you please also send a test program with the glibc wrapper?
>>
>> BTW, glibc has a clone3(2) wrapper since last year. It would be interesting to document it instead of the raw syscall.
>
> glibc does not have a clone3 wrapper.
>
> glibc has an internal non-exported __clone3 interface that we use for pthreads,
> and likely soon for posix_spawn.
>
> We have not yet chosen to export clone3 as a public global symbol that developers
> can use.
>
Ahhh, that's why I couldn't find it in the headers.
Incoming patch with the glibc clone wrapper test program.
Jack
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-14 21:00 ` Jack Pearson
@ 2022-12-14 21:02 ` Alejandro Colomar
2022-12-14 21:13 ` Jack Pearson
0 siblings, 1 reply; 9+ messages in thread
From: Alejandro Colomar @ 2022-12-14 21:02 UTC (permalink / raw)
To: Jack Pearson; +Cc: linux-man, GNU C Library, Carlos O'Donell
[-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --]
Hi Jack,
Please keep glibc and Carlos in the loop.
Thanks,
Alex
On 12/14/22 22:00, Jack Pearson wrote:
> On 12/12/22 18:53, Carlos O'Donell wrote:
>> On 12/9/22 14:49, Alejandro Colomar wrote:
>>> Hi Jack,
>>>
>>> On 12/2/22 23:44, Jack Pearson wrote:
>>>> Document that Linux will report EINVAL when exit_signal is specified and
>>>> either CLONE_THREAD or CLONE_PARENT is specified.
>>>>
>>>> From clone3_args_valid in Linux:
>>>> ```
>>>> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
>>>> kargs->exit_signal)
>>>> return false;
>>>> ```
>>>>
>>>> I have verified that this happens on my kernel with a small program, and
>>>> that this doesn't happen with normal `clone` through the glibc helper.
>>>
>>> Could you please also send a test program with the glibc wrapper?
>>>
>>> BTW, glibc has a clone3(2) wrapper since last year. It would be interesting
>>> to document it instead of the raw syscall.
>>
>> glibc does not have a clone3 wrapper.
>>
>> glibc has an internal non-exported __clone3 interface that we use for pthreads,
>> and likely soon for posix_spawn.
>>
>> We have not yet chosen to export clone3 as a public global symbol that developers
>> can use.
>>
>
> Ahhh, that's why I couldn't find it in the headers.
>
> Incoming patch with the glibc clone wrapper test program.
>
>
> Jack
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2022-12-14 21:02 ` Alejandro Colomar
@ 2022-12-14 21:13 ` Jack Pearson
0 siblings, 0 replies; 9+ messages in thread
From: Jack Pearson @ 2022-12-14 21:13 UTC (permalink / raw)
To: Alejandro Colomar; +Cc: linux-man, GNU C Library, Carlos O'Donell
Will do. I'm still learning the etiquette for developing over mailing
list. Trying not to fill up peoples' inboxes with junk y'know.
Thanks,
Jack
On 12/14/22 13:02, Alejandro Colomar wrote:
> Hi Jack,
>
> Please keep glibc and Carlos in the loop.
>
> Thanks,
>
> Alex
>
> On 12/14/22 22:00, Jack Pearson wrote:
>> On 12/12/22 18:53, Carlos O'Donell wrote:
>>> On 12/9/22 14:49, Alejandro Colomar wrote:
>>>> Hi Jack,
>>>>
>>>> On 12/2/22 23:44, Jack Pearson wrote:
>>>>> Document that Linux will report EINVAL when exit_signal is
>>>>> specified and
>>>>> either CLONE_THREAD or CLONE_PARENT is specified.
>>>>>
>>>>> From clone3_args_valid in Linux:
>>>>> ```
>>>>> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
>>>>> kargs->exit_signal)
>>>>> return false;
>>>>> ```
>>>>>
>>>>> I have verified that this happens on my kernel with a small
>>>>> program, and
>>>>> that this doesn't happen with normal `clone` through the glibc helper.
>>>>
>>>> Could you please also send a test program with the glibc wrapper?
>>>>
>>>> BTW, glibc has a clone3(2) wrapper since last year. It would be
>>>> interesting to document it instead of the raw syscall.
>>>
>>> glibc does not have a clone3 wrapper.
>>>
>>> glibc has an internal non-exported __clone3 interface that we use for
>>> pthreads,
>>> and likely soon for posix_spawn.
>>>
>>> We have not yet chosen to export clone3 as a public global symbol
>>> that developers
>>> can use.
>>>
>>
>> Ahhh, that's why I couldn't find it in the headers.
>>
>> Incoming patch with the glibc clone wrapper test program.
>>
>>
>> Jack
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags
2023-02-28 23:42 Jack Pearson
@ 2023-03-01 21:31 ` Alejandro Colomar
0 siblings, 0 replies; 9+ messages in thread
From: Alejandro Colomar @ 2023-03-01 21:31 UTC (permalink / raw)
To: Jack Pearson, linux-man; +Cc: Carlos O'Donell, GNU C Library
[-- Attachment #1.1: Type: text/plain, Size: 2279 bytes --]
Hi Jack,
On 3/1/23 00:42, Jack Pearson wrote:
> Document that Linux will report EINVAL when exit_signal is specified and
> either CLONE_THREAD or CLONE_PARENT is specified.
>
> From clone3_args_valid in Linux:
> ```
> if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
> kargs->exit_signal)
> return false;
> ```
>
> I have verified that this happens on my kernel with a small program:
>
> ```
> #include <stdio.h>
> #include <linux/sched.h>
> #include <signal.h>
> #include <sys/syscall.h>
> #include <unistd.h>
>
> int main() {
> struct clone_args ca = {
> .flags = CLONE_THREAD | CLONE_SIGHAND | CLONE_VM,
> .exit_signal = SIGCHLD, // comment me out to fix error
> .set_tid_size = 0,
> };
> syscall(SYS_clone3, &ca, sizeof(struct clone_args));
> perror("");
> }
> ```
>
> And I have verified that this doesn't happen with normal `clone` through
> the glibc helper:
>
> ```
> #define _GNU_SOURCE
>
> #include <sched.h>
> #include <signal.h>
> #include <stdio.h>
> #include <sys/mman.h>
>
> int do_nothing(void *_) { return 0; }
>
> int main() {
> void *map = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE,
> MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
> void *stack_top = map + 0x10000 - 1;
> clone(do_nothing, stack_top,
> CLONE_THREAD | CLONE_VM | CLONE_SIGHAND | SIGCHLD, NULL);
> perror("");
> }
> ```
>
> Signed-off-by: Jack Pearson <jack@pearson.onl>
> ---
> man2/clone.2 | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Patch applied. Thanks!
Alex
>
> diff --git a/man2/clone.2 b/man2/clone.2
> index d63895189..be802a280 100644
> --- a/man2/clone.2
> +++ b/man2/clone.2
> @@ -1436,6 +1436,16 @@ One of the PIDs specified in
> .I set_tid
> was an invalid.
> .TP
> +.BR EINVAL " (" clone3 "() only)"
> +.\" commit 7f192e3cd316ba58c88dfa26796cf77789dd9872
> +.B CLONE_THREAD
> +or
> +.B CLONE_PARENT
> +was specified in the
> +.I flags
> +mask, but a signal was specified in
> +.I exit_signal.
> +.TP
> .BR EINVAL " (AArch64 only, Linux 4.6 and earlier)"
> .I stack
> was not aligned to a 128-bit boundary.
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] clone.2: note EINVAL when exit_signal + bad flags
@ 2023-02-28 23:42 Jack Pearson
2023-03-01 21:31 ` Alejandro Colomar
0 siblings, 1 reply; 9+ messages in thread
From: Jack Pearson @ 2023-02-28 23:42 UTC (permalink / raw)
To: Alex Colomar, linux-man, GNU C Library, Carlos O'Donell; +Cc: Jack Pearson
Document that Linux will report EINVAL when exit_signal is specified and
either CLONE_THREAD or CLONE_PARENT is specified.
From clone3_args_valid in Linux:
```
if ((kargs->flags & (CLONE_THREAD | CLONE_PARENT)) &&
kargs->exit_signal)
return false;
```
I have verified that this happens on my kernel with a small program:
```
#include <stdio.h>
#include <linux/sched.h>
#include <signal.h>
#include <sys/syscall.h>
#include <unistd.h>
int main() {
struct clone_args ca = {
.flags = CLONE_THREAD | CLONE_SIGHAND | CLONE_VM,
.exit_signal = SIGCHLD, // comment me out to fix error
.set_tid_size = 0,
};
syscall(SYS_clone3, &ca, sizeof(struct clone_args));
perror("");
}
```
And I have verified that this doesn't happen with normal `clone` through
the glibc helper:
```
#define _GNU_SOURCE
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <sys/mman.h>
int do_nothing(void *_) { return 0; }
int main() {
void *map = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE,
MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
void *stack_top = map + 0x10000 - 1;
clone(do_nothing, stack_top,
CLONE_THREAD | CLONE_VM | CLONE_SIGHAND | SIGCHLD, NULL);
perror("");
}
```
Signed-off-by: Jack Pearson <jack@pearson.onl>
---
man2/clone.2 | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/man2/clone.2 b/man2/clone.2
index d63895189..be802a280 100644
--- a/man2/clone.2
+++ b/man2/clone.2
@@ -1436,6 +1436,16 @@ One of the PIDs specified in
.I set_tid
was an invalid.
.TP
+.BR EINVAL " (" clone3 "() only)"
+.\" commit 7f192e3cd316ba58c88dfa26796cf77789dd9872
+.B CLONE_THREAD
+or
+.B CLONE_PARENT
+was specified in the
+.I flags
+mask, but a signal was specified in
+.I exit_signal.
+.TP
.BR EINVAL " (AArch64 only, Linux 4.6 and earlier)"
.I stack
was not aligned to a 128-bit boundary.
--
2.39.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-03-01 21:31 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 22:44 [PATCH] clone.2: note EINVAL when exit_signal + bad flags Jack Pearson
2022-12-09 19:49 ` Alejandro Colomar
2022-12-13 2:53 ` Carlos O'Donell
2022-12-13 22:59 ` Alejandro Colomar
2022-12-14 21:00 ` Jack Pearson
2022-12-14 21:02 ` Alejandro Colomar
2022-12-14 21:13 ` Jack Pearson
2023-02-28 23:42 Jack Pearson
2023-03-01 21:31 ` Alejandro Colomar
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.