Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2018492ybb; Fri, 29 Mar 2019 16:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxF8URCAVCm0L65tA2QbwANPnDRcoTDIIztIp02yEUuiznQs7z3Uc5HnK16iyDOUV2urJJO X-Received: by 2002:a62:e816:: with SMTP id c22mr7138382pfi.54.1553903312282; Fri, 29 Mar 2019 16:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553903312; cv=none; d=google.com; s=arc-20160816; b=syku5JhrmsQad/Rr10JT3/RzLj9AtVC9XraHU4mRPUsbvqLCa6cUfXtO6YaiVonTjv QCQVvv9/36HK3+73HIs0/MY7TxQ5daxgGZ8o4IIg9lFzEU2Uytb3vIvnhWTwFhflnagL 2CcN4mVBdFPZetwrnsutbA5BJbHXSAmKa8XhmXux+TCsZlpssaSaEusv9mJI9cdzkVd1 DpBKXUDqNTfeTlL2IrGkbJYrRcLfZz7N4P1EkFsGSefzvS4vB0h+oMFOZkkh9AqdYc7Y +B6v1xG2LfggXCnVGCAwLqojC98un5O1kUZreKou0FC0VW8LSR1xypkPC6nekq4xMlwq xx6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/g/fHQBksrx3ws5RjN+7gkaT5AJmakYOWM6OLZLQbM0=; b=TR2yuodYguqRcxZT2aYZCjBnh/qmpff08qBpTYsjs11tqAFUU2bYZquMsNsv1xOWkX mbnny0LwVoYyUekDqzjMj750coeTklk63WA5CTNVmkIC6q8WPKAwrNS9Wz1UyvpMQj1T f0JMTafnen4xn4XTAcyltLPQ44HtlyQKyI0nFB6Bj4yj2xt9cuas8Y4b2SWHdJ+e45H5 LhKDt+vccaH/p3U917Zmx+ZchFYr8kYc3lvX0nR4orOr8jXppKntYgMq4324ktz9E2xb SyQhHXvApYSEijIazqyRbF8YbU58fseOZNzPpVafHnWUKN7PgqxY+/ElCzv//tldK65h YM+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="corx/B8F"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si1774557plq.400.2019.03.29.16.48.16; Fri, 29 Mar 2019 16:48:32 -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=@google.com header.s=20161025 header.b="corx/B8F"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730259AbfC2XqO (ORCPT + 99 others); Fri, 29 Mar 2019 19:46:14 -0400 Received: from mail-oi1-f193.google.com ([209.85.167.193]:44102 "EHLO mail-oi1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730154AbfC2XqN (ORCPT ); Fri, 29 Mar 2019 19:46:13 -0400 Received: by mail-oi1-f193.google.com with SMTP id i21so3002148oib.11 for ; Fri, 29 Mar 2019 16:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/g/fHQBksrx3ws5RjN+7gkaT5AJmakYOWM6OLZLQbM0=; b=corx/B8FFW48Deh8UoywlUT3M3m5tB07cWLbPghGvVw2d7Ouf1PTT5MEawQxwMjTue jjTCF5OqSTrRPFRrxYceOTsQHEhBvqq6O+5N4MUGFR/DzTkxK34YjBcANaOZ7/NUscj4 OcV6Juucjj36CxfLyODKkKdC+X/d78cI+71jdBhHtkaKcQJHz1PugyB6vw+l7VbYxJei W4Es8vvdrR8P2dV7YPZOYLbndZU8fHVW3dWgvWi3AFde/yqRkEGUBni/4PJXlAtl4wMI KZfx6qEy/CAcjK9Ys6faHZJqbswHzvznIV2AC8XSWep+IZy+veEDzKXCES3v+9T9APqb azFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/g/fHQBksrx3ws5RjN+7gkaT5AJmakYOWM6OLZLQbM0=; b=az1rDcBmj01PE7IrLPQels2ZMtF7ANR7SlIbzat74McvgGBzTcgCjL1sK/F6SjfEyc pDnc+0IUoNY3PsLnROJLV4eisEOH1S50aIkXvxXfmJB14JhjnGx6Vuq6pX0fFkss3DQk +gaImlA+tnpAsGGGd74KXbO3gHr/NaVyON94Djbk+s0F5cbVKQEYtV4KiI5nUhKJCAUh sVSaRymIO9fHKLA3gtbcfAV0miszTKP/hWknem72Q07T4Yai0VtGmRUtMG48OFds6WyJ kV1XvhkWgFsxrv5Tznj+Vej9tt5RLCHFNKWyZt0TaBIGJku+qZfrItsBuY6Z6v/N08Xc pukQ== X-Gm-Message-State: APjAAAU5arPEXGDC3LWxRtU9UqGznqn1aMH0u22ZHbvp0vsd8OmEDkMe AHnPiVCGlEmuDFdbx2MmZg8uqa+eVGspqJuSRUMXwg== X-Received: by 2002:aca:e4cc:: with SMTP id b195mr5598724oih.39.1553903172643; Fri, 29 Mar 2019 16:46:12 -0700 (PDT) MIME-Version: 1.0 References: <20190329155425.26059-1-christian@brauner.io> <20190329155425.26059-3-christian@brauner.io> In-Reply-To: <20190329155425.26059-3-christian@brauner.io> From: Jann Horn Date: Sat, 30 Mar 2019 00:45:46 +0100 Message-ID: Subject: Re: [PATCH v2 2/5] pid: add pidfd_open() To: Christian Brauner 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 [...] > 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"? [...] > +} > + > +static inline int pidfd_to_procfd(int procfd, struct file *pidfd_file) > +{ > + long fd; nit: This should probably be an int? [...] > + 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. > + switch (cmd) { > + case PIDFD_GET_PROCFD: > + return pidfd_to_procfd(procfd, file); > + default: > + return -ENOTTY; > + } > +}