From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC12CC3F68F for ; Sat, 21 Dec 2019 01:46:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82D4020CC7 for ; Sat, 21 Dec 2019 01:46:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=sargun.me header.i=@sargun.me header.b="LTNBj34a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726717AbfLUBqO (ORCPT ); Fri, 20 Dec 2019 20:46:14 -0500 Received: from mail-ed1-f68.google.com ([209.85.208.68]:44999 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726633AbfLUBqN (ORCPT ); Fri, 20 Dec 2019 20:46:13 -0500 Received: by mail-ed1-f68.google.com with SMTP id bx28so10274843edb.11 for ; Fri, 20 Dec 2019 17:46:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e12Mnu5DiWBdZFxNKin4JTRmUKOLU+wR6ztAL37zhAQ=; b=LTNBj34a/5X3efwYU6hSdfbjHgGkwrDz3BppIDQzVdomaBcPJYPjji/5CWcuX5eiuK nRtByNprFnPdf5vqKaOTpOXOo0r1yi89jhIVZ5tvRlCRIqmSzPUAoDg7I7HGa239Azzh yAiO/3eRLlEmi90xDuUgTzfU6okfFdGuZxqqs= 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=e12Mnu5DiWBdZFxNKin4JTRmUKOLU+wR6ztAL37zhAQ=; b=hHyHhUIHuVF9yM+JtJuNWq9faalzehC4WOeclLSRW0oqpSPtc2G2zxvUbgsoWZ7hmW 0rND/v0sWgUGElFNoNI8jLS0v99pi9twagdqeX6Wl5Rk4zSlICWslV/1A8nBpkpzOVdb K0hMPRfEn9rd7+E4prIe9ZXFtbvPR8XxpTu0rooKQnbzSsBX2jl2rn1bX1XUI0b4JsdU +wW2hKW0ayY89OF3E7yNh4Vy6ww58rnBIPWp3lud1v+hY88LgxTlRrKV610Lh4fdDDLA 3gfV2Leqvzhjwf6QhqW0g3eWYSvfq4Wu9dIHnnW/foGa8G7MKgK5bvGjBqaLmSGSwQfO SMSg== X-Gm-Message-State: APjAAAVDm4N0ZYR3ULjVm2AistyyWpRI1KrejSwkPInYmdWh18ZQn0S3 UyGuuaPhAvO2dLl9jy4k6sk5x5iPTyI4WXBFDWKgIQ== X-Google-Smtp-Source: APXvYqxb8UQLCVS8ZHvwXwLPP+w/fQZABPHqVecdCzSZ6Hw7QsjoOp76JDhiyTTOimtqSFsSY7HEMzdgklJ+w9vCSHM= X-Received: by 2002:a50:cc08:: with SMTP id m8mr19431615edi.263.1576892770667; Fri, 20 Dec 2019 17:46:10 -0800 (PST) MIME-Version: 1.0 References: <20191220232810.GA20233@ircssh-2.c.rugged-nimbus-611.internal> <20191221002734.7rz6lcdrshrrlnqf@yavin.dot.cyphar.com> In-Reply-To: <20191221002734.7rz6lcdrshrrlnqf@yavin.dot.cyphar.com> From: Sargun Dhillon Date: Fri, 20 Dec 2019 17:45:34 -0800 Message-ID: Subject: Re: [PATCH v5 2/3] pid: Introduce pidfd_getfd syscall To: Aleksa Sarai Cc: LKML , Linux Containers , Linux API , Linux FS-devel Mailing List , =?UTF-8?Q?Emilio_Cobos_=C3=81lvarez?= , Arnd Bergmann , Jann Horn , Gian-Carlo Pascutto , Jed Davis , Oleg Nesterov , Andy Lutomirski , Al Viro , Christian Brauner Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Dec 20, 2019 at 4:27 PM Aleksa Sarai wrote: > > On 2019-12-20, Sargun Dhillon wrote: > > diff --git a/include/uapi/linux/pidfd.h b/include/uapi/linux/pidfd.h > > new file mode 100644 > > index 000000000000..0a3fc922661d > > --- /dev/null > > +++ b/include/uapi/linux/pidfd.h > > @@ -0,0 +1,10 @@ > > +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ > > +#ifndef _UAPI_LINUX_PIDFD_H > > +#define _UAPI_LINUX_PIDFD_H > > + > > +struct pidfd_getfd_options {}; > > Are empty structs well-defined in C (from memory, some compilers make > them non-zero in size)? Since we probably plan to add a flags field in > the future anyway, why not just have a __u64 flags which must be zeroed? > It's allowed in GCC: https://gcc.gnu.org/onlinedocs/gcc-8.1.0/gcc/Empty-Structures.html I can add an __aligned_u64 flags for now, and just say something like "reserved". This will also solve the latter issue, and I'll just use copy_struct_from_user, as long as Christian is okay with having an unused (reserved) flag member. > > + f = fdget(pidfd); > > + if (!f.file) > > + return -EBADF; > > + > > + pid = pidfd_pid(f.file); > > + if (IS_ERR(pid)) { > > + ret = PTR_ERR(pid); > > + goto out; > > + } > > + > > + ret = pidfd_getfd(pid, fd); > > + > > +out: > > + fdput(f); > > + return ret; > > +} > > -- > > 2.20.1 > > -- > Aleksa Sarai > Senior Software Engineer (Containers) > SUSE Linux GmbH >