Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1109990ybl; Tue, 13 Aug 2019 07:31:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvCKciy62ml7T9utLkzK78+kN8m8Wox+bmGdc2Lqg2F0fk+Kl+fv6M/1vFHoqxKxy0BqD9 X-Received: by 2002:a63:5162:: with SMTP id r34mr33728393pgl.229.1565706709601; Tue, 13 Aug 2019 07:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565706709; cv=none; d=google.com; s=arc-20160816; b=wWVUnbDWXSOg57M/9B0nwnMTHgGnC0ufZWgpXD0bX5KbYJk/I28r8+N+Juif+jATkB CswiRMdeaRi/XXQkhQDCkB2T/+OktVxq6Trg7wFOxwaVTE1bklMCEW7ZwAcqT2X78qIa Qc3naGAlftJ2RI/wGKjfRBhOdvn04pOJEspSLK2QKCMR9bBl469588z7xkf8zo+XrLsF pKU8oMGs3tvjneKGyaazDwotDoKiroPnY9jMqOUWmR9bT/qSdIdqbooGQtbJhAr1xtYr 3cPRi+EFWMVcOXTkqr10Q1HutFxKMpDbSr1o4MYHPZOowDs8Jgr8BqYS/kFLRMUM6JpB SBKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=T2uhUQsIrhkU1c5KvxjP7soiV3JeJu3JljEpHOtqS/0=; b=Jr4XtgXbzR7RN9PGtBnMtsUlgUuaL5IZyz/YY3rUmWQDRVLoOY20beJ1WX3nSLzRmv pOhH0XhyokNxrYIQkDTyzOIQ13BDi39u4GVS4uoQGD5eC9fUTdOS0F0EktaJ8Exfwg0f 7gcRRaS68Cy5fcLqSdtZjjkKxbIvle+hkd+5JYfjqydjx8yF0AG23Rx0trRvKjxCbRdT /80SBeYRHZebB32EUDaQwoV0S6wj7RBQIjwva2DV6Vn0sz3aqlNZfkFwc1ubVaA9j3vt TqMxwVD1n/i8geIgrNNud95APkNo2+Ca50wdzpNiJKatwBr/cMSaEnY6HsJ0YDSVX65q 1qww== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e92si59803048pld.312.2019.08.13.07.31.33; Tue, 13 Aug 2019 07:31:49 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbfHMOa1 (ORCPT + 99 others); Tue, 13 Aug 2019 10:30:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50711 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729304AbfHMOa1 (ORCPT ); Tue, 13 Aug 2019 10:30:27 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35F5C30605EF; Tue, 13 Aug 2019 14:30:27 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.136]) by smtp.corp.redhat.com (Postfix) with SMTP id 04EA56092F; Tue, 13 Aug 2019 14:30:24 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 13 Aug 2019 16:30:26 +0200 (CEST) Date: Tue, 13 Aug 2019 16:30:24 +0200 From: Oleg Nesterov To: Adrian Reber Cc: Christian Brauner , Eric Biederman , Pavel Emelianov , Jann Horn , Dmitry Safonov <0x7f454c46@gmail.com>, linux-kernel@vger.kernel.org, Andrei Vagin , Mike Rapoport , Radostin Stoyanov Subject: Re: [PATCH v6 1/2] fork: extend clone3() to support setting a PID Message-ID: <20190813143023.GC6971@redhat.com> References: <20190812200939.23784-1-areber@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190812200939.23784-1-areber@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 13 Aug 2019 14:30:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/12, Adrian Reber wrote: > > The main motivation to add set_tid to clone3() is CRIU. > > To restore a process with the same PID/TID CRIU currently uses > /proc/sys/kernel/ns_last_pid. It writes the desired (PID - 1) to > ns_last_pid and then (quickly) does a clone(). This works most of the > time, but it is racy. It is also slow as it requires multiple syscalls. > > Extending clone3() to support set_tid makes it possible restore a > process using CRIU without accessing /proc/sys/kernel/ns_last_pid and > race free (as long as the desired PID/TID is available). > > This clone3() extension places the same restrictions (CAP_SYS_ADMIN) > on clone3() with set_tid as they are currently in place for ns_last_pid. > > Signed-off-by: Adrian Reber Reviewed-by: Oleg Nesterov