Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2022708ybb; Fri, 29 Mar 2019 16:56:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR/lnP/2alzTr1hvc+gXyjNh8VzrmFGrwYfjy8PYCpbGG2NHSm+uEfdOOVnFcBQuFAHt+4 X-Received: by 2002:a63:d4f:: with SMTP id 15mr48641405pgn.162.1553903782598; Fri, 29 Mar 2019 16:56:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553903782; cv=none; d=google.com; s=arc-20160816; b=HMajZf/BYsYs9eqZ8mb37XEatcSHTxlTnNZc9y4et7HvJUoWSyDcUxu7goZ0ssD5x9 GPIKl2nzyMsOWZzBVHLTFmR0nrbKVx1PaJ5jmCja5uX3Bhr80wl6syYz5awMFnTXBIRP RIbCUecnrkudMSqIpDL/tCsvS2Q6Emd27a+l2gxwSRGeX2OHsKfe1PavIzNnOYDtGUSx 6aS94NgaU8CA4bDULycxnsQ+JM6VYYw12qIHvWczWaAirWhnlu+APoEPbOZ5L7sjvjTS mnGw5SpqnpQLXaJV/5Jwh10kOkzpRXDIsN5RTy38m9OTVDgr72XyS1rKCs2WlMxe1lGW tcVg== 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=Nrq8BWIRn/YQVWfwi4OFVGnUNZFD63iddewfvjotgQI=; b=JIDa6ILZOxtX9I+OlTKSYszTdUxSCq7zIzYpc4yPMFJ8f9oZjp90MtG246RNxCN2IY U+BMeUGiMBNFzWAQ7jkoUFiFqHlY7zNqLU++DuEPIMpfxiPTuOzGFu8eoXJXtCpbohLm Uyd4XHN/z5wNNPIrXpu8maq8gsSJwrS05UN76PFa6fNWHtBTqKG4ezj6wiV+ScMsJGAF nX95SzvO+wBvc6ycfz+aTh2szWh1XFknWhTuVJWpoUAQ3uqLAbsg0Jz21jlEVqDvr3fw bC4RkBiiEhFjD25PalsUK+Gf5aMbdAAmfE29dxmWnqNLubBwXcn9pLtSJtwEigDY6q1X 9Y4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=Sh1RN6Jx; 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 h185si2909734pge.84.2019.03.29.16.56.06; Fri, 29 Mar 2019 16:56:22 -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=Sh1RN6Jx; 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 S1730065AbfC2Xz0 (ORCPT + 99 others); Fri, 29 Mar 2019 19:55:26 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:44692 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729911AbfC2Xz0 (ORCPT ); Fri, 29 Mar 2019 19:55:26 -0400 Received: by mail-ed1-f65.google.com with SMTP id x10so3412457edh.11 for ; Fri, 29 Mar 2019 16:55:24 -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=Nrq8BWIRn/YQVWfwi4OFVGnUNZFD63iddewfvjotgQI=; b=Sh1RN6Jxs1gFkA3SskG5lvwlPbMTGxkv/jl4a+JkL8A037+KAO3MMlRrP4fhseHpcg eOapaIdUcKWYSuGeo7Jzrm+H6Mvfr76qQ44+SdqyVV6fndYpFeU88/Mc2/Bzu3j6zxcg Z4qkPFz+BsfbeWiTVSf7Ytm7hkw0aOD+H2/mx8XMiEqXIYxrvI4vnxmGurKJtcdo+VLQ dCKbFRjUFxUVXeudZMWlxDokCU7vjaKzy2a7dCATniQsA2WwnK0A99iMwrJpACHJO6S4 0/wuhqV9u/O+cBtG861+zA1de+AOtuHqbsJm49VTomDtKqRn8zQoWxHnNAPew/D83X+z JJcg== 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=Nrq8BWIRn/YQVWfwi4OFVGnUNZFD63iddewfvjotgQI=; b=Rl/kAokBB7KLHc8vjfXsDyqoHYzsdGzDVsP1l44fQFQ3n7rXLv+0GSJM11lBVC86rF SmPgbGTX5BA9W7Zw2o72/aKoqx+Pxpx905pXS/wM6c+oXVgwq9ADCCtBMvMpNaMsl5BB 9wUyw+mGYpjQIDEagt1sR7gyKDmLt6hsI7am+e1PY2WVj2Y74bDW+k7tTvqLDNqOmP3N yjbKCue/ScK4WvVimBgA7RMDKZykBzKgKvX9lSlq8e8r3Zc2dM515fdJq/BDp6LR0Z02 MbeHXG+/uT61BqjKrf4spHJDfdCDtO0xv5dlQrpBAr4JVce8LPb845/XAbRJZxZvuPNG J6YA== X-Gm-Message-State: APjAAAUa/ae8UItNLsPrxv7JUlK19xSnEHDPlc0mSZALng2WknhRFbXz sB0+om7aohacVCDQ2eQt6HdvUQ== X-Received: by 2002:a17:906:5e0d:: with SMTP id n13mr29351915eju.37.1553903724202; Fri, 29 Mar 2019 16:55:24 -0700 (PDT) Received: from brauner.io ([2a02:8109:b6bf:d24a:b136:35b0:7c8c:280a]) by smtp.gmail.com with ESMTPSA id d8sm577242ejm.29.2019.03.29.16.55.22 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 29 Mar 2019 16:55:23 -0700 (PDT) Date: Sat, 30 Mar 2019 00:55:22 +0100 From: Christian Brauner To: Jann Horn Cc: Andy Lutomirski , David Howells , "Serge E. Hallyn" , Linux API , kernel list , Arnd Bergmann , "Eric W. Biederman" , Konstantin Khlebnikov , Kees Cook , Alexey Dobriyan , Thomas Gleixner , Michael Kerrisk-manpages , Jonathan Kowalski , "Dmitry V. Levin" , Andrew Morton , Oleg Nesterov , Nagarathnam Muthusamy , Aleksa Sarai , Al Viro , "Joel Fernandes (Google)" , Daniel Colascione Subject: Re: [PATCH v2 2/5] pid: add pidfd_open() Message-ID: <20190329235521.wrtuyoualsvcgz5k@brauner.io> References: <20190329155425.26059-1-christian@brauner.io> <20190329155425.26059-3-christian@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 30, 2019 at 12:45:46AM +0100, Jann Horn wrote: > On Fri, Mar 29, 2019 at 4:54 PM Christian Brauner wrote: > > /* Introduction */ > > This adds the pidfd_open() syscall. > > pidfd_open() allows to retrieve file descriptors for a given pid. This > > includes both file descriptors for processes and file descriptors for > > threads. > > Looks good to me, overall. Apart from a few nits below: > Reviewed-by: Jann Horn Thanks! Will fixup the nits and add your Reviewed-by! > > [...] > > diff --git a/kernel/pid.c b/kernel/pid.c > > index 20881598bdfa..8c9e15e0e463 100644 > > --- a/kernel/pid.c > > +++ b/kernel/pid.c > [...] > > +static struct file *pidfd_open_proc_pid(const struct file *procf, pid_t pid, > > + const struct pid *pidfd_pid) > > +{ > > + char name[12]; /* int to strlen + \0 but with */ > > nit: comment suddenly ends at "but with"? Will fix. > > [...] > > +} > > + > > +static inline int pidfd_to_procfd(int procfd, struct file *pidfd_file) > > +{ > > + long fd; > > nit: This should probably be an int? Yes. > > [...] > > + return fd; > > +} > [...] > > +static long pidfd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > > +{ > > + int procfd = arg; > > nit: I think it'd be semantically cleaner to move this assignment into > the switch case, but I don't feel about it strongly. Agreed. > > > + switch (cmd) { > > + case PIDFD_GET_PROCFD: > > + return pidfd_to_procfd(procfd, file); > > + default: > > + return -ENOTTY; > > + } > > +}