Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp958452pxb; Wed, 3 Mar 2021 22:31:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwn6STrxGLr38SRjPYsWIxiYp9Gp6Uziiw47IQ+3tV34n7kAWGRoI7alKRvX5VeWkrYFUty X-Received: by 2002:a17:906:2314:: with SMTP id l20mr2651240eja.178.1614839510410; Wed, 03 Mar 2021 22:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614839510; cv=none; d=google.com; s=arc-20160816; b=nxImnaQxosMNz0IuSMOX9MyJc6sFOpPCu7DgdM/lmmYr49V/4JBOa1QbwN7EE/dXJ2 EN1+4Pu0uuT68IUaWHNs0SE7OugYWJf0u9ODVEXqgikNhJql5vD4PFahJ7VveaFQj+qu BY1LJp91yqV61zNe3KB/oE0MR1Sg78sWol1VgpS3DcbD2toqrTWawL5yKpeTVH4Io6pq TktpJRXxOUbZQQsFpzYuq+7Bxygb628+naAbYDQvQ5izdI9KcA7iLu/sW80fo6s6S5Ej RPlo6J8QCuvZA9f54/vDmrA0Z/Sfj+JkAUrH8SboX53W0rMgGGKXiKfuxyJMv+3s2ugW cCIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=N3sSHK++R6zsz5fOVbw47mb0BUNgGRGZh9qrPGeQDx0=; b=GPgHbibxmm5hQ6l/m6nVmc0OXhOuieADceNLa/MlzhIoAPWGwg2DecTPF7NfwNF7jE nLMJQsLX8K1HCKd++UVHqJpSgFXEudFPM/3U4ECGL9uaGMZ8iMxQI7yfqcdPhqj3uJcC FjG0q1fJztypUUFT/ypQ7cVxJhjH2YJFvkQsVezAWaSoCUHM/mcfg18F2NDMIIeLgHE/ 0H+Rk1b30HPUuvEIQLPUBCY0t3fAdIeaqxnnz3MjBznxqE6dG8kKAMt3zkc1uvwGQgZZ Phpo3g99Ctf+suQ1N6Z0jI4iD+yO5BuyGOAlfbTrcF61ZpqDZqFhGd/WVLzxcBAZzwft aw8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVtFnuiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si17315415ejg.121.2021.03.03.22.31.28; Wed, 03 Mar 2021 22:31:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PVtFnuiO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1579449AbhCBQ5P (ORCPT + 99 others); Tue, 2 Mar 2021 11:57:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21123 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351435AbhCBOYv (ORCPT ); Tue, 2 Mar 2021 09:24:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614694976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N3sSHK++R6zsz5fOVbw47mb0BUNgGRGZh9qrPGeQDx0=; b=PVtFnuiOjFLUT4ffqkCDXT3J4gfoCqEj/giAzKPFomFTAPZ9yYqG16Dyz6NiigguwiaKlw AuNavOB5JmRA6l2NGPSOGaRxedwEb36l2Stw5DtQH2yKgDZnCqY4vybJF2l4DSv3ymGG2i wDgG6Z47WW7k80RsNDTquyGh2O2Fso4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-U146o1jFM_OqzMLU63kT_A-1; Tue, 02 Mar 2021 09:22:52 -0500 X-MC-Unique: U146o1jFM_OqzMLU63kT_A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB307107ACC7; Tue, 2 Mar 2021 14:22:51 +0000 (UTC) Received: from horse.redhat.com (ovpn-114-140.rdu2.redhat.com [10.10.114.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64D961971D; Tue, 2 Mar 2021 14:22:47 +0000 (UTC) Received: by horse.redhat.com (Postfix, from userid 10451) id BAAD922054F; Tue, 2 Mar 2021 09:22:46 -0500 (EST) Date: Tue, 2 Mar 2021 09:22:46 -0500 From: Vivek Goyal To: Luis Henriques Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com, linux-kernel@vger.kernel.org, "Dr. David Alan Gilbert" Subject: Re: [RFC PATCH] fuse: Clear SGID bit when setting mode in setacl Message-ID: <20210302142246.GC220334@redhat.com> References: <20210226183357.28467-1-lhenriques@suse.de> <20210301163324.GC186178@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210301163324.GC186178@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 01, 2021 at 11:33:24AM -0500, Vivek Goyal wrote: > On Fri, Feb 26, 2021 at 06:33:57PM +0000, Luis Henriques wrote: > > Setting file permissions with POSIX ACLs (setxattr) isn't clearing the > > setgid bit. This seems to be CVE-2016-7097, detected by running fstest > > generic/375 in virtiofs. Unfortunately, when the fix for this CVE landed > > in the kernel with commit 073931017b49 ("posix_acl: Clear SGID bit when > > setting file permissions"), FUSE didn't had ACLs support yet. > > Hi Luis, > > Interesting. I did not know that "chmod" can lead to clearing of SGID > as well. Recently we implemented FUSE_HANDLE_KILLPRIV_V2 flag which > means that file server is responsible for clearing of SUID/SGID/caps > as per following rules. > > - caps are always cleared on chown/write/truncate > - suid is always cleared on chown, while for truncate/write it is cleared > only if caller does not have CAP_FSETID. > - sgid is always cleared on chown, while for truncate/write it is cleared > only if caller does not have CAP_FSETID as well as file has group execute > permission. > > And we don't have anything about "chmod" in this list. Well, I will test > this and come back to this little later. Looks like I did not notice the setattr_prepare() call in fuse_do_setattr() which clears SGID in client itself and server does not have to do anything extra. So it works. IOW, FUSE_HANDLE_KILLPRIV_V2 will not handle this particular case and fuse client will clear SGID on chmod, if need be. Vivek