Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4894249ybi; Tue, 30 Jul 2019 09:59:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqygNbEo+myXD4dRQoylnH4DB5g7wVJa/4AhO+p0qiwwFIkCwUOodyorHXtYXFCB0uJfMJOf X-Received: by 2002:a17:90a:3548:: with SMTP id q66mr119045028pjb.17.1564505990726; Tue, 30 Jul 2019 09:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564505990; cv=none; d=google.com; s=arc-20160816; b=kOJ3p4cFPR2/njJ6KqQP8FWt6HXNHEaH6KvLsCHHfJNjw8SxCJJSsSsBUuEFpG5T4w YqN1sXUxcOdfymkBD83bpiqVZGsKLyIpkh4BUNiZ6LLmjba8Oo6lTg7tX6NAKJklZwQ/ o1y1Jut2eXeKWyVwhBnJjamSmhrPq3G1trgdf37AnAH9xZPQPTy5086c2hH4M/RCMKB1 g7o8fdfYRgo22SUSbRJ9kCpckUx+/v2T79WMq3FYLvfRkfoKAis7W1Gx0R4uOrvWHX6G JceoYj7lqxW9J7mCuXkmILRFwxcGsj5uld6ndBjIKzMLFhMU0mPmEt82/obbcsQcIT/C nYMA== 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=5ZiMM8RqYg7jZD3xqI11vdbzv8AzEDOfRyCtash6hS8=; b=wGcdxAzCtIDs7U8MIzE9l1VKpWRNI1AWiJetbyrF0noktBuaU3fojc+LSKAMTYNegl UUsFeWoczDcthGyJAJ7aSosm0TwG8UblY60kPev6K+NyBLD3DWrodm4koEG8l8y9/vCB M+zngYGh5ZFbB3+ylzjNlkzL9fhJxQwp3EfoN67ZIVrzpdNT1+8VP/fwwyWTG4nJo3Bi YDBms7g7lhxcNdVP/YQEHLKNgIjY97lFXFUrAWQnMiMACPVbk0ZiwSk4t803PtYQO97+ kF0cfuwlqyU16e0GC1C+bS+9rPQ0yBuhnWNyveRiHu+d0jwY1EzX7J0LXeyQmsOzhj7e Nc4Q== 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 29si16935589pgw.326.2019.07.30.09.59.35; Tue, 30 Jul 2019 09:59:50 -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 S1729233AbfG3Qzm (ORCPT + 99 others); Tue, 30 Jul 2019 12:55:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46742 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbfG3Qzm (ORCPT ); Tue, 30 Jul 2019 12:55:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 34F23307D90D; Tue, 30 Jul 2019 16:55:42 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.136]) by smtp.corp.redhat.com (Postfix) with SMTP id 598BA19C5B; Tue, 30 Jul 2019 16:55:40 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 30 Jul 2019 18:55:41 +0200 (CEST) Date: Tue, 30 Jul 2019 18:55:39 +0200 From: Oleg Nesterov To: Adrian Reber Cc: Christian Brauner , Eric Biederman , Pavel Emelianov , Jann Horn , linux-kernel@vger.kernel.org, Andrei Vagin , Mike Rapoport , Radostin Stoyanov Subject: Re: [PATCH 1/2] fork: extend clone3() to support CLONE_SET_TID Message-ID: <20190730165538.GE18501@redhat.com> References: <20190729163355.4530-1-areber@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190729163355.4530-1-areber@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 30 Jul 2019 16:55:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/29, Adrian Reber wrote: > > @@ -186,12 +187,26 @@ struct pid *alloc_pid(struct pid_namespace *ns) > if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS) > pid_min = RESERVED_PIDS; > > + if (set_tid) { > + if ((set_tid >= pid_max) || ((set_tid != 1) && > + (idr_get_cursor(&tmp->idr) <= 1))) { I think the (set_tid != 1) && idr_get_cursor() <= 1 check needs a comment... > + spin_unlock_irq(&pidmap_lock); > + retval = -EINVAL; > + goto out_free; > + } > + min_p = set_tid; > + max_p = set_tid + 1; > + set_tid = 0; > + } else { > + min_p = pid_min; > + max_p = pid_max; > + } > /* > * Store a null pointer so find_pid_ns does not find > * a partially initialized PID (see below). > */ > - nr = idr_alloc_cyclic(&tmp->idr, NULL, pid_min, > - pid_max, GFP_ATOMIC); > + nr = idr_alloc_cyclic(&tmp->idr, NULL, min_p, > + max_p, GFP_ATOMIC); do we really want _cyclic() which updates idr->idr_next if set_tid? perhaps idr_alloc() makes more sense? Oleg.