From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 17 Mar 2021 14:29:03 +0000 From: Luis Henriques Message-ID: References: <20210316160147.289193-1-vgoyal@redhat.com> MIME-Version: 1.0 In-Reply-To: <20210316160147.289193-1-vgoyal@redhat.com> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [Virtio-fs] [PATCH 0/1] fuse: acl: Send file mode updates using SETATTR List-Id: Development discussions about virtio-fs List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vivek Goyal Cc: linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com, seth.forshee@canonical.com, miklos@szeredi.hu On Tue, Mar 16, 2021 at 12:01:46PM -0400, Vivek Goyal wrote: > Hi Miklos, >=20 > Please find attached a patch to fix the SGID clearing issue upon=20 > ACL change.=20 >=20 > Luis reported that currently fstests generic/375 fails on virtiofs. And > reason being that we don't clear SGID when it should be. >=20 > Setting ACL can lead to file mode change. And this in-turn also can > lead to clearing SGID bit if. >=20 > - None of caller's groups match file owner group. > AND > - Caller does not have CAP_FSETID. >=20 > Current implementation relies on server updating the mode. But file > server does not have enough information to do so.=20 >=20 > Initially I thought of sending CAP_FSETID information to server but > then I realized, it is just one of the pieces. What about all the > groups caller is a member of. If this has to work correctly, then > all the information will have to be sent to virtiofsd somehow. Just > sending CAP_FSETID information required adding V2 of fuse_setxattr_in > because we don't have any space for sending extra information. >=20 > https://github.com/rhvgoyal/linux/commit/681cf5bdbba9c965c3dbd4337c16e9b1= 7f27debe >=20 > Also this approach will not work with idmapped mounts because server > does not have information about idmapped mappings. >=20 > So I started to look at the approach of sending file mode updates > using SETATTR. As filesystems like 9pfs and ceph are doing. This > seems simpler approach. Though it has its issues too. >=20 > - File mode update and setxattr(system.posix_acl_access) are not atomic. After reviewing (and testing) the patch, the only comment I have is that we should at least pr_warn() an eventual failure in setxattr(). But f that operation fails at that point, probably something went wrong on the other side and the kernel is unlikely to be able to revert the mode changes anyway. (And a nit: your patch seems to require some whitespaces clean-up.) Cheers, -- Lu=EDs > None of the approaches seem very clean to me. But sending SETATTR > explicitly seems to be lesser of two evils to me at this point of time. > Hence I am proposing this patch.=20 >=20 > I have run fstests acl tests and they pass. (./check -g acl). >=20 > Corresponding virtiofsd patches are here. >=20 > https://github.com/rhvgoyal/qemu/commits/acl-sgid-setattr >=20 > What do you think. >=20 > Vivek Goyal (1): > fuse: Add a mode where fuse client sends mode changes on ACL change >=20 > fs/fuse/acl.c | 54 ++++++++++++++++++++++++++++++++++++--- > fs/fuse/dir.c | 11 ++++---- > fs/fuse/fuse_i.h | 9 ++++++- > fs/fuse/inode.c | 4 ++- > include/uapi/linux/fuse.h | 5 ++++ > 5 files changed, 71 insertions(+), 12 deletions(-) >=20 > --=20 > 2.25.4 >=20 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C22BCC433E0 for ; Wed, 17 Mar 2021 14:28:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 632A564E13 for ; Wed, 17 Mar 2021 14:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbhCQO2S (ORCPT ); Wed, 17 Mar 2021 10:28:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:46876 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231828AbhCQO1u (ORCPT ); Wed, 17 Mar 2021 10:27:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 50083AD74; Wed, 17 Mar 2021 14:27:49 +0000 (UTC) Received: from localhost (brahms [local]) by brahms (OpenSMTPD) with ESMTPA id 0c713175; Wed, 17 Mar 2021 14:29:03 +0000 (UTC) Date: Wed, 17 Mar 2021 14:29:03 +0000 From: Luis Henriques To: Vivek Goyal Cc: linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com, miklos@szeredi.hu, dgilbert@redhat.com, seth.forshee@canonical.com Subject: Re: [PATCH 0/1] fuse: acl: Send file mode updates using SETATTR Message-ID: References: <20210316160147.289193-1-vgoyal@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210316160147.289193-1-vgoyal@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Mar 16, 2021 at 12:01:46PM -0400, Vivek Goyal wrote: > Hi Miklos, > > Please find attached a patch to fix the SGID clearing issue upon > ACL change. > > Luis reported that currently fstests generic/375 fails on virtiofs. And > reason being that we don't clear SGID when it should be. > > Setting ACL can lead to file mode change. And this in-turn also can > lead to clearing SGID bit if. > > - None of caller's groups match file owner group. > AND > - Caller does not have CAP_FSETID. > > Current implementation relies on server updating the mode. But file > server does not have enough information to do so. > > Initially I thought of sending CAP_FSETID information to server but > then I realized, it is just one of the pieces. What about all the > groups caller is a member of. If this has to work correctly, then > all the information will have to be sent to virtiofsd somehow. Just > sending CAP_FSETID information required adding V2 of fuse_setxattr_in > because we don't have any space for sending extra information. > > https://github.com/rhvgoyal/linux/commit/681cf5bdbba9c965c3dbd4337c16e9b17f27debe > > Also this approach will not work with idmapped mounts because server > does not have information about idmapped mappings. > > So I started to look at the approach of sending file mode updates > using SETATTR. As filesystems like 9pfs and ceph are doing. This > seems simpler approach. Though it has its issues too. > > - File mode update and setxattr(system.posix_acl_access) are not atomic. After reviewing (and testing) the patch, the only comment I have is that we should at least pr_warn() an eventual failure in setxattr(). But f that operation fails at that point, probably something went wrong on the other side and the kernel is unlikely to be able to revert the mode changes anyway. (And a nit: your patch seems to require some whitespaces clean-up.) Cheers, -- Luís > None of the approaches seem very clean to me. But sending SETATTR > explicitly seems to be lesser of two evils to me at this point of time. > Hence I am proposing this patch. > > I have run fstests acl tests and they pass. (./check -g acl). > > Corresponding virtiofsd patches are here. > > https://github.com/rhvgoyal/qemu/commits/acl-sgid-setattr > > What do you think. > > Vivek Goyal (1): > fuse: Add a mode where fuse client sends mode changes on ACL change > > fs/fuse/acl.c | 54 ++++++++++++++++++++++++++++++++++++--- > fs/fuse/dir.c | 11 ++++---- > fs/fuse/fuse_i.h | 9 ++++++- > fs/fuse/inode.c | 4 ++- > include/uapi/linux/fuse.h | 5 ++++ > 5 files changed, 71 insertions(+), 12 deletions(-) > > -- > 2.25.4 >