Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4462419ybc; Fri, 15 Nov 2019 05:09:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzyfDMdvxlkyo7q1ADAcRW/gLaeK4MoXpf2nA2QNjcbVXUHJZAqFml3DdbxdRH9oDMKq7tx X-Received: by 2002:adf:e8ce:: with SMTP id k14mr14729375wrn.393.1573823395671; Fri, 15 Nov 2019 05:09:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573823395; cv=none; d=google.com; s=arc-20160816; b=kpGzC5qeUS0dJxtDigYs2E9Iwv3YyYM2GFkbYiKG8rR79ot8+jf0oAU0tJx+smfhhE UsSzm7HnSIGVvQ92JuZ09yYmVBnMofPiFkONXjnG9IXGCDycqxDMmqTB6W9WWKA4Cd1a wf1JgjS0KJ2fK0irtYe/PWATAwjMxhUQHtEaCdJCibrqmpiYliW5TfELpRUaNCv4GZqy wtL/0uPjdum7klCapU0KPE6tqzzJG3OTC4PDNHNkv2Vvp7t927g4Qj/7y0prT2Ejc3n/ 53gqXTs5VSnuUhOvwPdLUmpejp5ti5tz5qN8P6zWgW7VXQYSL3aCvo2aH/I+nTnAadxA bj/g== 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=hvHfCcf2szU17Yv1kf3IUno47cbg3w0zciZ8n5PBzH8=; b=sLTOpPFCdnYm/QW7Zr3NOapu8F6oUx0vA9BRPXKdPdk68k4qUmg/MIN8lcXHcfnmKZ 0mvrpbdLQO9UoTeouow+k2q1rV83ONQSdFpKP6os9uhElVxAdEHm+dqBPthQdXcGV8ME QyBbZkmKjywrRCxDAKPJVIlZ3LvSmXa/qqvm+HoEOcqsgcC5rTNMJ2CqI8b5zdC5SybC MAnHdSQiunnIuCa0fj/hwfeesKpPkyxhABrwg23Y4EdMeICtZdRt4f4xWPx4TwUKgA1n blN4Ph62jn+K5p9eu7ZviziOYNCz+oanZfiEArxqwiUOH/6DNnpSmpF3pUQ+aJhkhXYS KF3g== 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 x26si6274067eda.404.2019.11.15.05.09.31; Fri, 15 Nov 2019 05:09:55 -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 S1727427AbfKONIJ (ORCPT + 99 others); Fri, 15 Nov 2019 08:08:09 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:44171 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbfKONIJ (ORCPT ); Fri, 15 Nov 2019 08:08:09 -0500 Received: from [213.220.153.21] (helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iVbKU-0000T5-1V; Fri, 15 Nov 2019 13:08:02 +0000 Date: Fri, 15 Nov 2019 14:08:01 +0100 From: Christian Brauner To: Oleg Nesterov Cc: Andrei Vagin , Adrian Reber , Eric Biederman , Pavel Emelyanov , Jann Horn , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , linux-kernel@vger.kernel.org, Mike Rapoport , Radostin Stoyanov Subject: Re: [PATCH v10 1/2] fork: extend clone3() to support setting a PID Message-ID: <20191115130800.zntefr5ptabdngph@wittgenstein> References: <20191114142707.1608679-1-areber@redhat.com> <20191114191538.GC171963@gmail.com> <20191115093419.GA25528@redhat.com> <20191115095854.4vr6bgfz6ny5zbpd@wittgenstein> <20191115104909.GB25528@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191115104909.GB25528@redhat.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 15, 2019 at 11:49:10AM +0100, Oleg Nesterov wrote: > On 11/15, Christian Brauner wrote: > > > > +static int set_tid_next(pid_t *set_tid, size_t *size, int idx) > > +{ > > + int tid = 0; > > + > > + if (*size) { > > + tid = set_tid[idx]; > > + if (tid < 1 || tid >= pid_max) > > + return -EINVAL; > > + > > + /* > > + * Also fail if a PID != 1 is requested and > > + * no PID 1 exists. > > + */ > > + if (tid != 1 && !tmp->child_reaper) > > + return -EINVAL; > > + > > + if (!ns_capable(tmp->user_ns, CAP_SYS_ADMIN)) > > + return -EPERM; > > + > > + (*size)--; > > + } > > this needs more args, struct pid_namespace *tmp + pid_t pid_max > if (set_tid_size) { > tid = set_tid[ns->level - i]; > > retval = -EINVAL; > if (tid < 1 || tid >= pid_max) > goto out_free; I'm not a fan of this pattern of _not_ setting error codes in the actual error path t but I won't object. Christian