Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2639632ybl; Thu, 19 Dec 2019 17:44:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzDifJbCG+apEu3l7+54lZjPkjb5jcVAWUcqBi/mjyXDbweW02DeKV+WnzyiK9GZrppagVv X-Received: by 2002:a05:6830:2110:: with SMTP id i16mr11790845otc.337.1576806272288; Thu, 19 Dec 2019 17:44:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576806272; cv=none; d=google.com; s=arc-20160816; b=D/kdQ+pg/+xPIzvpdc1BO/X+eO5kA57/N9n2QhiN8y8DlpaXNOeYd+I0lLBF+WqZHP INbc0FVudFAZoYwFaNyzPhgApScw/SKgvXUnJWOON9T2tihhNz6F1HDEqWAVaDPQbYEl 5/CY5MfWQbmIiHyLNvO4cHaHXiwyl4YB6Nm3P1yMVawotfjhpX1rqfW7zlZ2UKq9As/K ZS07wMPeka2C4tNS/fGppvqbHt+O7iP4v6EfLEetXOHLCDjuYOTtbacVpkhmNDqwM04Z /WKYcyipiBZoVDpXQ19D/Q1ChDEYfhPx+bfxiErNs1wv2MoijS7bYiyl1eGz0tbF5U81 3P+Q== 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=8c+3QELHlKW2nEirpJI3/wLGQezQLAYWMocwzqyckiY=; b=VCv6ltICxBKsE2ttT0b9g9IzYE5CLmsprutk+R+CjHWv7PI9vLmKi7ZkSNLWK8RM+X 9o9+Pm5pE18iO6IDvthyxrx5VzQdFNiwLloR/j6o5bU8ipdSSK84DMUiZ8fKC1moqACA uUwvZ2m18HtSud5vWYzj6eCS9hscSDbyva/tPi1Ln8aBioFTNX6+WPffJixoQTooX0VA vKv/l3Tru8nmdvltZ0NSfUdmjERRLMuSXzKv9NOMqB4LYYvkegCkTuZbS6uZBqQt2YWc eoFxVtvipsaw2qoz9U4tMEGBgwlAkzxsddFfxyUqXq+hPsptIbf1Q38s69u8QZd/vm4+ VmmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JfMhr7V0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23si4280524otk.304.2019.12.19.17.44.21; Thu, 19 Dec 2019 17:44:32 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JfMhr7V0; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727241AbfLTBnb (ORCPT + 99 others); Thu, 19 Dec 2019 20:43:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:48316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727020AbfLTBna (ORCPT ); Thu, 19 Dec 2019 20:43:30 -0500 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 46B5624687 for ; Fri, 20 Dec 2019 01:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576806210; bh=9ejuSSpwcIgoC1vtIrf1QW8XeawMCi6i1EBo5T44lto=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JfMhr7V0wOAkVFs2SKNvA7dd8/uf8OvCUvrPu/E+fvrZWV1YEq9FzyAehZ+V7GmVI UlDMYIVSnn+r6U8JIGwm7D889lEyw6cFQYiyhDwj9OfXz1LegMVJfzUMzMjhhP/AVL ASF5a8ihUb8caQAHihcy7CgZW+qF+n8kOPLeWFds= Received: by mail-wr1-f49.google.com with SMTP id z3so7874944wru.3 for ; Thu, 19 Dec 2019 17:43:30 -0800 (PST) X-Gm-Message-State: APjAAAVR3Z58FZbrHjTVvqOCbJsH62XSEfLoFg64NWHJYi5iNYAM8bKt CRMSAgoq1c8ZSv/4ZPls0aj8XKdiOv4m2cD+CKFCuQ== X-Received: by 2002:adf:eb09:: with SMTP id s9mr12892287wrn.61.1576806208779; Thu, 19 Dec 2019 17:43:28 -0800 (PST) MIME-Version: 1.0 References: <20191218235459.GA17271@ircssh-2.c.rugged-nimbus-611.internal> In-Reply-To: <20191218235459.GA17271@ircssh-2.c.rugged-nimbus-611.internal> From: Andy Lutomirski Date: Thu, 19 Dec 2019 17:43:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 2/5] pid: Add PIDFD_IOCTL_GETFD to fetch file descriptors from processes To: Sargun Dhillon Cc: LKML , Linux Containers , Linux API , Linux FS Devel , Tycho Andersen , Jann Horn , Aleksa Sarai , Christian Brauner , Oleg Nesterov , Al Viro , gpascutto@mozilla.com, ealvarez@mozilla.com, Florian Weimer , jld@mozilla.com, Arnd Bergmann 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 Wed, Dec 18, 2019 at 3:55 PM Sargun Dhillon wrote: > > + > + if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { > + file = ERR_PTR(-EPERM); > + goto out; > + } I don't think this is MODE_READ. By copying an fd from the task, you can easily change its state. IMO it would be really nice if pidfd could act more like a capability here and carry a ptrace mode, for example. But I guess it doesn't right now. --Andy