Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp443667rdb; Thu, 30 Nov 2023 08:41:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWpSkvRrPZ5t/WyjUQ15xgJPOlF6cZQlOdZRznGlQ+TV5D1yJ0qmdGOEY7TkrDJ4X14Vs2 X-Received: by 2002:a05:6a20:a10a:b0:18b:4632:af0b with SMTP id q10-20020a056a20a10a00b0018b4632af0bmr26838712pzk.17.1701362496072; Thu, 30 Nov 2023 08:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701362496; cv=none; d=google.com; s=arc-20160816; b=Nv00EF8w40ogO87o77zmALRJdoc1ep0/bAM4JjjyQMiudrB95aJ/sbAzsfYZ/+tfBL n3arpkHUGmQicdi7OBtcRCQEW9IZyNmRHsBai52jJLjb2OkRHSCQr4x+8gayYfTxCLQa hZSX8+RzoiwxgGlP4uz0riIwQwQy5yZmNCwpdsnbta1IJOsQdzcqZMabnsrlVlDLbTDP JG+XXG3fHeXTWNMCTmJ+4F7lIOlCh+t7g3KoKm+axCn+qLEPRlWPMXWRc2Cj60BbNJrR /xVKDiwvjlsdM8l+1n6rOIAOKTvAPe9jsn5JR4KTb6mGNjpTe6l3cj5ukotON5ZlZ7gT kKng== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=FDTY8U7EOT/1DeRPnfFwHP0MdgI/bwbxCW2DXPahxYI=; fh=+vZwhLTSeTSKnU46TxpzbraKs0lTOVYQiil923WoDOY=; b=WUiFVoarAHHLgvfe9rXOFMyXQx5KXYkFRm6OpCMdoCwObkzdaRmw3GACanHkk4wL4v +I5VIRReNr/KDOotMEoW+1YaCHQp7JcvEU1auyDCBSLnzjd8q3L+fAXPRin6slXdYhhk T1U1nmh/sYwVapdw/Mg4w9smMfw6OPjdb+llkD8soLOl03vjXt+z+AH2wttRp7asvq+B OJLi7F7zf1aEdtMjLR++fhqh5a5nfc27NjI60NVx8pRwfT8F53NC0lWRePb3alzS/mPS 9mtuh9WzggZS1yMzRpbKetyMj4/xOvO5oCP1oGl+EEx12oQf/8WueR9u7NkVgsQSCOT5 4a4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sbewMVwK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id gg16-20020a17090b0a1000b00285bd5232d2si1695246pjb.143.2023.11.30.08.41.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sbewMVwK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 112E1802571B; Thu, 30 Nov 2023 08:41:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjK3QlB (ORCPT + 99 others); Thu, 30 Nov 2023 11:41:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235176AbjK3Qkw (ORCPT ); Thu, 30 Nov 2023 11:40:52 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B89CA1A3 for ; Thu, 30 Nov 2023 08:40:58 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30BAFC433C8; Thu, 30 Nov 2023 16:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701362458; bh=eMauWcpoHiWGcXeCJ6n8laJEDioZTrZnYDww6VNDcD4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sbewMVwKMEOHbYOQLQybblEflNdQip+Ra5frYeqsZTWZAms2Jc3Y7vZ7VASj5Aur8 2zcpnKl6VXvVqF/kauQ4Iiz6DQt73jk1dO6H+GoLx3lC2Yt97HLA9T/vmzzP3B+03Q kPTyK/7HFP2KvQ4SKG0MDkNX4gmfFGIAyQE7Dz22TIRefJZJ/gc0YSFucBeOaMT/67 f5ls+Y0y+ImdrcDVR/MACxVOCl3kZppNqPy264LpK0ESvaBOEFvkoIHFv8e7NkdBGk ZAAtIELOtR5UTdVF1PVhKL5Y6tVrJ43gmuW9DJ9HJXCC6/5leR2WXKhnvL4nNFn4y2 C3+wHN3tZckhg== Date: Thu, 30 Nov 2023 10:40:57 -0600 From: "Seth Forshee (DigitalOcean)" To: Amir Goldstein Cc: Christian Brauner , Serge Hallyn , Paul Moore , Eric Paris , James Morris , Alexander Viro , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, audit@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: Re: [PATCH 16/16] vfs: return -EOPNOTSUPP for fscaps from vfs_*xattr() Message-ID: References: <20231129-idmap-fscap-refactor-v1-0-da5a26058a5b@kernel.org> <20231129-idmap-fscap-refactor-v1-16-da5a26058a5b@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 08:41:22 -0800 (PST) On Thu, Nov 30, 2023 at 08:10:15AM +0200, Amir Goldstein wrote: > On Wed, Nov 29, 2023 at 11:51 PM Seth Forshee (DigitalOcean) > wrote: > > > > Now that the new vfs-level interfaces are fully supported and all code > > has been converted to use them, stop permitting use of the top-level vfs > > xattr interfaces for capabilities xattrs. Unlike with ACLs we still need > > to be able to work with fscaps xattrs using lower-level interfaces in a > > handful of places, so only use of the top-level xattr interfaces is > > restricted. > > Can you explain why? > Is there an inherent difference between ACLs and fscaps in that respect > or is it just a matter of more work that needs to be done? There are a number of differences. ACLs have caching, require additional permission checks, and require a lot of filesystem-specific handling. fscaps are simpler by comparison, and most filesystems can rely on a common implementation that just converts to/from raw disk xattrs. So at minimum I think the lowest level interfaces, __vfs_{get,set,remove}xattr(), need to continue to allow fscaps, and that's where ACL xattrs are blocked. Allowing some of the others to still work with them is a matter of convenience (e.g. using vfs_getxattr_alloc()) and trying to reduce code duplication. But as you pointed out I did miss at least duplicating fsnotify_xattr(), so I'm going to have another look at how I implemented these. > > > > > Signed-off-by: Seth Forshee (DigitalOcean) > > --- > > fs/xattr.c | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/fs/xattr.c b/fs/xattr.c > > index 372644b15457..4b779779ad8c 100644 > > --- a/fs/xattr.c > > +++ b/fs/xattr.c > > @@ -540,6 +540,9 @@ vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, > > const void *orig_value = value; > > int error; > > > > + if (!strcmp(name, XATTR_NAME_CAPS)) > > + return -EOPNOTSUPP; > > + > > It this is really not expected, then it should be an assert and > please use an inline helper like is_posix_acl_xattr(): > > if (WARN_ON_ONCE(is_fscaps_xattr(name))) Ack, makes sense.