mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] clone: Return EINVAL for null stack
@ 2022-08-02 11:30 Tudor Cretu
  2022-08-02 18:53 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Tudor Cretu @ 2022-08-02 11:30 UTC (permalink / raw)
  To: musl; +Cc: Tudor Cretu

This change aligns the clone wrapper with the man page. If the stack is
null, clone sets errno to EINVAL, instead of throwing a segmentation fault.
---
 src/linux/clone.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/linux/clone.c b/src/linux/clone.c
index 8c1af7d3..43a6803b 100644
--- a/src/linux/clone.c
+++ b/src/linux/clone.c
@@ -1,4 +1,5 @@
 #define _GNU_SOURCE
+#include <errno.h>
 #include <stdarg.h>
 #include <unistd.h>
 #include <sched.h>
@@ -11,6 +12,10 @@ int clone(int (*func)(void *), void *stack, int flags, void *arg, ...)
 	pid_t *ptid, *ctid;
 	void  *tls;
 
+	if (!stack) {
+		return __syscall_ret(-EINVAL);
+	}
+
 	va_start(ap, arg);
 	ptid = va_arg(ap, pid_t *);
 	tls  = va_arg(ap, void *);
-- 
2.25.1


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

end of thread, other threads:[~2022-08-03 16:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 11:30 [musl] [PATCH] clone: Return EINVAL for null stack Tudor Cretu
2022-08-02 18:53 ` Rich Felker
2022-08-03 14:42   ` Tudor Cretu
2022-08-03 16:42     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).