From patchwork Thu May 2 04:35:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10925995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE1181395 for ; Thu, 2 May 2019 04:36:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DB8528FCA for ; Thu, 2 May 2019 04:36:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90B2028FD0; Thu, 2 May 2019 04:36:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01D1428FCA for ; Thu, 2 May 2019 04:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725730AbfEBEfp (ORCPT ); Thu, 2 May 2019 00:35:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:50456 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725372AbfEBEfo (ORCPT ); Thu, 2 May 2019 00:35:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1F9BDAE14; Thu, 2 May 2019 04:35:42 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Andreas Gruenbacher Date: Thu, 02 May 2019 14:35:33 +1000 Cc: Miklos Szeredi , Andreas =?utf-8?q?Gr=C3=BCnbacher?= , Patrick Plagwitz , "linux-unionfs\@vger.kernel.org" , Linux NFS list , Linux FS-devel Mailing List , Linux Kernel Mailing List Subject: [PATCH] OVL: add honoracl=off mount option. In-Reply-To: <87bm0l4nra.fsf@notabene.neil.brown.name> References: <20161205151933.GA17517@fieldses.org> <20161205162559.GB17517@fieldses.org> <266c571f-e4e2-7c61-5ee2-8ece0c2d06e9@web.de> <20161206185806.GC31197@fieldses.org> <87bm0l4nra.fsf@notabene.neil.brown.name> Message-ID: <8736lx4goa.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the upper and lower layers use incompatible ACL formats, it is not possible to copy the ACL xttr from one to the other, so overlayfs cannot work with them. This happens particularly with NFSv4 which uses system.nfs4_acl, and ext4 which uses system.posix_acl_access. If all ACLs actually make to Unix permissions, then there is no need to copy up the ACLs, but overlayfs cannot determine this. So allow the sysadmin it assert that ACLs are not needed with a mount option honoracl=off This causes the ACLs to not be copied, so filesystems with different ACL formats can be overlaid together. Signed-off-by: NeilBrown --- Documentation/filesystems/overlayfs.txt | 24 ++++++++++++++++++++++++ fs/overlayfs/copy_up.c | 9 +++++++-- fs/overlayfs/dir.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/super.c | 15 +++++++++++++++ 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/overlayfs.txt b/Documentation/filesystems/overlayfs.txt index eef7d9d259e8..7ad675940c93 100644 --- a/Documentation/filesystems/overlayfs.txt +++ b/Documentation/filesystems/overlayfs.txt @@ -245,6 +245,30 @@ filesystem - future operations on the file are barely noticed by the overlay filesystem (though an operation on the name of the file such as rename or unlink will of course be noticed and handled). +ACL copy-up +----------- + +When a file that only exists on the lower layer is modified it needs +to be copied up to the upper layer. This means copying the metadata +and (usually) the data (though see "Metadata only copy up" below). +One part of the metadata can be problematic: the ACLs. + +Now all filesystems support ACLs, and when they do they don't all use +the same format. A significant conflict appears between POSIX acls +used on many local filesystems, and NFSv4 ACLs used with NFSv4. There +two formats are, in general, not inter-convertible. + +If a site only uses regular Unix permissions (Read, Write, eXecute by +User, Group and Other), then as these permissions are compatible with +all ACLs, there is no need to copy ACLs. overlayfs cannot determine +if this is the case itself. + +For this reason, overlayfs supports a mount option "honoracl=off" +which causes ACLs, any "system." extended attribute, on the lower +layer to be ignored and, particularly, not copied to the upper later. +This allows NFSv4 to be overlaid with a local filesystem, but should +only be used if the only access controls used on the filesystem are +Unix permission bits. Multiple lower layers --------------------- diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 68b3303e4b46..032aa88f21c1 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -39,7 +39,7 @@ static int ovl_ccup_get(char *buf, const struct kernel_param *param) module_param_call(check_copy_up, ovl_ccup_set, ovl_ccup_get, NULL, 0644); MODULE_PARM_DESC(ovl_check_copy_up, "Obsolete; does nothing"); -int ovl_copy_xattr(struct dentry *old, struct dentry *new) +int ovl_copy_xattr(struct dentry *old, struct dentry *new, struct ovl_fs *ofs) { ssize_t list_size, size, value_size = 0; char *buf, *name, *value = NULL; @@ -77,6 +77,10 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) } list_size -= slen; + if (strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) == 0 && + !ofs->config.honoracl) + continue; + if (ovl_is_private_xattr(name)) continue; retry: @@ -461,7 +465,8 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) return err; } - err = ovl_copy_xattr(c->lowerpath.dentry, temp); + err = ovl_copy_xattr(c->lowerpath.dentry, temp, + c->dentry->d_sb->s_fs_info); if (err) return err; diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 82c129bfe58d..cc8fb9eeb7df 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -368,7 +368,7 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry, if (IS_ERR(opaquedir)) goto out_unlock; - err = ovl_copy_xattr(upper, opaquedir); + err = ovl_copy_xattr(upper, opaquedir, upper->d_sb->s_fs_info); if (err) goto out_cleanup; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 9c6018287d57..4a104a4732af 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -422,7 +422,7 @@ int ovl_copy_up(struct dentry *dentry); int ovl_copy_up_with_data(struct dentry *dentry); int ovl_copy_up_flags(struct dentry *dentry, int flags); int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); -int ovl_copy_xattr(struct dentry *old, struct dentry *new); +int ovl_copy_xattr(struct dentry *old, struct dentry *new, struct ovl_fs *ofs); int ovl_set_attr(struct dentry *upper, struct kstat *stat); struct ovl_fh *ovl_encode_real_fh(struct dentry *real, bool is_upper); int ovl_set_origin(struct dentry *dentry, struct dentry *lower, diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index ec237035333a..c541e3fed5b9 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -20,6 +20,7 @@ struct ovl_config { bool nfs_export; int xino; bool metacopy; + bool honoracl; }; struct ovl_sb { diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 0116735cc321..ceb8fdb7ce14 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -362,6 +362,8 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry) if (ofs->config.metacopy != ovl_metacopy_def) seq_printf(m, ",metacopy=%s", ofs->config.metacopy ? "on" : "off"); + if (!ofs->config.honoracl) + seq_puts(m, ",honoracl=off"); return 0; } @@ -401,6 +403,8 @@ enum { OPT_XINO_AUTO, OPT_METACOPY_ON, OPT_METACOPY_OFF, + OPT_HONORACL_ON, + OPT_HONORACL_OFF, OPT_ERR, }; @@ -419,6 +423,8 @@ static const match_table_t ovl_tokens = { {OPT_XINO_AUTO, "xino=auto"}, {OPT_METACOPY_ON, "metacopy=on"}, {OPT_METACOPY_OFF, "metacopy=off"}, + {OPT_HONORACL_ON, "honoracl=on"}, + {OPT_HONORACL_OFF, "honoracl=off"}, {OPT_ERR, NULL} }; @@ -557,6 +563,14 @@ static int ovl_parse_opt(char *opt, struct ovl_config *config) config->metacopy = false; break; + case OPT_HONORACL_ON: + config->honoracl = true; + break; + + case OPT_HONORACL_OFF: + config->honoracl = false; + break; + default: pr_err("overlayfs: unrecognized mount option \"%s\" or missing value\n", p); return -EINVAL; @@ -1440,6 +1454,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) ofs->config.nfs_export = ovl_nfs_export_def; ofs->config.xino = ovl_xino_def(); ofs->config.metacopy = ovl_metacopy_def; + ofs->config.honoracl = true; err = ovl_parse_opt((char *) data, &ofs->config); if (err) goto out_err;