From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 614B5C433EF for ; Fri, 8 Apr 2022 11:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229550AbiDHLi1 (ORCPT ); Fri, 8 Apr 2022 07:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232486AbiDHLiZ (ORCPT ); Fri, 8 Apr 2022 07:38:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35E94762A9 for ; Fri, 8 Apr 2022 04:36:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C890761FFB for ; Fri, 8 Apr 2022 11:36:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id 35028C385A5 for ; Fri, 8 Apr 2022 11:36:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649417781; bh=SgotHmdHbiDfuudi0A4ALxiCgO08GNmjHKRkLOiKb68=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LmjlPOQ8PMF0VXlIxuuCyseGnqu2kkbZSiATenR5VFWi6Qkk9s2E2rg0DStDUl+8p PR3EpG4n5gWUdAmrL2RF9+Iq6y6IH6sO1Nz+MI6c6mGU8oyRqF7BNBxiUM80Dxk8JA kC1QCppS0qbpimZm84lLwUCRg+nklpoLh2OM6Xda54Fs1K69hzfEZ8XRPCoriQMEz5 iHO2qwEoOgnqnC0SCVSzccQqJiOcFzP5+PCQa0W6FRTvcjAhCnPVU/V6DgS4fzD7zC Wf+hLIzxs5KuwtILeipjpuVUkfv1Rwx1VyOqHwDij8hvaRfca8GwrOYuteXvkctkUC nfKveYjr36s1Q== Received: by aws-us-west-2-korg-bugzilla-1.web.codeaurora.org (Postfix, from userid 48) id 1C11AC05FCE; Fri, 8 Apr 2022 11:36:21 +0000 (UTC) From: bugzilla-daemon@kernel.org To: linux-man@vger.kernel.org Subject: [Bug 215769] vfork() returns EINVAL after unshare(CLONE_NEWTIME) Date: Fri, 08 Apr 2022 11:36:20 +0000 X-Bugzilla-Reason: None X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: AssignedTo documentation_man-pages@kernel-bugs.osdl.org X-Bugzilla-Product: Other X-Bugzilla-Component: Other X-Bugzilla-Version: 2.5 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: socketpair@gmail.com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: documentation_man-pages@kernel-bugs.osdl.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: component version product Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugzilla.kernel.org/ Auto-Submitted: auto-generated MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-man@vger.kernel.org https://bugzilla.kernel.org/show_bug.cgi?id=3D215769 =D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3 =D0=9C=D0=B0=D1=80= =D0=BA (socketpair@gmail.com) changed: What |Removed |Added ---------------------------------------------------------------------------- Component|man-pages |Other Version|unspecified |2.5 Product|Documentation |Other --- Comment #13 from =D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3= =D0=9C=D0=B0=D1=80=D0=BA (socketpair@gmail.com) --- Please help me to change Bugzilla fields in the issue. This is a kernel bug= as I think. Nothing should be changed in documentation. And also, please stop discussing how to correctly use vfork() (regarding modifying stack, glibc and so on). This issue is actually about vfork() + CLONE_NEWTIME. Regarding CLONE_VM. We have no problems for, say, PID namespace. Suppose we have parent process with two threads. Let's second thread calls vfork() and= is stopped as expected. So children process is running and the first thread of parent process too. They share VM, but getpid() will give different values = in them, right ? If YES, I don't see any stoppers for doing the same for CLONE_NEWTIME. If NO, this is a bug. Actually, yes: #define _GNU_SOURCE 1 #include #include #include #include #include #include #include #include static void *showpid (void *restrict arg) { (void) arg; for (int i =3D 0; i < 25; i++) { printf ("thr pid=3D%lu\n", (unsigned long) syscall (SYS_getpid)); struct timespec ts =3D { 0, 100000000 };<---->// 0.1 sec nanosleep (&ts, NULL); } return NULL; } int main (void) { pthread_t thr; if (pthread_create (&thr, NULL, showpid, NULL)) abort (); if (unshare (CLONE_NEWPID) =3D=3D -1) err (EXIT_FAILURE, "unshare(newpid)"); sleep (1);<--><------><------>// allow the thread to work for 1 second pid_t p =3D vfork (); if (!p) { static char qwe[100]; static struct timespec ts =3D { 1, 0 }; syscall (SYS_write, 1, qwe, sprintf (qwe, "child: %lu\n", (unsigned lon= g) syscall (SYS_getpid))); syscall (SYS_clock_nanosleep, CLOCK_MONOTONIC, 0, &ts, NULL); syscall (SYS_write, 1, qwe, sprintf (qwe, "child sleep complete\n")); _exit (0); } if (p =3D=3D -1) err (EXIT_FAILURE, "vfork"); printf("Waiting for child\n"); waitpid (p, NULL, 0); pthread_join (thr, NULL); } $ sudo ./a.out=20 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 child: 1 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 child sleep complete Waiting for child thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 thr pid=3D46371 --=20 You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.=