Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp713774yba; Wed, 15 May 2019 08:41:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+aXGDGvBHHc+LcdTHmKwtvaJVixF/fGVBjZQbN38Yd32fxoF95SPGNTD0JfzmMuFlHIuu X-Received: by 2002:a62:ab10:: with SMTP id p16mr16274096pff.222.1557934904656; Wed, 15 May 2019 08:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557934904; cv=none; d=google.com; s=arc-20160816; b=huN5D49QlED9Y50p1o+tQgWHsuax0+YUq4gYyAQCTfO/+9C0s8VopNaCTpGVTFl0iG YyWmbOpXguhq6E/TknQ1nmFfJyulLjNJg2bcUWxaX+PehKXh5OlfW/J//K5L6197Gd6f gLDNZzOMvjhiuMVVI7EINKbte1hqKe3Vd2V+XY+E0z1lNvUomaxd1hfFkb8apFXf4T9w raiTnlybmltZYmLX9yNZDRha2FLeG53CnTJX69iJiUHy49rwhJ7vn14LQwLUc/fuy/An Sz1N1JUclU0aq42L0EE+9VBeybpBG9rAZxuaXsrQMga5FRoxQssQcuVvqqaro64gKeRp mPFQ== 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:dkim-signature; bh=xdgkq7E7+92ZW8x2Wkn7bfn+NRy1PNeG8DcUh6bxPio=; b=oSCsscY4J/Tv02ileNXQZeFwLPpe6zMy2xVbVpywpgtS8NVPsBdiknRdT121+3u0d4 2nPyIOG15VJLPse1NDuJPiVZoKmwAei/yvxidhJ+cXsgHShju6v6nr/XXqaL+i3KM2it JSJpLGLq1BrvAP55IjNB6a8d5xLPqQqA+FNbODtBFRDuSEflWB6MUHDJzFxyKEeQArQG 7fIyS4OSV1iaw3RH4pZh3WWoPRA8G2muQn8sAJe7xygiAiei0YpUfVJu7UmHfM0TlNs+ Zmn2hG0WfwH76jyI+DlGvNQcutlYfdeslpHfmTdfZjjpocu0cjTghGgK0uuRf5Pimfxs whLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=bfuTPZdA; 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 c137si2527589pfb.185.2019.05.15.08.41.29; Wed, 15 May 2019 08:41:44 -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; dkim=pass header.i=@brauner.io header.s=google header.b=bfuTPZdA; 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 S1728428AbfEOPkW (ORCPT + 99 others); Wed, 15 May 2019 11:40:22 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:39944 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728405AbfEOPkU (ORCPT ); Wed, 15 May 2019 11:40:20 -0400 Received: by mail-ed1-f65.google.com with SMTP id j12so431157eds.7 for ; Wed, 15 May 2019 08:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xdgkq7E7+92ZW8x2Wkn7bfn+NRy1PNeG8DcUh6bxPio=; b=bfuTPZdAtZJEgr+LRkX72jzoj84BPgpwvQPX7TINdboNhdzKNjJGvDzVvqvaaAh8Km iqTakFfgT4CJH4/cI6DSpX88s8Sfap4XoOKg2RDeLLxirLNHPqbOEbbj/6aCt06XF/9P X/us6CYYROr8DPKhgLY3SLh3ZeL1/eih/MR9PMbtrWfnl7CFIcBUAogBL0DY90Buod6x uECgJQv/SirIkuk/ECloyg95oA5R0oldoWVKg0CvJmRDjoeJEJ6edtPOwuBN6C4fcGnO BW2YYNw0hfraOKLIXAT/1qzfZOA/kv0yJLeVZCoYp69fdwL2bHQEsKScA+TLGS8z8aPr de9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xdgkq7E7+92ZW8x2Wkn7bfn+NRy1PNeG8DcUh6bxPio=; b=qbD0FwfK1boDigBEzLeIgrLy5eFWpjE3lF0k//lvG0lzS74iU8OOIojGrHVOhzN6P0 aM3nv9pjoVE/xxBjzYD3FKf+wRcbIeiK94svulGHWFAoiLJR8JDDmLulpH29bPcksfyL xGGCDT/Fy/vMwueiGlZV9zjX7H3IMacReBpnRjye/3JiT2YQlKrDII7JpIXTt+FnpHxm y0Qv6B9BlSz6PPwELXhsyCHKKsaLOX8FpVsa6We0yh9LKlyQi6swImO5mXA3rAe6BLb/ 5x2Djno/9ls2moejDgmRzoq0+QjdvbVlMre3JyCBWkOwY3iLYqh1eTpGBgOo1oRVt7gM +rfA== X-Gm-Message-State: APjAAAVUzOAsVgTSe2phc++Tqk3MsOOJrR125WOsXLug1OUQsxLms1/4 7dJpdIL5jHCA/MH8I0xKI+WqMA== X-Received: by 2002:a50:87b5:: with SMTP id a50mr42379905eda.118.1557934819122; Wed, 15 May 2019 08:40:19 -0700 (PDT) Received: from brauner.io ([193.96.224.243]) by smtp.gmail.com with ESMTPSA id p52sm887134eda.79.2019.05.15.08.40.16 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 15 May 2019 08:40:18 -0700 (PDT) Date: Wed, 15 May 2019 17:40:15 +0200 From: Christian Brauner To: Oleg Nesterov Cc: jannh@google.com, viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, arnd@arndb.de, dhowells@redhat.com, akpm@linux-foundation.org, cyphar@cyphar.com, ebiederm@xmission.com, elena.reshetova@intel.com, keescook@chromium.org, luto@amacapital.net, luto@kernel.org, tglx@linutronix.de, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH 1/2] pid: add pidfd_open() Message-ID: <20190515154014.4jaxuw4fcgbusnbt@brauner.io> References: <20190515100400.3450-1-christian@brauner.io> <20190515143857.GB18892@redhat.com> <20190515153515.GA20783@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190515153515.GA20783@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 Wed, May 15, 2019 at 05:35:15PM +0200, Oleg Nesterov wrote: > On 05/15, Oleg Nesterov wrote: > > > > On 05/15, Christian Brauner wrote: > > > > > > +SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) > > > +{ > > > + int fd, ret; > > > + struct pid *p; > > > + struct task_struct *tsk; > > > + > > > + if (flags) > > > + return -EINVAL; > > > + > > > + if (pid <= 0) > > > + return -EINVAL; > > > + > > > + p = find_get_pid(pid); > > > + if (!p) > > > + return -ESRCH; > > > + > > > + rcu_read_lock(); > > > + tsk = pid_task(p, PIDTYPE_PID); > > > > You do not need find_get_pid() before rcu_lock and put_pid() at the end. > > You can just do find_vpid() under rcu_read_lock(). > > Ah, sorry. Somehow I forgot you need to call pidfd_create(pid), you can't > do this under rcu_read_lock(). > > So I was wrong, you can't avoid get/put_pid. Yeah, I haven't made any changes yet. Christian