Received: by 10.223.185.116 with SMTP id b49csp1740773wrg; Thu, 22 Feb 2018 02:16:34 -0800 (PST) X-Google-Smtp-Source: AH8x225Rvfo3uHQsJIeB3VKo19JnrXcAxqVo25slMtPDcfjPIPp7rQujZ4EAOEQEG6Wxre9435i0 X-Received: by 10.99.121.71 with SMTP id u68mr5264617pgc.330.1519294594312; Thu, 22 Feb 2018 02:16:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519294594; cv=none; d=google.com; s=arc-20160816; b=yWIfgYKjjv8XWDYa6gRnZpEyh/cpXxNkp4bxilkPn1lL/g7OUVW+f/T2yC4EmFdrh8 jgUi2WGRsWwa0DZYY0AvJ41Chjnl7BCObtd1pxdNxlT20balnY3DB76a+gPg0ftlmTcF CjEYCRvg8sFkxMjuifhS6cldJ5UOqwhaGbo5RzBjQPMlE/uSz4y7TUoiES5n5pvt/psx qIZDxt0SKuHI6XPz+wlMRcxVlJmeSw2Qf4flaIDYmHRLTYTLPqC5chi9M5w/bw2aeeWI UoyepTvmLXRbLgkupnQ8jt5jcE2GulChdfYUuQMD6VeA9CuZn7wTmjnyYVJ9srWdfPa8 muZA== 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 :references:in-reply-to:mime-version:arc-authentication-results; bh=a9t+zLCpFVu2juDgjOlO0Jh/IelqtRWQC/SLomJAubQ=; b=yVDEcKaHBbbSVuy0Ma9uK3Nj9ZdU2L6I/X6qmxq240lHTmkdQStw+ezqrwfDeEk/2K jrwo3jqr72nkVFFw7s5FVo1Z1wM7vdIVu+L/OjI4XAqTKU3fOFrE1q4WJlhZAeJTNSHn G+INQ7l5P7I0NtSVA23Ir7Z4ppGHYapokDAF3Uug20L+63oSI45ZwMl2JBGpt3xc0uDW xfZeC4Bg93KlfsEs8kTuP31YN0ZP7iP+BHCAAyafOB9N2Vv/XRuD36/W1v0usfDB6VMG srBZHNUcJMAL/QqFCFUacNLs6gyvuFLyYiJBC6t6PNInILt3M9qT2KJ47xwNle29Bl+l MhYg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si2709913pgt.621.2018.02.22.02.16.20; Thu, 22 Feb 2018 02:16:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753345AbeBVKNi (ORCPT + 99 others); Thu, 22 Feb 2018 05:13:38 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:35109 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961AbeBVKNh (ORCPT ); Thu, 22 Feb 2018 05:13:37 -0500 Received: by mail-qt0-f194.google.com with SMTP id g14so5616481qti.2 for ; Thu, 22 Feb 2018 02:13:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=a9t+zLCpFVu2juDgjOlO0Jh/IelqtRWQC/SLomJAubQ=; b=giqs7MkGqHUgDaM8bGJqRGumJ7370hHTH7ECmOrgydQbhSaErH2fp8fueCWtK2yRTe 8ly6zoJ53ktf1zKsFVAwTrum388tq0QgjKRCTI91RJvLJUnjfPjGgrlhJe2ZYg/+sAxl P2L6JBdaYuHbzLYjrVgGAXZcvXlgbKUGBhOem/Q78NCfKPnzC9A5unURw/w0hEO6Sdff jXHX7BTmXTsQq4W5xtM/jZETWWhKVXMESnCiLgh25+wlQaS0KM69B6dGAC1LCUMW2UsF su4C7JIctO+TTo3e0RFhijwhZUnE7ri1wj/tOqCBs9tMLivuGA9eqUQpW8strfw/gFI2 Ssng== X-Gm-Message-State: APf1xPCJ1LIiYSrg5Gc/U5zxP+Plv7FpM/VIzlZaYFeXjoKRx5t06AKd bq3zHn7sH6VeJUZduRRq0GlkavyF2c2SInZo4c2k0g== X-Received: by 10.200.36.37 with SMTP id c34mr10155017qtc.38.1519294416471; Thu, 22 Feb 2018 02:13:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.29.117 with HTTP; Thu, 22 Feb 2018 02:13:36 -0800 (PST) In-Reply-To: <20180221202908.17258-1-ebiederm@xmission.com> References: <878tbmf5vl.fsf@xmission.com> <20180221202908.17258-1-ebiederm@xmission.com> From: Miklos Szeredi Date: Thu, 22 Feb 2018 11:13:36 +0100 Message-ID: Subject: Re: [PATCH v6 1/5] fuse: Remove the buggy retranslation of pids in fuse_dev_do_read To: "Eric W. Biederman" Cc: lkml , Linux Containers , linux-fsdevel , Alban Crequy , Seth Forshee , Sargun Dhillon , Dongsu Park , "Serge E. Hallyn" 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, Feb 21, 2018 at 9:29 PM, Eric W. Biederman wrote: > At the point of fuse_dev_do_read the user space process that initiated the > action on the fuse filesystem may no longer exist. The process have been > killed or may have fired an asynchronous request and exited. > > If the initial process has exited the code "pid_vnr(find_pid_ns(in->h.pid, > fc->pid_ns)" will either return a pid of 0, or in the unlikely event that > the pid has been reallocated it can return practically any pid. Any pid is > possible as the pid allocator allocates pid numbers in different pid > namespaces independently. > > The only way to make translation in fuse_dev_do_read reliable is to call > get_pid in fuse_req_init_context, and pid_vnr followed by put_pid in > fuse_dev_do_read. That reference counting in other contexts has been shown > to bounce cache lines between processors and in general be slow. So that is > not desirable. > > The only known user of running the fuse server in a different pid namespace > from the filesystem does not care what the pids are in the fuse messages > so removing this code should not matter. Shouldn't we at least zero out the pid in that case? Thanks, Miklos > > Getting the translation to a server running outside of the pid namespace > of a container can still be achieved by playing setns games at mount time. > It is also possible to add an option to pass a pid namespace into the fuse > filesystem at mount time. > > Fixes: 5d6d3a301c4e ("fuse: allow server to run in different pid_ns") > Signed-off-by: "Eric W. Biederman" > --- > fs/fuse/dev.c | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c > index 5d06384c2cae..0fb58f364fa6 100644 > --- a/fs/fuse/dev.c > +++ b/fs/fuse/dev.c > @@ -1260,12 +1260,6 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, > in = &req->in; > reqsize = in->h.len; > > - if (task_active_pid_ns(current) != fc->pid_ns) { > - rcu_read_lock(); > - in->h.pid = pid_vnr(find_pid_ns(in->h.pid, fc->pid_ns)); > - rcu_read_unlock(); > - } > - > /* If request is too large, reply with an error and restart the read */ > if (nbytes < reqsize) { > req->out.h.error = -EIO; > -- > 2.14.1 >