lkml.org 
[lkml]   [2022]   [Mar]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectBUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME)
test:
----------------------------------------
#define _GNU_SOURCE 1
#include <stdio.h>
#include <sched.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <err.h>

#ifndef CLONE_NEWTIME
#define CLONE_NEWTIME 0x00000080
#endif

int main (void)
{
if (unshare (CLONE_NEWTIME)) err (EXIT_FAILURE, "UNSHARE_NEWTIME");

pid_t pid;
switch (pid=vfork ())
{
case 0:
_exit(0);
case -1:
err(EXIT_FAILURE, "vfork BUG");
default:
waitpid(pid, NULL, 0);
}
return 0;
}
-----------------------------------------------

Seems the bug in kernel/fork.c. It does not check for CLONE_VFORK

if (clone_flags & (CLONE_THREAD | CLONE_VM)) {
if (nsp->time_ns != nsp->time_ns_for_children)
return ERR_PTR(-EINVAL);
}

-----------------------------------
Changing vfork() to fork() in the program works ok.
The bug has been found during regression in our system because Python
3.10 runs subprocesses using vfork()+execve().

--
Segmentation fault

\
 
 \ /
  Last update: 2022-03-31 10:37    [W:0.032 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site