Received: by 10.223.185.116 with SMTP id b49csp1816003wrg; Thu, 22 Feb 2018 03:41:53 -0800 (PST) X-Google-Smtp-Source: AH8x2279U4zDXprfIQ8WlwCo4kUx5Pb5bMV/NtYGFRhyCzpgGndlwUkQcTRVgmT4X+43xvrjuqyu X-Received: by 10.98.76.215 with SMTP id e84mr6698055pfj.45.1519299712900; Thu, 22 Feb 2018 03:41:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519299712; cv=none; d=google.com; s=arc-20160816; b=N+gMTnAomXYkkw4OPK7JNveFUvINJ6SXpCex+fNVuBPbzk/rrXar5MKCXonV1b08X+ AK0u8ewc6YIAqUdaHJ+b9GlujYcF9L2Eh3n+dcC3huXCafjclhOhlQoHlaO18pQoONwN XbUkEbKFCLBzd8DpGnCQpzSESkNJXn2po1B2/wEmgk1RjcuvePBaRAzPRISZST1OYh3t +Qlo9Jqm+AhksHb4Hh6Rz3QZoB6eX78/ItE0qkN50x8OctJVyZ2/mhpblYqA3eUPTy0j l05oJm7JxklXsee7jTEqLjg535SfFHApz+ZIYfZTYMkrRZ88MqFRlSGHzy3u0cHKsakA IR3w== 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=DbB1A/pYdA4wZ6y7p4e6dxOG+3OTIV9Ua1HHNS/l3d8=; b=DakJCyeabW9DCFGuBsF8+9jjwQPBHxDzcgSof0dR7H8b0IfIPJikgJa5P8yZZZVN1W VOKdF1ygCrmlP1uP8l03rw7drYzz/dMwPr5W1P/qiX4+/PTdZwKYuMREDoD2VL1KRX0g NrkH6GzbXaLliuQDuQyWulrG43qRFciXsVlaaSVx7oivdSKON4Nf+gSyd0PJ1Qah0zKX K972FDD+Y5U78putPohOAXINndtzC+U2z2tJhrG9EVu5lqbrLwBIQVLmoCvFPdVlh7/b 0DyWpb6TUwh8gd7Ra1/BM4i7cM355APd8DWnRw4NzZnN42uekphqbfuGNl8JsyIdJoAJ KkFw== 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 v8-v6si3255064plg.283.2018.02.22.03.41.38; Thu, 22 Feb 2018 03:41:52 -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 S932100AbeBVLkh (ORCPT + 99 others); Thu, 22 Feb 2018 06:40:37 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:41298 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753640AbeBVLkU (ORCPT ); Thu, 22 Feb 2018 06:40:20 -0500 Received: by mail-qt0-f194.google.com with SMTP id a9so5850825qtj.8 for ; Thu, 22 Feb 2018 03:40:19 -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=DbB1A/pYdA4wZ6y7p4e6dxOG+3OTIV9Ua1HHNS/l3d8=; b=dpH0Ynwr4Ai8jg7REXwpBeXV0E7S0EfWj1B1uU56Pnbe3qVbxmzgH/4Vav17PP6fi3 tdIeknVkU3C+e4jqoO1YxQinsiY2eohk6pAv1AP8iKBQDqp6kWVhgN1hgISo3QqoE1u9 pUzUzxSg3nZRzf7lK9GSJCGC/e1THf+/q1kJ8EwjEKbfTwCYaRoO9t55ADYZe7/i2fhG qJgXA2PUzyfbIFETRw7tCp1vIitT4j/jZGwFFSL26TojMTTGDlAlNvKUz6CYC1Iot373 /mG2LKPTOFGctrJDc8kcOMqTRknspAW6GEZubQncpaqMHlfCsm3MEsIGsPP3HCq8mp3K fN9Q== X-Gm-Message-State: APf1xPB/rgAR+wRs2ABoOwTsDEwtO3eHAU8RV1YwjkHjtfdwaCMQU4qH RaXX8Iq17qKXiO0h2VuEKB237p9sWpcMK2Yxrniqow== X-Received: by 10.200.26.79 with SMTP id q15mr10124048qtk.174.1519299619393; Thu, 22 Feb 2018 03:40:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.29.117 with HTTP; Thu, 22 Feb 2018 03:40:18 -0800 (PST) In-Reply-To: <20180221202908.17258-4-ebiederm@xmission.com> References: <878tbmf5vl.fsf@xmission.com> <20180221202908.17258-4-ebiederm@xmission.com> From: Miklos Szeredi Date: Thu, 22 Feb 2018 12:40:18 +0100 Message-ID: Subject: Re: [PATCH v6 4/5] fuse: Ensure posix acls are translated outside of init_user_ns 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: > Ensure the translation happens by failing to read or write > posix acls when the filesystem has not indicated it supports > posix acls. For the first iteration this is fine, but we could convert the raw xattrs as well, if we later want to, right? Thanks, Miklos > > This ensures that modern cached posix acl support is available > and used when dealing with posix acls. This is important > because only that path has the code to convernt the uids and > gids in posix acls into the user namespace of a fuse filesystem. > > Signed-off-by: "Eric W. Biederman" > --- > fs/fuse/fuse_i.h | 1 + > fs/fuse/inode.c | 7 +++++++ > fs/fuse/xattr.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 51 insertions(+) > > diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h > index 7772e2b4057e..986fa2b043ab 100644 > --- a/fs/fuse/fuse_i.h > +++ b/fs/fuse/fuse_i.h > @@ -979,6 +979,7 @@ ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size); > int fuse_removexattr(struct inode *inode, const char *name); > extern const struct xattr_handler *fuse_xattr_handlers[]; > extern const struct xattr_handler *fuse_acl_xattr_handlers[]; > +extern const struct xattr_handler *fuse_no_acl_xattr_handlers[]; > > struct posix_acl; > struct posix_acl *fuse_get_acl(struct inode *inode, int type); > diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c > index e018dc3999f4..a52cf2019a58 100644 > --- a/fs/fuse/inode.c > +++ b/fs/fuse/inode.c > @@ -1097,6 +1097,13 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) > file->f_cred->user_ns != sb->s_user_ns) > goto err_fput; > > + /* > + * If we are not in the initial user namespace posix > + * acls must be translated. > + */ > + if (sb->s_user_ns != &init_user_ns) > + sb->s_xattr = fuse_no_acl_xattr_handlers; > + > fc = kmalloc(sizeof(*fc), GFP_KERNEL); > err = -ENOMEM; > if (!fc) > diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c > index 3caac46b08b0..433717640f78 100644 > --- a/fs/fuse/xattr.c > +++ b/fs/fuse/xattr.c > @@ -192,6 +192,26 @@ static int fuse_xattr_set(const struct xattr_handler *handler, > return fuse_setxattr(inode, name, value, size, flags); > } > > +static bool no_xattr_list(struct dentry *dentry) > +{ > + return false; > +} > + > +static int no_xattr_get(const struct xattr_handler *handler, > + struct dentry *dentry, struct inode *inode, > + const char *name, void *value, size_t size) > +{ > + return -EOPNOTSUPP; > +} > + > +static int no_xattr_set(const struct xattr_handler *handler, > + struct dentry *dentry, struct inode *nodee, > + const char *name, const void *value, > + size_t size, int flags) > +{ > + return -EOPNOTSUPP; > +} > + > static const struct xattr_handler fuse_xattr_handler = { > .prefix = "", > .get = fuse_xattr_get, > @@ -209,3 +229,26 @@ const struct xattr_handler *fuse_acl_xattr_handlers[] = { > &fuse_xattr_handler, > NULL > }; > + > +static const struct xattr_handler fuse_no_acl_access_xattr_handler = { > + .name = XATTR_NAME_POSIX_ACL_ACCESS, > + .flags = ACL_TYPE_ACCESS, > + .list = no_xattr_list, > + .get = no_xattr_get, > + .set = no_xattr_set, > +}; > + > +static const struct xattr_handler fuse_no_acl_default_xattr_handler = { > + .name = XATTR_NAME_POSIX_ACL_DEFAULT, > + .flags = ACL_TYPE_ACCESS, > + .list = no_xattr_list, > + .get = no_xattr_get, > + .set = no_xattr_set, > +}; > + > +const struct xattr_handler *fuse_no_acl_xattr_handlers[] = { > + &fuse_no_acl_access_xattr_handler, > + &fuse_no_acl_default_xattr_handler, > + &fuse_xattr_handler, > + NULL > +}; > -- > 2.14.1 >