mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* BUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME)
@ 2022-03-31  8:36 Марк Коренберг
  2022-05-03 17:26 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Марк Коренберг @ 2022-03-31  8:36 UTC (permalink / raw)
  To: linux-kernel

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

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

* Re: BUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME)
  2022-03-31  8:36 BUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME) Марк Коренберг
@ 2022-05-03 17:26 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2022-05-03 17:26 UTC (permalink / raw)
  To: Марк
	Коренберг,
	linux-kernel, Alexander Viro, Christian Brauner

[add some readers:]

On 3/31/22 01:36, Марк Коренберг wrote:
> 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().
> 

-- 
~Randy

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

end of thread, other threads:[~2022-05-03 17:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31  8:36 BUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME) Марк Коренберг
2022-05-03 17:26 ` Randy Dunlap

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®