Re: [PATCH] clone.2: note EINVAL when exit_signal + bad flags

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
  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: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux