mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: "Марк Коренберг" <socketpair@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <christian@brauner.io>
Subject: Re: BUG: vfork() returns EINVAL after unshare(CLONE_NEWTIME)
Date: Tue, 3 May 2022 10:26:04 -0700	[thread overview]
Message-ID: <dcb534d5-e9b7-74b3-4088-eb498adb9ec2@infradead.org> (raw)
In-Reply-To: <CAEmTpZGJxtTuq8LDTLDK4V8to_Z30WEmo=p_2umboHvZaDr=Xg@mail.gmail.com>

[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

      reply	other threads:[~2022-05-03 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-31  8:36 Марк Коренберг
2022-05-03 17:26 ` Randy Dunlap [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dcb534d5-e9b7-74b3-4088-eb498adb9ec2@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=christian@brauner.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=socketpair@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®