Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4403718ybl; Mon, 13 Jan 2020 13:06:46 -0800 (PST) X-Google-Smtp-Source: APXvYqx/zGbAGvDclKdOnGvQ+kOgt0V4uZBHDVXakYVAwqlcXP/du8gagOa/sL2WqnHJVJnsih5S X-Received: by 2002:a9d:590d:: with SMTP id t13mr14807062oth.290.1578949606219; Mon, 13 Jan 2020 13:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578949606; cv=none; d=google.com; s=arc-20160816; b=OR7qjlIPXiuwc0qX0TLvyoDU9jGq+tC7cWF9aj8VmhJktBNAkIwHXfV9jnel5ARjC5 oLS27ezySkMuMdeR7udGflU6Io889y1G6UyPu+DShdSgsz83CwGQIf2KfDp5s+jnpAMw NxNy7bzBLTa/5wp1YUqB6KalQ3r+dFQCxDK20ujZPgsf26nPCrtGYJr7vSUKcj8t4G1G akYQCk6FSk95x3NMxYC8kGl7tg2yqZ+mxaLVtw/AnIoCD2IblRudhcIwfvfLmb6GG9la h1MogQ/abEfHV1Gu79843H7vPsMqocl8lx5U0h0Ji3trslTIOohxlPFr9t31u5gL0o2x PA7A== 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=/u5MUGVpDUAbfDbLeEsPX6aUptgWMsZ6OpMkOdaH+A4=; b=WcWTqGq3r6dZLpRUEyAFGbWo4MhcBV+M2dBb6cyFJhevNaPtYW+DfAlxbV3Xe5+KZq rvnssiks4TKlaxgg16bZexAT9lgZC1xmcmh8Y+cwpyaMjWTUMayLHszA6m2oFnn2H1Ar k2awrMj7ZN63iwDggotxrn3QLWnt3KyKtOPOKeuygAI/mzH5hHuG80Q8Fa6leq4SDKmB xSefXYdN/sUivlRTYJhFnXLHgwm6/8hMsiGSlyxmSbmZl3K+JSxnFLVnkDpkIAaET1dc B+AwA9qzpPTlDQC4RE00MeZM87yb/lJblczdZtI8wv64I8HKS3p55wrmpuYXV57tOKiD Yd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=pywZLKqd; 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 b133si6543945oif.244.2020.01.13.13.06.33; Mon, 13 Jan 2020 13:06:46 -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=@google.com header.s=20161025 header.b=pywZLKqd; 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 S1728808AbgAMVFZ (ORCPT + 99 others); Mon, 13 Jan 2020 16:05:25 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39472 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbgAMVFY (ORCPT ); Mon, 13 Jan 2020 16:05:24 -0500 Received: by mail-lj1-f194.google.com with SMTP id l2so11723551lja.6 for ; Mon, 13 Jan 2020 13:05:23 -0800 (PST) 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=/u5MUGVpDUAbfDbLeEsPX6aUptgWMsZ6OpMkOdaH+A4=; b=pywZLKqdxPfExS0SnABaJ4aTlQdAJxvMIPcUiv09kBnxMbRddIefk6L+AZtCxKjWgA liHsrkFRC3T9RBzdlmOhUVoaEwJ5JAUBmXvh78E0up26nPZ4ijaFW8mUbjAFWyB2kxi1 edgeWwJ3faA3x9NLcDaEa0gXbEXEgCF6iZ12xGf4x2B1oR62JNenKpXiDsinOqybcBL/ 5z60/LxPmvRsfacCOOyvejl2NFaOXDPWX6k8QKvbmBf8vjXLe2Nc/I6MAqALAeeOUOB3 5OC/2iiijXYynwhr1LtgfBkelfr6L54T3rAd02/rrhUTlSv2CTl04r7b6+dIP+dzetEf HUpw== 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=/u5MUGVpDUAbfDbLeEsPX6aUptgWMsZ6OpMkOdaH+A4=; b=laO2nZKf2P8Y4XOlR27YOe9z4Bz7F8dztZVFO/0knOC0D8htPN9zaf5myzE0+QpSjb O4i160YPeP5nhMsdl6hk/0XwQeQrnAkRnpYg+plWMzFTyeEdZGQb+nBWnr50yVtzEOBf +qZnMJo0MddnJGssaqN1kw9/cwz6Owe6kaVOVYW+ABctGFyT8my21Z6tWP25KOHaNfUc BYPrfdJknsx1UXqQW9/pts9WA9lrfqEmGIbhbmsNdXgpWb90AYSCZGhCNkjqdkX1JJlm 6DWv6UkdhQmp4bGsWMcvz111KfYl6j+0oPohETepUjmf0KInXBa14xdqcsUQ8xEoMiKq ZhwQ== X-Gm-Message-State: APjAAAW4k2a60sf0aYJp1GHPEAmFv7nccePQAU5ze8k1z0m5d6qTbzhV MRXzY0ROv4+pXIeJRRuSFvdH4oA29X8MrxRYdHtIauKW X-Received: by 2002:a2e:884d:: with SMTP id z13mr12351302ljj.116.1578949522306; Mon, 13 Jan 2020 13:05:22 -0800 (PST) MIME-Version: 1.0 References: <20200110213433.94739-1-minchan@kernel.org> <20200110213433.94739-3-minchan@kernel.org> <56ea0927-ad2e-3fbd-3366-3813330f6cec@virtuozzo.com> <20200113104256.5ujbplyec2sk4onn@wittgenstein> <20200113184408.GD110363@google.com> <20200113191046.2tidyvc544zvchek@wittgenstein> <20200113204237.ew6nn4ohxu7auw3u@wittgenstein> In-Reply-To: <20200113204237.ew6nn4ohxu7auw3u@wittgenstein> From: Daniel Colascione Date: Mon, 13 Jan 2020 13:04:44 -0800 Message-ID: Subject: Re: [PATCH 2/4] mm: introduce external memory hinting API To: Christian Brauner Cc: Minchan Kim , Kirill Tkhai , Michal Hocko , Andrew Morton , LKML , linux-mm , Linux API , oleksandr@redhat.com, Suren Baghdasaryan , Tim Murray , Sandeep Patil , Sonny Rao , Brian Geffon , Johannes Weiner , Shakeel Butt , John Dias 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 Mon, Jan 13, 2020 at 12:42 PM Christian Brauner wrote: > > On Mon, Jan 13, 2020 at 11:27:03AM -0800, Daniel Colascione wrote: > > On Mon, Jan 13, 2020 at 11:10 AM Christian Brauner > > wrote: > > > This does not > > > affect the permission checking you're performing here. > > > > Pidfds-as-capabilities sounds like a good change. Can you clarify what > > you mean here though? Do you mean that in order to perform some > > process-directed operation X on process Y, the pidfd passed to X must > > have been opened with PIDFD_CAP_X *and* the process *using* the pidfds > > must be able to perform operation X on process Y? Or do pidfds in this > > model "carry" permissions in the same way that an ordinary file > > descriptor "carries" the ability to write to a file if it was opened > > with O_WRONLY even if the FD is passed to a process that couldn't > > otherwise write to that file? Right now, pidfds are identity-only and > > always rely on the caller's permissions. I like the capability bit > > model because it makes pidfds more consistent with other file > > descriptors and enabled delegation of capabilities across the system. > > I'm going back and forth on this. My initial implementation has it that > you'd need both, PIDFD_FLAG/CAP_X and the process using the pidfd must > be able to perform the operation X on process Y. The alternative becomes > tricky for e.g. anything that requires ptrace_may_access() permissions > such as getting an fd out from another task based on its pidfd and so > on. I think the alternative is necessary though. What's the point of the pidfd capability bits if they don't grant access? If I have a pidfd for Y that doesn't let me do operation X, but I have ambient authority to do Y anyway, then I can just make my own pidfd for Y and then use that new pidfd to do X. AFAICT, pidfd capabilities only do something when they replace ptrace_may_access and friends for access control. Otherwise, they seem purely advisory. Am I missing something?