From patchwork Wed Jan 25 11:28:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3809C54E94 for ; Wed, 25 Jan 2023 11:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235437AbjAYL37 (ORCPT ); Wed, 25 Jan 2023 06:29:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235463AbjAYL3a (ORCPT ); Wed, 25 Jan 2023 06:29:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D20C2ED61 for ; Wed, 25 Jan 2023 03:29:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2DF0614C0 for ; Wed, 25 Jan 2023 11:29:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F414CC433A0; Wed, 25 Jan 2023 11:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646167; bh=rpioZjmc8Cn4WYIVXTsl179baJ9K19ztyXY6GuGAveU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K+Aq3OkLlQNrnJWUFa9bEr9bhTY3rAMvvY872cZDazBcXEbgeBgUHgKY/XUG1BeUa 7vD2+QmB5tDhEGBcDPvIqw5bNDCD6QoI5rFrckzIYJUl5p96s8iIMa01CJ9sZe/FdL IQKHJpJAzvr8iMqJxBcuL82CZ9EK+v1p2ijnXQq4NvOrq9Nu9JvrIaiP12QMSDI7u7 1yCk43TsND1nzg0E+O9y9DhrbNQcWxxnv6HRwQ5p/sWI1FB6O4z/BfrKtL8RGJy6wU dC5tNYFiJ/RdMA+t7rrGo8SPlOD0IltqJ/v76eryAkaeKO7oMq4cvDTTheTxz7Z9rs cvz7nsnh0G9iw== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:46 +0100 Subject: [PATCH 01/12] xattr: simplify listxattr helpers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-1-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4210; i=brauner@kernel.org; h=from:subject:message-id; bh=rpioZjmc8Cn4WYIVXTsl179baJ9K19ztyXY6GuGAveU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJq4a3r+19ecK57M68v9/STlNPOkJcf7vh9q/RR8O/AB /51wtY5SFgYxLgZZMUUWh3aTcLnlPBWbjTI1YOawMoEMYeDiFICJ8LsyMnw34+o88bL4ffXrxIW/PU Q9VPa4/Dt96528Cv/u14dOh65j+Ke47zGD79nqrYf3Re85mekhY374/+oPt2r83ryre+21VpUBAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The generic_listxattr() and simple_xattr_list() helpers list xattrs and contain duplicated code. Add two helpers that both generic_listxattr() and simple_xattr_list() can use. Signed-off-by: Christian Brauner (Microsoft) --- fs/xattr.c | 114 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 58 insertions(+), 56 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index adab9a70b536..ed7fcaab8e1a 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -949,6 +949,46 @@ SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) return error; } +static int xattr_list_one(char **buffer, ssize_t *remaining_size, + const char *name) +{ + size_t len = strlen(name) + 1; + if (*buffer) { + if (*remaining_size < len) + return -ERANGE; + memcpy(*buffer, name, len); + *buffer += len; + } + *remaining_size -= len; + return 0; +} + +static int posix_acl_listxattr(struct inode *inode, char **buffer, + ssize_t *remaining_size) +{ +#ifdef CONFIG_FS_POSIX_ACL + int err; + + if (!IS_POSIXACL(inode)) + return 0; + + if (inode->i_acl) { + err = xattr_list_one(buffer, remaining_size, + XATTR_NAME_POSIX_ACL_ACCESS); + if (err) + return err; + } + + if (inode->i_default_acl) { + err = xattr_list_one(buffer, remaining_size, + XATTR_NAME_POSIX_ACL_DEFAULT); + if (err) + return err; + } +#endif + return 0; +} + /* * Combine the results of the list() operation from every xattr_handler in the * list. @@ -957,33 +997,22 @@ ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) { const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; - unsigned int size = 0; - - if (!buffer) { - for_each_xattr_handler(handlers, handler) { - if (!handler->name || - (handler->list && !handler->list(dentry))) - continue; - size += strlen(handler->name) + 1; - } - } else { - char *buf = buffer; - size_t len; - - for_each_xattr_handler(handlers, handler) { - if (!handler->name || - (handler->list && !handler->list(dentry))) - continue; - len = strlen(handler->name); - if (len + 1 > buffer_size) - return -ERANGE; - memcpy(buf, handler->name, len + 1); - buf += len + 1; - buffer_size -= len + 1; - } - size = buf - buffer; + ssize_t remaining_size = buffer_size; + int err = 0; + + err = posix_acl_listxattr(d_inode(dentry), &buffer, &remaining_size); + if (err) + return err; + + for_each_xattr_handler(handlers, handler) { + if (!handler->name || (handler->list && !handler->list(dentry))) + continue; + err = xattr_list_one(&buffer, &remaining_size, handler->name); + if (err) + return err; } - return size; + + return err ? err : buffer_size - remaining_size; } EXPORT_SYMBOL(generic_listxattr); @@ -1245,20 +1274,6 @@ static bool xattr_is_trusted(const char *name) return !strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN); } -static int xattr_list_one(char **buffer, ssize_t *remaining_size, - const char *name) -{ - size_t len = strlen(name) + 1; - if (*buffer) { - if (*remaining_size < len) - return -ERANGE; - memcpy(*buffer, name, len); - *buffer += len; - } - *remaining_size -= len; - return 0; -} - /** * simple_xattr_list - list all xattr objects * @inode: inode from which to get the xattrs @@ -1287,22 +1302,9 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs, ssize_t remaining_size = size; int err = 0; -#ifdef CONFIG_FS_POSIX_ACL - if (IS_POSIXACL(inode)) { - if (inode->i_acl) { - err = xattr_list_one(&buffer, &remaining_size, - XATTR_NAME_POSIX_ACL_ACCESS); - if (err) - return err; - } - if (inode->i_default_acl) { - err = xattr_list_one(&buffer, &remaining_size, - XATTR_NAME_POSIX_ACL_DEFAULT); - if (err) - return err; - } - } -#endif + err = posix_acl_listxattr(inode, &buffer, &remaining_size); + if (err) + return err; read_lock(&xattrs->lock); for (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) { From patchwork Wed Jan 25 11:28:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35EF7C61DA2 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235499AbjAYLaC (ORCPT ); Wed, 25 Jan 2023 06:30:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235565AbjAYL3d (ORCPT ); Wed, 25 Jan 2023 06:29:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3342E9EF8 for ; Wed, 25 Jan 2023 03:29:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 8450DB81990 for ; Wed, 25 Jan 2023 11:29:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB980C433EF; Wed, 25 Jan 2023 11:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646169; bh=nkbD/SyQZs2afsrS0O87QOkz8HvG7my1dcjAzjSGdM0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ao+xx+xXSdkn8MoxnZ+apBo4CN0hlga/fGnjsIWr+Lca+8C2TJCZy+H65pExpzxt7 1clG/5W2eyzl+QyrtxsN+mAePj/s2BGxdrAvpLEEnAorVuPxvkaeemUevU7EfvGFV7 D/rnU9WuMdpcykBtAB9OdQIgraUKjOr+kZRJNaQJBaUej7/f92muFMh96tyd9P2BYX moNzpIzkOtVrPy9CKKbjAH+diA/lIubBnYbyDyyHmGVrl4YFZhvA5ET1R8KVbPg4ye AQvUSsb1HONAubrJ5us7YT/+VwY+aR1sGCfuyTsZAytZtyoAd4V8rBfd0eFXEX0HuL 9k1DgcWL2+CSw== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:47 +0100 Subject: [PATCH 02/12] xattr, posix acl: add listxattr helpers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-2-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1470; i=brauner@kernel.org; h=from:subject:message-id; bh=nkbD/SyQZs2afsrS0O87QOkz8HvG7my1dcjAzjSGdM0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJpoJdxya7Zg8BeXY4kHYtZmCl/zf7u+53Tuv4Bvs/8b z09k6ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhIjwcjw4Q2xuN31JY8443ojK5WX3 cjjt3KQfHvG/8znyMMW7rM+RgZNp06+KM75LByZ83a1HqOtncr55yaft3mZFpBhOi6aXIWLAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Add two tiny helpers to determine whether a given dentry supports listing the requested xattr or posix acl. We will use this helper in various filesystems in later commits. Signed-off-by: Christian Brauner (Microsoft) --- include/linux/posix_acl_xattr.h | 5 +++++ include/linux/xattr.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h index 54cd7a14330d..905d532ccd6e 100644 --- a/include/linux/posix_acl_xattr.h +++ b/include/linux/posix_acl_xattr.h @@ -68,6 +68,11 @@ static inline int posix_acl_type(const char *name) return -1; } +static inline bool posix_acl_dentry_list(struct dentry *dentry) +{ + return IS_POSIXACL(d_backing_inode(dentry)); +} + extern const struct xattr_handler posix_acl_access_xattr_handler; extern const struct xattr_handler posix_acl_default_xattr_handler; diff --git a/include/linux/xattr.h b/include/linux/xattr.h index 2e7dd44926e4..d1150b7ba8d0 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -47,6 +47,12 @@ struct xattr_handler { size_t size, int flags); }; +static inline bool xattr_dentry_list(const struct xattr_handler *handler, + struct dentry *dentry) +{ + return handler && (!handler->list || handler->list(dentry)); +} + const char *xattr_full_name(const struct xattr_handler *, const char *); struct xattr { From patchwork Wed Jan 25 11:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115546 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46EFCC61DA4 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235536AbjAYLaE (ORCPT ); Wed, 25 Jan 2023 06:30:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235567AbjAYL3e (ORCPT ); Wed, 25 Jan 2023 06:29:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE815244B8 for ; Wed, 25 Jan 2023 03:29:33 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 84E91B8191A for ; Wed, 25 Jan 2023 11:29:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF23AC4339E; Wed, 25 Jan 2023 11:29:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646171; bh=QmlDYYqZSAYFuk5CdnnztAbIgxZQWYoaQiNLu8Gb/Cw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VMmPRh8dLQHlrGgl5NmgOossAydMoWghG6gKRs/u6/MuLwvbbcH6kqm3J1YIl8Hrw 30kWRJ7EwgoEk1aKCliIp3WgVzV9pxMdjGmxCtvtAt1TLCjaHsYT5aRvVU7xvLdVoZ 7j2bWNWcTsmjinTXEU1p1TCsrAjakLCHTp409jZOiBTq30caLsmH6lwtTDfZZVbXh7 hh1wok8mZUI+HDNUTXVcqBCd5w7RbQl1Sm5yP8Zjj4P3TbqY6ZHkSbHaqlIDkVnr1d 17AbwMEpGrUxBWTd+LWVM6QZwJt69d2TKdV6Cd+I7Q+eZOS4GT5K9QpgxGtld+L+dK vLUDc/xpXbUEQ== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:48 +0100 Subject: [PATCH 03/12] xattr: remove unused argument MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-3-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2590; i=brauner@kernel.org; h=from:subject:message-id; bh=QmlDYYqZSAYFuk5CdnnztAbIgxZQWYoaQiNLu8Gb/Cw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJrI27JzX/lU/nfn5/L8P7yC2895FvchjoLvN/0d7Pf3 aqpWdZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExkpx0jQ9crzcV+U803bLjx+5jQRu 55T47Hrln2/mLH3IsPVwRGGD9j+GfP+MzFPtOyo70/7/+J/w/FGvPXXPNg41+r/KbePLopjxkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org his helpers is really just used to check for user.* xattr support so don't make it pointlessly generic. Signed-off-by: Christian Brauner (Microsoft) Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4xdr.c | 3 +-- fs/xattr.c | 10 ++++------ include/linux/xattr.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2b4ae858c89b..d78a73c732a3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3442,8 +3442,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, p = xdr_reserve_space(xdr, 4); if (!p) goto out_resource; - err = xattr_supported_namespace(d_inode(dentry), - XATTR_USER_PREFIX); + err = xattr_supports_user_prefix(d_inode(dentry)); *p++ = cpu_to_be32(err == 0); } diff --git a/fs/xattr.c b/fs/xattr.c index ed7fcaab8e1a..b79f202c5857 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -159,11 +159,10 @@ xattr_permission(struct user_namespace *mnt_userns, struct inode *inode, * Look for any handler that deals with the specified namespace. */ int -xattr_supported_namespace(struct inode *inode, const char *prefix) +xattr_supports_user_prefix(struct inode *inode) { const struct xattr_handler **handlers = inode->i_sb->s_xattr; const struct xattr_handler *handler; - size_t preflen; if (!(inode->i_opflags & IOP_XATTR)) { if (unlikely(is_bad_inode(inode))) @@ -171,16 +170,15 @@ xattr_supported_namespace(struct inode *inode, const char *prefix) return -EOPNOTSUPP; } - preflen = strlen(prefix); - for_each_xattr_handler(handlers, handler) { - if (!strncmp(xattr_prefix(handler), prefix, preflen)) + if (!strncmp(xattr_prefix(handler), XATTR_USER_PREFIX, + XATTR_USER_PREFIX_LEN)) return 0; } return -EOPNOTSUPP; } -EXPORT_SYMBOL(xattr_supported_namespace); +EXPORT_SYMBOL(xattr_supports_user_prefix); int __vfs_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry, diff --git a/include/linux/xattr.h b/include/linux/xattr.h index d1150b7ba8d0..391ade703782 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -84,7 +84,7 @@ int vfs_getxattr_alloc(struct user_namespace *mnt_userns, struct dentry *dentry, const char *name, char **xattr_value, size_t size, gfp_t flags); -int xattr_supported_namespace(struct inode *inode, const char *prefix); +int xattr_supports_user_prefix(struct inode *inode); static inline const char *xattr_prefix(const struct xattr_handler *handler) { From patchwork Wed Jan 25 11:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56BEFC61DA3 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235542AbjAYLaF (ORCPT ); Wed, 25 Jan 2023 06:30:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235535AbjAYL3g (ORCPT ); Wed, 25 Jan 2023 06:29:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF9322A33 for ; Wed, 25 Jan 2023 03:29:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C2A4C614BB for ; Wed, 25 Jan 2023 11:29:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C5CC4339C; Wed, 25 Jan 2023 11:29:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646173; bh=YJdMOaNTSboPBakdGZtb5/eAxnhlrj+MEmcYvcegqDI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=geEHcHBT/tSZlrxP9TQvnG3fA6sh6dzT6qH8Nl3DfslAFxwvPSM2Yv9hisA5fJMGn QXypa5WDCgg8wJduLduKZiEk9OWJSFOOdvUm1ZQpIl0/fKb9vNfNbGwAmbLabXkdPK GgTD+wtGZg7gWGo7Lqww3ovwOqe1X2RejWO8mBguoiEF8Z+awY3OglyW5O5VbT+ulu PojneqLNUElPOahcguXMEIwIs5ISpyBlZh+iw7gyyPikUFxPG8cx1pDKlz2u5bJb27 dii+R8egwp4N8NfZvw95gJYPLfQUi+it5UnHAN/rFnFwEQUOVbJ2B9X4eK2EEExx+9 6r5ctvfWPxA/Q== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:49 +0100 Subject: [PATCH 04/12] fs: drop unused posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-4-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8360; i=brauner@kernel.org; h=from:subject:message-id; bh=YJdMOaNTSboPBakdGZtb5/eAxnhlrj+MEmcYvcegqDI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJo4z+9QvzxTy7LVJtdPbKj5Xch6mWeC25rJ4kzPXv7P TN/L01HKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjARy2RGhk3zDDO7XA+nrf7rx37r1s bfOgnZv+4pebQotthFv2DZZMjI8GfaQYcPbpEF8rV3Tq45whD+mG/NrNxPG6LqlQSOvfpnzwYA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove struct posix_acl_{access,default}_handler for all filesystems that don't depend on the xattr handler in their inode->i_op->listxattr() method in any way. There's nothing more to do than to simply remove the handler. It's been effectively unused ever since we introduced the new posix acl api. Signed-off-by: Christian Brauner (Microsoft) Reviewed-by: Christoph Hellwig --- fs/9p/xattr.c | 4 ---- fs/btrfs/xattr.c | 4 ---- fs/ceph/xattr.c | 4 ---- fs/cifs/xattr.c | 4 ---- fs/ecryptfs/inode.c | 4 ---- fs/gfs2/xattr.c | 2 -- fs/jfs/xattr.c | 4 ---- fs/nfs/nfs3_fs.h | 1 - fs/nfs/nfs3acl.c | 6 ------ fs/nfs/nfs3super.c | 3 --- fs/ntfs3/xattr.c | 4 ---- fs/orangefs/xattr.c | 2 -- fs/overlayfs/super.c | 8 -------- fs/xfs/xfs_xattr.c | 4 ---- mm/shmem.c | 4 ---- 15 files changed, 58 deletions(-) diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c index b6984311e00a..1d2df17b450f 100644 --- a/fs/9p/xattr.c +++ b/fs/9p/xattr.c @@ -183,10 +183,6 @@ static struct xattr_handler v9fs_xattr_security_handler = { const struct xattr_handler *v9fs_xattr_handlers[] = { &v9fs_xattr_user_handler, &v9fs_xattr_trusted_handler, -#ifdef CONFIG_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif #ifdef CONFIG_9P_FS_SECURITY &v9fs_xattr_security_handler, #endif diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 0ed4b119a7ca..a6abe528c5d8 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c @@ -444,10 +444,6 @@ static const struct xattr_handler btrfs_btrfs_xattr_handler = { const struct xattr_handler *btrfs_xattr_handlers[] = { &btrfs_security_xattr_handler, -#ifdef CONFIG_BTRFS_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &btrfs_trusted_xattr_handler, &btrfs_user_xattr_handler, &btrfs_btrfs_xattr_handler, diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index f31350cda960..22e22e8dc226 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -1411,10 +1411,6 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx) * attributes are handled directly. */ const struct xattr_handler *ceph_xattr_handlers[] = { -#ifdef CONFIG_CEPH_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &ceph_other_xattr_handler, NULL, }; diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c index 5f2fb2fd2e37..1b50814eadbb 100644 --- a/fs/cifs/xattr.c +++ b/fs/cifs/xattr.c @@ -487,9 +487,5 @@ const struct xattr_handler *cifs_xattr_handlers[] = { &smb3_ntsd_xattr_handler, /* alias for above since avoiding "cifs" */ &cifs_cifs_ntsd_full_xattr_handler, &smb3_ntsd_full_xattr_handler, /* alias for above since avoiding "cifs" */ -#ifdef CONFIG_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif NULL }; diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index f3cd00fac9c3..5802b93b2cda 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c @@ -1210,10 +1210,6 @@ static const struct xattr_handler ecryptfs_xattr_handler = { }; const struct xattr_handler *ecryptfs_xattr_handlers[] = { -#ifdef CONFIG_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &ecryptfs_xattr_handler, NULL }; diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 518c0677e12a..88c78dc526fa 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c @@ -1501,8 +1501,6 @@ const struct xattr_handler *gfs2_xattr_handlers_max[] = { /* GFS2_FS_FORMAT_MIN */ &gfs2_xattr_user_handler, &gfs2_xattr_security_handler, - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, NULL, }; diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c index f9273f6901c8..dfdc0c1f6e25 100644 --- a/fs/jfs/xattr.c +++ b/fs/jfs/xattr.c @@ -986,10 +986,6 @@ static const struct xattr_handler jfs_trusted_xattr_handler = { }; const struct xattr_handler *jfs_xattr_handlers[] = { -#ifdef CONFIG_JFS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &jfs_os2_xattr_handler, &jfs_user_xattr_handler, &jfs_security_xattr_handler, diff --git a/fs/nfs/nfs3_fs.h b/fs/nfs/nfs3_fs.h index df9ca56db347..a6d1314dbe56 100644 --- a/fs/nfs/nfs3_fs.h +++ b/fs/nfs/nfs3_fs.h @@ -17,7 +17,6 @@ extern int nfs3_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, struct posix_acl *dfacl); extern ssize_t nfs3_listxattr(struct dentry *, char *, size_t); -extern const struct xattr_handler *nfs3_xattr_handlers[]; #else static inline int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, struct posix_acl *dfacl) diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 74d11e3c4205..aeb158e3bd99 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c @@ -300,12 +300,6 @@ int nfs3_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, goto out; } -const struct xattr_handler *nfs3_xattr_handlers[] = { - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, - NULL, -}; - static int nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data, size_t size, ssize_t *result) diff --git a/fs/nfs/nfs3super.c b/fs/nfs/nfs3super.c index 7c5809431e61..8a9be9e47f76 100644 --- a/fs/nfs/nfs3super.c +++ b/fs/nfs/nfs3super.c @@ -14,9 +14,6 @@ struct nfs_subversion nfs_v3 = { .rpc_vers = &nfs_version3, .rpc_ops = &nfs_v3_clientops, .sops = &nfs_sops, -#ifdef CONFIG_NFS_V3_ACL - .xattr = nfs3_xattr_handlers, -#endif }; static int __init init_nfs_v3(void) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index 616df209feea..1eb9f3d9ba8c 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -1033,10 +1033,6 @@ static const struct xattr_handler ntfs_other_xattr_handler = { }; const struct xattr_handler *ntfs_xattr_handlers[] = { -#ifdef CONFIG_NTFS3_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &ntfs_other_xattr_handler, NULL, }; diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c index 9a5b757fbd2f..3203abc89b9f 100644 --- a/fs/orangefs/xattr.c +++ b/fs/orangefs/xattr.c @@ -555,8 +555,6 @@ static const struct xattr_handler orangefs_xattr_default_handler = { }; const struct xattr_handler *orangefs_xattr_handlers[] = { - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, &orangefs_xattr_default_handler, NULL }; diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 85b891152a2c..559d416e06a3 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -1055,20 +1055,12 @@ static const struct xattr_handler ovl_other_xattr_handler = { }; static const struct xattr_handler *ovl_trusted_xattr_handlers[] = { -#ifdef CONFIG_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &ovl_own_trusted_xattr_handler, &ovl_other_xattr_handler, NULL }; static const struct xattr_handler *ovl_user_xattr_handlers[] = { -#ifdef CONFIG_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &ovl_own_user_xattr_handler, &ovl_other_xattr_handler, NULL diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 10aa1fd39d2b..379e1dc97225 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -179,10 +179,6 @@ const struct xattr_handler *xfs_xattr_handlers[] = { &xfs_xattr_user_handler, &xfs_xattr_trusted_handler, &xfs_xattr_security_handler, -#ifdef CONFIG_XFS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif NULL }; diff --git a/mm/shmem.c b/mm/shmem.c index c301487be5fb..081a82edf7c0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -3333,10 +3333,6 @@ static const struct xattr_handler shmem_trusted_xattr_handler = { }; static const struct xattr_handler *shmem_xattr_handlers[] = { -#ifdef CONFIG_TMPFS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &shmem_security_xattr_handler, &shmem_trusted_xattr_handler, NULL From patchwork Wed Jan 25 11:28:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76D3EC61DB3 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235562AbjAYLaG (ORCPT ); Wed, 25 Jan 2023 06:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235603AbjAYL3l (ORCPT ); Wed, 25 Jan 2023 06:29:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE8C27997 for ; Wed, 25 Jan 2023 03:29:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C21C9B81991 for ; Wed, 25 Jan 2023 11:29:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BEBB6C4339E; Wed, 25 Jan 2023 11:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646175; bh=MKSA4pnIEhyA1wK9ZUCK91ZgbKvksc8BYw8SfMd3xXc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QJJ9Z4WN0Il91E9PeY3JoUgIo3rpqItLB+HW8PAn6mqk1rzueejoBMJvnXTLLwcr2 XnNjOTXls/1LFQ+ovVV/pE9q5YW5c99H1FlfG1227ZqKsu1yjQMuQejfRsHp3lQ15c N9iVmCDrzVPZvU+rrQ3dOE1h4LQJ34lekKR3NDfTeS/IczFi83yn7O8nCC66T5xoy4 WQ6SFejNtnSoMNNJRKSK96N6hLOb48cbLptc19AP5YVk/vV5EIBxXznBn4NJf5Emit KqWeXb3Gt7x7nh13hUQkSadcYcNyThkR8MPZQc2e+a8l1o9wyo+eniKJLhGsA7FVB/ 7LfKr6EbQoujQ== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:50 +0100 Subject: [PATCH 05/12] erofs: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-5-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , linux-erofs@lists.ozlabs.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4168; i=brauner@kernel.org; h=from:subject:message-id; bh=MKSA4pnIEhyA1wK9ZUCK91ZgbKvksc8BYw8SfMd3xXc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJqYwrjvz0nn9CnfdzjMikjas9H8cRb/tDevlZI6di5T C9VY01HKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRDlNGhtUNKxrZNT8xzzWLOPaG/e bhA7v/nRH+/XfKJDPrJ/22ovsZGRZXWp/6eNc6O/mSucH+qvlrNCbeuB58ty7vqLNrzOld37kA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/erofs/xattr.c | 49 +++++++++++++++++++++++++++++++++++++++---------- fs/erofs/xattr.h | 21 --------------------- 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c index a62fb8a3318a..a787e74d9a21 100644 --- a/fs/erofs/xattr.c +++ b/fs/erofs/xattr.c @@ -469,10 +469,6 @@ const struct xattr_handler __maybe_unused erofs_xattr_security_handler = { const struct xattr_handler *erofs_xattr_handlers[] = { &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &erofs_xattr_trusted_handler, #ifdef CONFIG_EROFS_FS_SECURITY &erofs_xattr_security_handler, @@ -480,6 +476,43 @@ const struct xattr_handler *erofs_xattr_handlers[] = { NULL, }; +static const char *erofs_xattr_prefix(int xattr_index, struct dentry *dentry) +{ + const char *name = NULL; + const struct xattr_handler *handler = NULL; + + switch (xattr_index) { + case EROFS_XATTR_INDEX_USER: + handler = &erofs_xattr_user_handler; + break; + case EROFS_XATTR_INDEX_TRUSTED: + handler = &erofs_xattr_trusted_handler; + break; +#ifdef CONFIG_EROFS_FS_SECURITY + case EROFS_XATTR_INDEX_SECURITY: + handler = &erofs_xattr_security_handler; + break; +#endif +#ifdef CONFIG_EROFS_FS_POSIX_ACL + case EROFS_XATTR_INDEX_POSIX_ACL_ACCESS: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; +#endif + default: + return NULL; + } + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; +} + struct listxattr_iter { struct xattr_iter it; @@ -496,13 +529,9 @@ static int xattr_entrylist(struct xattr_iter *_it, unsigned int prefix_len; const char *prefix; - const struct xattr_handler *h = - erofs_xattr_handler(entry->e_name_index); - - if (!h || (h->list && !h->list(it->dentry))) + prefix = erofs_xattr_prefix(entry->e_name_index, it->dentry); + if (!prefix) return 1; - - prefix = xattr_prefix(h); prefix_len = strlen(prefix); if (!it->buffer) { diff --git a/fs/erofs/xattr.h b/fs/erofs/xattr.h index 0a43c9ee9f8f..9376cbdc32d8 100644 --- a/fs/erofs/xattr.h +++ b/fs/erofs/xattr.h @@ -40,27 +40,6 @@ static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi, extern const struct xattr_handler erofs_xattr_user_handler; extern const struct xattr_handler erofs_xattr_trusted_handler; extern const struct xattr_handler erofs_xattr_security_handler; - -static inline const struct xattr_handler *erofs_xattr_handler(unsigned int idx) -{ - static const struct xattr_handler *xattr_handler_map[] = { - [EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler, -#ifdef CONFIG_EROFS_FS_POSIX_ACL - [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = - &posix_acl_access_xattr_handler, - [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = - &posix_acl_default_xattr_handler, -#endif - [EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler, -#ifdef CONFIG_EROFS_FS_SECURITY - [EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler, -#endif - }; - - return idx && idx < ARRAY_SIZE(xattr_handler_map) ? - xattr_handler_map[idx] : NULL; -} - extern const struct xattr_handler *erofs_xattr_handlers[]; int erofs_getxattr(struct inode *, int, const char *, void *, size_t); From patchwork Wed Jan 25 11:28:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 863D1C61DA7 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235575AbjAYLaH (ORCPT ); Wed, 25 Jan 2023 06:30:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235617AbjAYL3n (ORCPT ); Wed, 25 Jan 2023 06:29:43 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 033FE244B7; Wed, 25 Jan 2023 03:29:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 834EEB81990; Wed, 25 Jan 2023 11:29:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08C0DC4339B; Wed, 25 Jan 2023 11:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646178; bh=/aCnVtMqRsFxCKOkrIG2QAmkVkNmJ/VxqZjQsKF8mpU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=l8PIjUpeoAhBCrIPONenXO3sNukZhJdLUwWEz9P23/doB8yRRd/4xZP4X5eSg1Li8 drhmb5M54dknXeHwMP/LBMgnJcMN3iEKmBjGLlTw48tnilBqTQFN62jnyqFB4RQdQD JFhTSkVBz9At5Rw/PkZZGkDybaAM4+shzOx8NRg1Ua8zZZeq5xX0fwMwr8yCi6Dbb4 IwmIBiBDQ3JbXlRR/S1XXEqUPG0djYve7zKgn/SAOEJAFhnKZn7J2yHJ4XabTrE3qY k2DdbSej0fscOVHZ6Pil43xn6JW/Zg78BIs/LWSoZ1xJaA/FnB1tk5qY/6wsD5rvYT XcGWQY6MY4q/g== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:51 +0100 Subject: [PATCH 06/12] ext2: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-6-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , Jan Kara , linux-ext4@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3928; i=brauner@kernel.org; h=from:subject:message-id; bh=/aCnVtMqRsFxCKOkrIG2QAmkVkNmJ/VxqZjQsKF8mpU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJp4+UPud5NDUzkv3hb8vuhwjKvegwtvl6+7+vnOtWUK tjwV1zpKWRjEuBhkxRRZHNpNwuWW81RsNsrUgJnDygQyhIGLUwAmErODkaH7u+Y8X6nDT8R+1Sd+fn xUrs9+icrd2Fk7W30+ZB78PPEQw/8IN/mj1pvCGV34+0M5FHnnMNg32wt+nHn4pkKZ2KYX/CwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Jan Kara Cc: Signed-off-by: Christian Brauner (Microsoft) Acked-by: Jan Kara --- fs/ext2/xattr.c | 60 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 641abfa4b718..86ba6a33349e 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c @@ -98,25 +98,9 @@ static struct buffer_head *ext2_xattr_cache_find(struct inode *, static void ext2_xattr_rehash(struct ext2_xattr_header *, struct ext2_xattr_entry *); -static const struct xattr_handler *ext2_xattr_handler_map[] = { - [EXT2_XATTR_INDEX_USER] = &ext2_xattr_user_handler, -#ifdef CONFIG_EXT2_FS_POSIX_ACL - [EXT2_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, - [EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, -#endif - [EXT2_XATTR_INDEX_TRUSTED] = &ext2_xattr_trusted_handler, -#ifdef CONFIG_EXT2_FS_SECURITY - [EXT2_XATTR_INDEX_SECURITY] = &ext2_xattr_security_handler, -#endif -}; - const struct xattr_handler *ext2_xattr_handlers[] = { &ext2_xattr_user_handler, &ext2_xattr_trusted_handler, -#ifdef CONFIG_EXT2_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif #ifdef CONFIG_EXT2_FS_SECURITY &ext2_xattr_security_handler, #endif @@ -125,14 +109,41 @@ const struct xattr_handler *ext2_xattr_handlers[] = { #define EA_BLOCK_CACHE(inode) (EXT2_SB(inode->i_sb)->s_ea_block_cache) -static inline const struct xattr_handler * -ext2_xattr_handler(int name_index) +static const char *ext2_xattr_prefix(int xattr_index, struct dentry *dentry) { + const char *name = NULL; const struct xattr_handler *handler = NULL; - if (name_index > 0 && name_index < ARRAY_SIZE(ext2_xattr_handler_map)) - handler = ext2_xattr_handler_map[name_index]; - return handler; + switch (xattr_index) { + case EXT2_XATTR_INDEX_USER: + handler = &ext2_xattr_user_handler; + break; + case EXT2_XATTR_INDEX_TRUSTED: + handler = &ext2_xattr_trusted_handler; + break; +#ifdef CONFIG_EXT2_FS_SECURITY + case EXT2_XATTR_INDEX_SECURITY: + handler = &ext2_xattr_security_handler; + break; +#endif +#ifdef CONFIG_EXT2_FS_POSIX_ACL + case EXT2_XATTR_INDEX_POSIX_ACL_ACCESS: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; +#endif + default: + return NULL; + } + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; } static bool @@ -333,11 +344,10 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size) /* list the attribute names */ for (entry = FIRST_ENTRY(bh); !IS_LAST_ENTRY(entry); entry = EXT2_XATTR_NEXT(entry)) { - const struct xattr_handler *handler = - ext2_xattr_handler(entry->e_name_index); + const char *prefix; - if (handler && (!handler->list || handler->list(dentry))) { - const char *prefix = handler->prefix ?: handler->name; + prefix = ext2_xattr_prefix(entry->e_name_index, dentry); + if (prefix) { size_t prefix_len = strlen(prefix); size_t size = prefix_len + entry->e_name_len + 1; From patchwork Wed Jan 25 11:28:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9639FC636CB for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234993AbjAYLaK (ORCPT ); Wed, 25 Jan 2023 06:30:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235676AbjAYL3o (ORCPT ); Wed, 25 Jan 2023 06:29:44 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF0E528D04; Wed, 25 Jan 2023 03:29:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4814B614C8; Wed, 25 Jan 2023 11:29:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C46D2C433EF; Wed, 25 Jan 2023 11:29:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646180; bh=L83frKBR+KHV5qJCuYpyI67ZuEsOVDhNuZ4zqzpj91M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZBLxtHhJZSGOwVTyvnv9aW5SxeFNAYTSaW3eYC+JaK8rDWkkqCsz+Fpa8Ypmhycv2 mIJ3nqtsRaT3SKPHi7cvO5/kWVGt0iLdtJrUCnbpUS18PSB8RVy6a5DyyZlFTgKHEm m6q8UwhhsA21TcP7VjtBB5GVtHMEbUtciEE3lhUc0ESjjSU2AT2s7m3luui3xKq7jQ cUpwZes96SP1i4a8p9Grk4UnAW1N+o6WyfBxJ3a9SUqaZkTxlfYNsCl6hDXVC0bCCP 1BiyvskVSBlFQW1bg1kikSvBVHF1M7GSiARctU0aqlejpSztBf3FsddisDktZjBoVu Osb2wZAm10X6A== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:52 +0100 Subject: [PATCH 07/12] ext4: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-7-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , linux-ext4@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4272; i=brauner@kernel.org; h=from:subject:message-id; bh=L83frKBR+KHV5qJCuYpyI67ZuEsOVDhNuZ4zqzpj91M=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJrYdka74MCWN9OS/fr1G74vf5pnpHR7p+D1L3nsj25I F0nf7ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIHWuGfyo315Y+Oaxel13VsrlPKs GXXfFe7/qGWwEzwl93LpZaUcLIsDpKbrKxRWdBOAvPgQXmrukJ/5oj1fMY980JSWQ2E+biBQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/ext4/xattr.c | 71 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 7decaaf27e82..5472b8eac672 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -83,26 +83,9 @@ static __le32 ext4_xattr_hash_entry(char *name, size_t name_len, __le32 *value, size_t value_count); static void ext4_xattr_rehash(struct ext4_xattr_header *); -static const struct xattr_handler * const ext4_xattr_handler_map[] = { - [EXT4_XATTR_INDEX_USER] = &ext4_xattr_user_handler, -#ifdef CONFIG_EXT4_FS_POSIX_ACL - [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, - [EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, -#endif - [EXT4_XATTR_INDEX_TRUSTED] = &ext4_xattr_trusted_handler, -#ifdef CONFIG_EXT4_FS_SECURITY - [EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler, -#endif - [EXT4_XATTR_INDEX_HURD] = &ext4_xattr_hurd_handler, -}; - const struct xattr_handler *ext4_xattr_handlers[] = { &ext4_xattr_user_handler, &ext4_xattr_trusted_handler, -#ifdef CONFIG_EXT4_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif #ifdef CONFIG_EXT4_FS_SECURITY &ext4_xattr_security_handler, #endif @@ -110,6 +93,43 @@ const struct xattr_handler *ext4_xattr_handlers[] = { NULL }; +static const char *ext4_xattr_prefix(int xattr_index, struct dentry *dentry) +{ + const char *name = NULL; + const struct xattr_handler *handler = NULL; + + switch (xattr_index) { + case EXT4_XATTR_INDEX_USER: + handler = &ext4_xattr_user_handler; + break; + case EXT4_XATTR_INDEX_TRUSTED: + handler = &ext4_xattr_trusted_handler; + break; +#ifdef CONFIG_EXT4_FS_SECURITY + case EXT4_XATTR_INDEX_SECURITY: + handler = &ext4_xattr_security_handler; + break; +#endif +#ifdef CONFIG_EXT4_FS_POSIX_ACL + case EXT4_XATTR_INDEX_POSIX_ACL_ACCESS: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; +#endif + default: + return NULL; + } + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; +} + #define EA_BLOCK_CACHE(inode) (((struct ext4_sb_info *) \ inode->i_sb->s_fs_info)->s_ea_block_cache) @@ -171,16 +191,6 @@ static void ext4_xattr_block_csum_set(struct inode *inode, bh->b_blocknr, BHDR(bh)); } -static inline const struct xattr_handler * -ext4_xattr_handler(int name_index) -{ - const struct xattr_handler *handler = NULL; - - if (name_index > 0 && name_index < ARRAY_SIZE(ext4_xattr_handler_map)) - handler = ext4_xattr_handler_map[name_index]; - return handler; -} - static int ext4_xattr_check_entries(struct ext4_xattr_entry *entry, void *end, void *value_start) @@ -679,11 +689,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry, size_t rest = buffer_size; for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) { - const struct xattr_handler *handler = - ext4_xattr_handler(entry->e_name_index); + const char *prefix; - if (handler && (!handler->list || handler->list(dentry))) { - const char *prefix = handler->prefix ?: handler->name; + prefix = ext4_xattr_prefix(entry->e_name_index, dentry); + if (prefix) { size_t prefix_len = strlen(prefix); size_t size = prefix_len + entry->e_name_len + 1; From patchwork Wed Jan 25 11:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5EA3C636BD for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235661AbjAYLaM (ORCPT ); Wed, 25 Jan 2023 06:30:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235729AbjAYL3r (ORCPT ); Wed, 25 Jan 2023 06:29:47 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60DD89EF8 for ; Wed, 25 Jan 2023 03:29:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 09780B8191A for ; Wed, 25 Jan 2023 11:29:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C13AC4339E; Wed, 25 Jan 2023 11:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646182; bh=xUJebQ0e9KwSrY/Cal4CAWhcfhSdz9RiiwAWxi4+KHc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cozUATMauQjoFoE5hvkPr3B8PLlGiW9MIxmWen0gF5YS0pgPqXF4Pn9S0uVbr+uYc p491Vbspem4g0PCceifALOTy6+qpfE5kh/4jStAxD+ZuKyYh0DxthtjJI4hQ7AWHFk b/fuJK+2etQRxLoSUz5B53F8exR1AtrjGyeIe12JxcWlBMZ3V+mnl/TttpVH5tUL0q gTwehhNG5kDIv5l9NTUrGlkxx3X4kbOtust3QDGfEIg7G3Rs+XCpIss1ACzBvsuqWS x1sg9/dCn9u129Cr/KNRlE3sLRhKJRlmxglFod74Z71pw0JW+wAJNfUMcilK9LdLyQ y2Rw4Ww0qzb/w== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:53 +0100 Subject: [PATCH 08/12] f2fs: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-8-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , linux-f2fs-devel@lists.sourceforge.net X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4258; i=brauner@kernel.org; h=from:subject:message-id; bh=xUJebQ0e9KwSrY/Cal4CAWhcfhSdz9RiiwAWxi4+KHc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJo4R/Ewy9Nf8XlH1lk8Wza9MPAK53VNoYdMX0ydX15S m3EqtqOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAi93sYGbaf/ODb2vt+zuIgaS/j00 sL73qtV3355daEa3pPt8VtbvFlZLgVWjcxz8ixvPOexxans++qrF/uSFf4VCiod6a0MOLIOS4A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/f2fs/xattr.c | 63 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index dc2e8637189e..e5bd071fac8c 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -189,25 +189,8 @@ const struct xattr_handler f2fs_xattr_security_handler = { .set = f2fs_xattr_generic_set, }; -static const struct xattr_handler *f2fs_xattr_handler_map[] = { - [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler, -#ifdef CONFIG_F2FS_FS_POSIX_ACL - [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler, - [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler, -#endif - [F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler, -#ifdef CONFIG_F2FS_FS_SECURITY - [F2FS_XATTR_INDEX_SECURITY] = &f2fs_xattr_security_handler, -#endif - [F2FS_XATTR_INDEX_ADVISE] = &f2fs_xattr_advise_handler, -}; - const struct xattr_handler *f2fs_xattr_handlers[] = { &f2fs_xattr_user_handler, -#ifdef CONFIG_F2FS_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, -#endif &f2fs_xattr_trusted_handler, #ifdef CONFIG_F2FS_FS_SECURITY &f2fs_xattr_security_handler, @@ -216,13 +199,44 @@ const struct xattr_handler *f2fs_xattr_handlers[] = { NULL, }; -static inline const struct xattr_handler *f2fs_xattr_handler(int index) +static const char *f2fs_xattr_prefix(int xattr_index, struct dentry *dentry) { + const char *name = NULL; const struct xattr_handler *handler = NULL; - if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map)) - handler = f2fs_xattr_handler_map[index]; - return handler; + switch (xattr_index) { + case F2FS_XATTR_INDEX_USER: + handler = &f2fs_xattr_user_handler; + break; + case F2FS_XATTR_INDEX_TRUSTED: + handler = &f2fs_xattr_trusted_handler; + break; + case F2FS_XATTR_INDEX_ADVISE: + handler = &f2fs_xattr_advise_handler; + break; +#ifdef CONFIG_F2FS_FS_SECURITY + case F2FS_XATTR_INDEX_SECURITY: + handler = &f2fs_xattr_security_handler; + break; +#endif +#ifdef CONFIG_F2FS_FS_POSIX_ACL + case F2FS_XATTR_INDEX_POSIX_ACL_ACCESS: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT: + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; +#endif + default: + return NULL; + } + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; } static struct f2fs_xattr_entry *__find_xattr(void *base_addr, @@ -573,12 +587,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) last_base_addr = (void *)base_addr + XATTR_SIZE(inode); list_for_each_xattr(entry, base_addr) { - const struct xattr_handler *handler = - f2fs_xattr_handler(entry->e_name_index); const char *prefix; size_t prefix_len; size_t size; + prefix = f2fs_xattr_prefix(entry->e_name_index, dentry); + if ((void *)(entry) + sizeof(__u32) > last_base_addr || (void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) { f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr", @@ -590,10 +604,9 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) goto cleanup; } - if (!handler || (handler->list && !handler->list(dentry))) + if (!prefix) continue; - prefix = xattr_prefix(handler); prefix_len = strlen(prefix); size = prefix_len + entry->e_name_len + 1; if (buffer) { From patchwork Wed Jan 25 11:28:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115552 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5CB5C636CD for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234873AbjAYLaP (ORCPT ); Wed, 25 Jan 2023 06:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235732AbjAYL3r (ORCPT ); Wed, 25 Jan 2023 06:29:47 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1540822A33 for ; Wed, 25 Jan 2023 03:29:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A616661356 for ; Wed, 25 Jan 2023 11:29:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49036C4339C; Wed, 25 Jan 2023 11:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646185; bh=6r8RQh6tLH90oDxRR8sLeViDQoVA80avbvRgVwUU3Yg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XMDpKqbpUAVmqDTm7pZEcTXvThgRxpkDZG6NtSYWVWJcCDJ4ZYdSJG/M9J0PIOlLc JEQb9AObtaef/Chu2cyOPTd9p55hF5A6Krv6a8ep7zfYg8+4Onr2Lg25SX8yTVlo8b ThM9sd6AeyLe8T1d0aGsmiHp+3mhccXL70LA5gXUIh/fP6t6eo7cB9pah6rwDt0Vu+ a6YucsiQOSurAeM4GvAF6GvD+uGc7qktMEXPLUsuYMT9ywpg/3D2QBNQcfjAAOsLlk WngOziFjEPfV+/PQYsSRgBIPxHfWj54SB/DrGNELcKMeFWoBPS/S4APE//9ciR8kMu 0FeMmMO9MtthQ== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:54 +0100 Subject: [PATCH 09/12] jffs2: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-9-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , linux-mtd@lists.infradead.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3423; i=brauner@kernel.org; h=from:subject:message-id; bh=6r8RQh6tLH90oDxRR8sLeViDQoVA80avbvRgVwUU3Yg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJp05d+95bf+fmCyPWl0U6v0p6vtw/e5F6S+PJ15bNrZ z677eTpKWRjEuBhkxRRZHNpNwuWW81RsNsrUgJnDygQyhIGLUwAmkj6XkeFy0LJJL9/naQo/EEi2eP t5XYH6vCeO6g5C+ur6Bg6vwmUYGa43NLzrOTbrj6pMeecD45Ufp2hLdjwKrpin+CB9nVqSMjsA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/jffs2/xattr.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index da3e18503c65..40cf03dc34be 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c @@ -919,43 +919,46 @@ const struct xattr_handler *jffs2_xattr_handlers[] = { &jffs2_user_xattr_handler, #ifdef CONFIG_JFFS2_FS_SECURITY &jffs2_security_xattr_handler, -#endif -#ifdef CONFIG_JFFS2_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, #endif &jffs2_trusted_xattr_handler, NULL }; -static const struct xattr_handler *xprefix_to_handler(int xprefix) { - const struct xattr_handler *ret; +static const char *jffs2_xattr_prefix(int xprefix, struct dentry *dentry) +{ + const char *name = NULL; + const struct xattr_handler *handler = NULL; switch (xprefix) { case JFFS2_XPREFIX_USER: - ret = &jffs2_user_xattr_handler; + handler = &jffs2_user_xattr_handler; + break; + case JFFS2_XPREFIX_TRUSTED: + handler = &jffs2_trusted_xattr_handler; break; #ifdef CONFIG_JFFS2_FS_SECURITY case JFFS2_XPREFIX_SECURITY: - ret = &jffs2_security_xattr_handler; + handler = &jffs2_security_xattr_handler; break; #endif #ifdef CONFIG_JFFS2_FS_POSIX_ACL case JFFS2_XPREFIX_ACL_ACCESS: - ret = &posix_acl_access_xattr_handler; + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_ACCESS; break; case JFFS2_XPREFIX_ACL_DEFAULT: - ret = &posix_acl_default_xattr_handler; + if (posix_acl_dentry_list(dentry)) + name = XATTR_NAME_POSIX_ACL_DEFAULT; break; #endif - case JFFS2_XPREFIX_TRUSTED: - ret = &jffs2_trusted_xattr_handler; - break; default: - ret = NULL; - break; + return NULL; } - return ret; + + if (xattr_dentry_list(handler, dentry)) + name = xattr_prefix(handler); + + return name; } ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) @@ -966,7 +969,6 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) struct jffs2_inode_cache *ic = f->inocache; struct jffs2_xattr_ref *ref, **pref; struct jffs2_xattr_datum *xd; - const struct xattr_handler *xhandle; const char *prefix; ssize_t prefix_len, len, rc; int retry = 0; @@ -998,10 +1000,10 @@ ssize_t jffs2_listxattr(struct dentry *dentry, char *buffer, size_t size) goto out; } } - xhandle = xprefix_to_handler(xd->xprefix); - if (!xhandle || (xhandle->list && !xhandle->list(dentry))) + + prefix = jffs2_xattr_prefix(xd->xprefix, dentry); + if (!prefix) continue; - prefix = xhandle->prefix ?: xhandle->name; prefix_len = strlen(prefix); rc = prefix_len + xd->name_len + 1; From patchwork Wed Jan 25 11:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115555 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D53A7C636CC for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235722AbjAYLaR (ORCPT ); Wed, 25 Jan 2023 06:30:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235024AbjAYL3v (ORCPT ); Wed, 25 Jan 2023 06:29:51 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34ADA22A18 for ; Wed, 25 Jan 2023 03:29:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E0811B81990 for ; Wed, 25 Jan 2023 11:29:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A178AC433A1; Wed, 25 Jan 2023 11:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646187; bh=IOzssTgtK++UqVcJ5HUSWWFIaDrn43ndUjBrAjyFiaU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dJV9+p9ePI3jx5JC9RvTtdzmW1bNqW1rsHe0cmGA6kJs92nv9sD5fIBkqleTFMBLj mYd6bQ6V/xxr3LaywZ7SXG2zALJFaZukjVImD/7wVfnjG/oHG1hUJ4FxL4k/PPJtGN ZlLquvMiwjZi1Rx/MZjfUORVlg9e76o1yEwZN4k0HhhmRzpUYrRJ1hIoLt7/xAmahk hTxcE2F3jcshpf4F97YK4cxgJOsvnvTFiZOW4ejFP3SkOum4XQHFhZpc0AU0sylydp AnvzLQ/MHW4pyUCigmxXVlRhUgbUs0uxvYsE7SyfhrbLF/zwI0PtZpNpGfJttcKN0j bQe613ufERfrw== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:55 +0100 Subject: [PATCH 10/12] ocfs2: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-10-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , ocfs2-devel@oss.oracle.com X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2847; i=brauner@kernel.org; h=from:subject:message-id; bh=IOzssTgtK++UqVcJ5HUSWWFIaDrn43ndUjBrAjyFiaU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJr0gc14+e+JtjaTM+wZKpOMl6zUZWGsmHtpcsAxZ8v9 ibETO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZyTI3hf/2SS7sUq53Ft1/Yxb13td diR/E923/qrJ5telPw8MfzLNGMDK+KzdrWei9Iapx3QbfIZhNvzxudhO6W5ROs2t/9r/0rxg8A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/ocfs2/xattr.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 95d0611c5fc7..e55cd11d72fc 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c @@ -89,23 +89,11 @@ static struct ocfs2_xattr_def_value_root def_xv = { const struct xattr_handler *ocfs2_xattr_handlers[] = { &ocfs2_xattr_user_handler, - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, &ocfs2_xattr_trusted_handler, &ocfs2_xattr_security_handler, NULL }; -static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = { - [OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler, - [OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS] - = &posix_acl_access_xattr_handler, - [OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT] - = &posix_acl_default_xattr_handler, - [OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler, - [OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler, -}; - struct ocfs2_xattr_info { int xi_name_index; const char *xi_name; @@ -528,13 +516,34 @@ static int ocfs2_read_xattr_block(struct inode *inode, u64 xb_blkno, return rc; } -static inline const char *ocfs2_xattr_prefix(int name_index) +static const char *ocfs2_xattr_prefix(int xattr_index) { + const char *name = NULL; const struct xattr_handler *handler = NULL; - if (name_index > 0 && name_index < OCFS2_XATTR_MAX) - handler = ocfs2_xattr_handler_map[name_index]; - return handler ? xattr_prefix(handler) : NULL; + switch (xattr_index) { + case OCFS2_XATTR_INDEX_USER: + handler = &ocfs2_xattr_user_handler; + break; + case OCFS2_XATTR_INDEX_TRUSTED: + handler = &ocfs2_xattr_trusted_handler; + break; + case OCFS2_XATTR_INDEX_SECURITY: + handler = &ocfs2_xattr_security_handler; + break; + case OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS: + name = XATTR_NAME_POSIX_ACL_ACCESS; + break; + case OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT: + name = XATTR_NAME_POSIX_ACL_DEFAULT; + break; + default: + return NULL; + } + + name = xattr_prefix(handler); + + return name; } static u32 ocfs2_xattr_name_hash(struct inode *inode, From patchwork Wed Jan 25 11:28:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115556 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A08C636D0 for ; Wed, 25 Jan 2023 11:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235769AbjAYLaT (ORCPT ); Wed, 25 Jan 2023 06:30:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235762AbjAYL3w (ORCPT ); Wed, 25 Jan 2023 06:29:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E313022A33; Wed, 25 Jan 2023 03:29:50 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7E8BE614C0; Wed, 25 Jan 2023 11:29:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B6C2C4339E; Wed, 25 Jan 2023 11:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646189; bh=AoICruiO1fmkjMmVCbtvYwyBOmjeAS6gY4YyaNR8wz0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dF4D8bF47RsyStOaLuvZJIgd6MZaGTgdo5DoiqntT3BlbSbqElPDUPL5cWz6gZT+U HyHGVef2rEGo8gGG41m3i8nc8sJqNS1wc6q1Lit5U2iAF2zpdVj46Chd53+jEKiIY0 9lr+Wg8ErLBAt3M06dVdXmK9gzWxM2M+TZQm2EwHB/fOxiDHw94yHCfgcts9Vcaw9u 8/7rUzcCg+dUvKBRCmRgkjnk5CS6OJW9K8GE/WnIFGGKIGQvRW0ETscc2SuebUaQxS pLgCTwJPYfY1UzxMPEr2vsBXVWfoyMKjmXo3mTGa1B4uY5se67DKY4pxce4LdYy/DY zTwvrANTf6PdA== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:56 +0100 Subject: [PATCH 11/12] reiserfs: drop posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-11-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" , reiserfs-devel@vger.kernel.org X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3133; i=brauner@kernel.org; h=from:subject:message-id; bh=AoICruiO1fmkjMmVCbtvYwyBOmjeAS6gY4YyaNR8wz0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJpknfH6FsONWq05LiZuKbdZ9TPV65bNe3A/IVT5Os+p 7as5OkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZiYsfIsGn6vXfqejUrQnScqv9pcG 5wCJi1aH7rG5PEDdNT1908yM3I8OF1kaT0a2b5s+t/Xub0LG5he8il8C59B5fubMnf06YU8AAA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: Signed-off-by: Christian Brauner (Microsoft) --- fs/reiserfs/xattr.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c index 8b2d52443f41..cc6f42128031 100644 --- a/fs/reiserfs/xattr.c +++ b/fs/reiserfs/xattr.c @@ -52,6 +52,7 @@ #include #include #include +#include #define PRIVROOT_NAME ".reiserfs_priv" #define XAROOT_NAME "xattrs" @@ -771,22 +772,26 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer, (handler) = *(handlers)++) /* This is the implementation for the xattr plugin infrastructure */ -static inline const struct xattr_handler * -find_xattr_handler_prefix(const struct xattr_handler **handlers, - const char *name) +static inline bool reiserfs_xattr_list(const struct xattr_handler **handlers, + const char *name, struct dentry *dentry) { - const struct xattr_handler *xah; + const struct xattr_handler *xah = NULL; - if (!handlers) - return NULL; + if (handlers) { + for_each_xattr_handler(handlers, xah) { + const char *prefix = xattr_prefix(xah); - for_each_xattr_handler(handlers, xah) { - const char *prefix = xattr_prefix(xah); - if (strncmp(prefix, name, strlen(prefix)) == 0) - break; + if (strncmp(prefix, name, strlen(prefix))) + continue; + + if (!xattr_dentry_list(xah, dentry)) + return false; + + return true; + } } - return xah; + return (posix_acl_type(name) >= 0) && posix_acl_dentry_list(dentry); } struct listxattr_buf { @@ -807,12 +812,7 @@ static bool listxattr_filler(struct dir_context *ctx, const char *name, if (name[0] != '.' || (namelen != 1 && (name[1] != '.' || namelen != 2))) { - const struct xattr_handler *handler; - - handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, - name); - if (!handler /* Unsupported xattr name */ || - (handler->list && !handler->list(b->dentry))) + if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name, b->dentry)) return true; size = namelen + 1; if (b->buf) { @@ -910,10 +910,6 @@ const struct xattr_handler *reiserfs_xattr_handlers[] = { #endif #ifdef CONFIG_REISERFS_FS_SECURITY &reiserfs_xattr_security_handler, -#endif -#ifdef CONFIG_REISERFS_FS_POSIX_ACL - &posix_acl_access_xattr_handler, - &posix_acl_default_xattr_handler, #endif NULL }; From patchwork Wed Jan 25 11:28:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13115554 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00CDAC636D3 for ; Wed, 25 Jan 2023 11:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235756AbjAYLaU (ORCPT ); Wed, 25 Jan 2023 06:30:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235763AbjAYL3x (ORCPT ); Wed, 25 Jan 2023 06:29:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E851E9EF8 for ; Wed, 25 Jan 2023 03:29:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83EA2614C7 for ; Wed, 25 Jan 2023 11:29:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CE3DC4339C; Wed, 25 Jan 2023 11:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674646192; bh=2hyKsONoFMtmM8iTjuJTXUT79jOLhlYjsFLY9rKXI9A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OCwnQtKZDEALzjBEjed/2kj+0N7kbW8pwocjz2w7xgcD4RY5kpsW0qhlvOpdVPDmh /2tIYf9WL62TAFbAGpR57+RrOisd4EKSKQbsWxCVme8nCgZdR+utW1YvBUOWRJoH30 Vf8707ZgptcICq/48xa748h3hbRftBSIqZyd9kaR1OJFA9OANCSZJiTH5+d0Sgp3fK 936qx9gA2ZhBaXk3aJZRW4PGAnP4s7eQUsaQUORyDSeJRWxJvjcL3S7QEfTlYtxBp6 pcxQnp5zSk5ApP3i90BDtdpyrr1nKvSo57g7XRVBTYXAMALHuGswLynNHq8L1SiN6h F++aD95XzKsuQ== From: Christian Brauner Date: Wed, 25 Jan 2023 12:28:57 +0100 Subject: [PATCH 12/12] acl: remove posix acl handlers MIME-Version: 1.0 Message-Id: <20230125-fs-acl-remove-generic-xattr-handlers-v1-12-6cf155b492b6@kernel.org> References: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> In-Reply-To: <20230125-fs-acl-remove-generic-xattr-handlers-v1-0-6cf155b492b6@kernel.org> To: linux-fsdevel@vger.kernel.org, Christoph Hellwig Cc: Al Viro , Seth Forshee , "Christian Brauner (Microsoft)" X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1998; i=brauner@kernel.org; h=from:subject:message-id; bh=2hyKsONoFMtmM8iTjuJTXUT79jOLhlYjsFLY9rKXI9A=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMSRfFJq0R+Fh3QbvuwqFvKb7L/HKLFbtv85vkyG6q8nbKGrR ur9iHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPRzmf4K8XOUTnPit2nQpSltOKYXN 1clWIhU/PwNdmSPLInKg7MYPjDM9lhNnPEx70upTnLY9esvJ3OrnpQ+pGV1gaWhYrxhfaMAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Now that everything in the VFS and all filesystems just rely on the dedicated inode methods to interact with posix acls we can remove the dummy generic posix acl xattr handlers. This way no filesystem an be falsely under the impression that they are needed to implement posix acl support. Signed-off-by: Christian Brauner (Microsoft) --- fs/posix_acl.c | 20 -------------------- include/linux/posix_acl_xattr.h | 3 --- 2 files changed, 23 deletions(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index d7bc81fc0840..8028b6ee38a0 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -958,26 +958,6 @@ set_posix_acl(struct user_namespace *mnt_userns, struct dentry *dentry, } EXPORT_SYMBOL(set_posix_acl); -static bool -posix_acl_xattr_list(struct dentry *dentry) -{ - return IS_POSIXACL(d_backing_inode(dentry)); -} - -const struct xattr_handler posix_acl_access_xattr_handler = { - .name = XATTR_NAME_POSIX_ACL_ACCESS, - .flags = ACL_TYPE_ACCESS, - .list = posix_acl_xattr_list, -}; -EXPORT_SYMBOL_GPL(posix_acl_access_xattr_handler); - -const struct xattr_handler posix_acl_default_xattr_handler = { - .name = XATTR_NAME_POSIX_ACL_DEFAULT, - .flags = ACL_TYPE_DEFAULT, - .list = posix_acl_xattr_list, -}; -EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler); - int simple_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry, struct posix_acl *acl, int type) { diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h index 905d532ccd6e..bb657f3336e8 100644 --- a/include/linux/posix_acl_xattr.h +++ b/include/linux/posix_acl_xattr.h @@ -73,7 +73,4 @@ static inline bool posix_acl_dentry_list(struct dentry *dentry) return IS_POSIXACL(d_backing_inode(dentry)); } -extern const struct xattr_handler posix_acl_access_xattr_handler; -extern const struct xattr_handler posix_acl_default_xattr_handler; - #endif /* _POSIX_ACL_XATTR_H */