Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4840687ybv; Mon, 17 Feb 2020 06:59:56 -0800 (PST) X-Google-Smtp-Source: APXvYqycibqTCbEdB4P2Urplbc9vU8DBmktSXiW8ZhGXmR1C7v4FFv5OjrGQH8hWlqb1wPe+tiFL X-Received: by 2002:a05:6830:1d6e:: with SMTP id l14mr12113035oti.32.1581951596292; Mon, 17 Feb 2020 06:59:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581951596; cv=none; d=google.com; s=arc-20160816; b=k3caqm98BvB9G6R13Us/PXr1lrjNNeTA/IXqXjymBr1NpRybur6Kgq7j5RrIjPdoj6 XjrONk4wLix0mGmkgn5itF/Jt89POA+57eI8J5AI204IOdfv1wc1gJ9yjwWC5IIrKwM9 7faEPV/pFNPc9FRHcUQ9lw5TYnimjP65vYVU7cGROf4mDNLcySksLxth27f70cbJXSo0 +JsiHVja7Z0sJuPTQkTExcKvMN6f0uxQOhEC0mB9aFTcxjDZ2qUYX3NvdVvWw/qArtAk NJXqBRAor+pLnot7jDqPB3GDq5mjkd6S6kYOe4P76coH+GkgPXg+FBPOy/VzvzH5mSsJ 5RIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qO0/Tg7IJakPgsQ8yMx98JiSTNgky2xDVuHxFefFQEg=; b=dcKkKkUEmqtA7FmPAl5FZ7oUhK/NMsAQcu+HCH6T4SZ+sLY7ojTYNGqQaDvIVFkOHh hLqj15oyaCUYYzAypm4Sec0Y25BAJd9brA5HcdwpZBBoyouye6dDG3yVlFd68o5yhy9n 1lBZ+o0eVH5d8n0GbbWPWtPsvmJNnqdTECQMnSddhAyM9OegERd8m2CJu66WO2BLSvB6 xpOuAt0RnfwV41sQnLfP8A0RV0C1Gkr2lQIdvoMHoO/bl2kmkuskWDt9BvTbb51KjBj0 lIUtbJp/jh3MyJdz3e7XwkBbKpfSjfrXSo5bdRYfYuzyFnqovzoG6dYzOCc/MMA0TCxV TWcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si280666otf.87.2020.02.17.06.59.44; Mon, 17 Feb 2020 06:59:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729337AbgBQO7P (ORCPT + 99 others); Mon, 17 Feb 2020 09:59:15 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:46123 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbgBQO7O (ORCPT ); Mon, 17 Feb 2020 09:59:14 -0500 Received: from ip5f5bf7ec.dynamic.kabel-deutschland.de ([95.91.247.236] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1j3hra-0006Ab-1U; Mon, 17 Feb 2020 14:59:10 +0000 Date: Mon, 17 Feb 2020 15:59:08 +0100 From: Christian Brauner To: Michael Kerrisk Cc: Dmitry Safonov , Andrei Vagin , Linux Kernel , Dmitry Safonov <0x7f454c46@gmail.com>, Adrian Reber , Andy Lutomirski , Arnd Bergmann , Cyrill Gorcunov , "Eric W. Biederman" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Jeff Dike , Oleg Nesterov , Pavel Emelyanov , Shuah Khan , Thomas Gleixner , Vincenzo Frascino , containers , criu@openvz.org, Linux API , x86@kernel.org, Andrei Vagin Subject: Re: Time Namespaces: CLONE_NEWTIME and clone3()? Message-ID: <20200217145908.7epzz5nescccwvzv@wittgenstein> References: <20191112012724.250792-1-dima@arista.com> <20191112012724.250792-4-dima@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 17, 2020 at 03:20:55PM +0100, Michael Kerrisk wrote: > Hello Dmitry, Andrei, > > Is the CLONE_NEWTIME flag intended to be usable with clone3()? The > mail quoted below implies (in my reading) that this should be possible > once clone3() is available, which it is by now. (See also [1].) > > If the answer is yes, CLONE_NEWTIME should be usable with clone3(), > then I have a bug report and a question. > > I successfully used CLONE_NEWTIME with unshare(). But if I try to use > CLONE_NEWSIGNAL with clone3(), it errors out with EINVAL, because of s/CLONE_NEWSIGNAL/CLONE_NEWTIME/ > the following check in clone3_args_valid(): > > /* > * - make the CLONE_DETACHED bit reuseable for clone3 > * - make the CSIGNAL bits reuseable for clone3 > */ > if (kargs->flags & (CLONE_DETACHED | CSIGNAL)) > return false; > > The problem is that CLONE_NEWTIME matches one of the bits in the > CSIGNAL mask. If the intention is to allow CLONE_NEWTIME with > clone3(), then either the bit needs to be redefined, or the error > checking in clone3_args_valid() needs to be reworked. If this is intended to be useable with clone3() the check should be adapted to allow for CLONE_NEWTIME. (I asked about this a while ago I think.) But below rather sounds like it should simply be an unshare() flag. The code seems to set frozen_offsets to true right after copy_namespaces() in timens_on_fork(new_ns, tsk) and so the offsets can't be changed anymore unless I'm reading this wrong. Alternatives seem to either make timens_offsets writable once after fork and before exec, I guess - though that's probably not going to work with the vdso judging from timens_on_fork(). The other alternative is that Andrei and Dmitry send me a patch to enable CLONE_NEWTIME with clone3() by exposing struct timens_offsets (or a version of it) in the uapi and extend struct clone_args to include a pointer to a struct timens_offset that is _only_ set when CLONE_NEWTIME is set. Though the unshare() way sounds way less invasive simpler. Christian