From patchwork Wed Oct 19 08:24:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp249971wrs; Wed, 19 Oct 2022 03:47:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49gEhVjDeeTzbF6PA/4bfuoc2C0wvUJYNhE2W+dmH19r84NpA4aNQ91ID+/Juz8cWLkK+S X-Received: by 2002:a05:6402:3806:b0:450:bad8:8cd5 with SMTP id es6-20020a056402380600b00450bad88cd5mr7017459edb.305.1666176462328; Wed, 19 Oct 2022 03:47:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666176462; cv=none; d=google.com; s=arc-20160816; b=FljOw9u0U6xUnY8O0Db0s9mDNPEMsh2a6B3dZAOgTxcH5LroQCN7cqgwa8vXWgu6s+ ty3Dt+Cx+rMDMFwVfnzvHB5FxKIguJ+x18val8Zk3szy7wa7+j4ej+JUhCxS//qrmijV jZRLC9mLtMY4gdQorb+wln1eqsTUTIKagotMDXRe2aUP3qw2JrKePJvovTpjvSU9j3qQ /CZgFXLLzdlT2FnkmED58NLObPfT7Ihneo7P5l4ApvCzXTK98F0KCN6+ySNS30U6IHjP qb7YOcFpysveLi4NxiVr0FxuB3SbN5jayYIKR0r+7QhTiBmrDZKqJp3rCV46RYL9zXav F0jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ECdlPo2HcH5m/MhhAi1p9TSPoKOiFn/cC0ssIDVBA9k=; b=Q4UJp830cQup4CxoqmDRvjhQV6UxW5k19eDOd0lCHGdOtPBnJ6+ZqpTKj6RGBYbZ29 uVda6hCwAAU9TVMLOPV/QJPIdsmnFDPGZ2KiSuNAdTapfpIObGRve2sDlL+HX8+Aijyd Ddople0Z6Gcp/ry6ZtFG+AdPEaFR1oUE8C9gDB2OAkkWNgYWO1RqPQtQb0bcAtcYsqC2 o/gVGSo00k5gYpwcbzAkrsILsMnu6YpY1X+4H1OlaFy0PnCrP3hhQLp19sQU8hEzbcBL UFgUzFFjJ8hT1QUysI/diwtMz8ahICIkVAc4AqjvORMOyXQ2wsEFswqZoeZ2NRjVCIdJ /x1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZESqIxcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a056402349600b0045cea9cf231si15979056edc.566.2022.10.19.03.47.17; Wed, 19 Oct 2022 03:47:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZESqIxcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbiJSKrB (ORCPT + 99 others); Wed, 19 Oct 2022 06:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbiJSKop (ORCPT ); Wed, 19 Oct 2022 06:44:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D75121F2CF; Wed, 19 Oct 2022 03:21:15 -0700 (PDT) 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 DF565B8231A; Wed, 19 Oct 2022 08:47:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56839C433D7; Wed, 19 Oct 2022 08:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169239; bh=fh45nFe3rfXMwurcMd+R47taX1sPGPQRXV1ZR1n3M1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZESqIxcZ3aXcNbkzvFGfnKqojtum0EV82/nlfKs4eABMLnEf9jfSPbn393p9pcLTy wuuRmfsVDIG96KiEvHN7EP0ioTUJkELHFAA+dkncML4ZnHgSFFb3bcsinFhHwnGkZE 5SeZTTnwSTuqhXcR+AfLDDlEsE7E5glc2XY+NhOI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Christian Brauner (Microsoft)" , Sasha Levin , Seth Forshee Subject: [PATCH 6.0 206/862] acl: return EOPNOTSUPP in posix_acl_fix_xattr_common() Date: Wed, 19 Oct 2022 10:24:53 +0200 Message-Id: <20221019083259.111043097@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747112649903547809?= X-GMAIL-MSGID: =?utf-8?q?1747112649903547809?= From: Christian Brauner [ Upstream commit 985a6d0b3c800265a2d5312a52c549bf09254e55 ] Return EOPNOTSUPP when the POSIX ACL version doesn't match and zero if there are no entries. This will allow us to reuse the helper in posix_acl_from_xattr(). This change will have no user visible effects. Fixes: 0c5fd887d2bb ("acl: move idmapped mount fixup into vfs_{g,s}etxattr()") Signed-off-by: Christian Brauner (Microsoft) Reviewed-by: Seth Forshee (DigitalOcean) > Signed-off-by: Sasha Levin --- fs/posix_acl.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 5af33800743e..abe387700ba9 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -710,9 +710,9 @@ EXPORT_SYMBOL(posix_acl_update_mode); /* * Fix up the uids and gids in posix acl extended attributes in place. */ -static int posix_acl_fix_xattr_common(void *value, size_t size) +static int posix_acl_fix_xattr_common(const void *value, size_t size) { - struct posix_acl_xattr_header *header = value; + const struct posix_acl_xattr_header *header = value; int count; if (!header) @@ -720,13 +720,13 @@ static int posix_acl_fix_xattr_common(void *value, size_t size) if (size < sizeof(struct posix_acl_xattr_header)) return -EINVAL; if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) - return -EINVAL; + return -EOPNOTSUPP; count = posix_acl_xattr_count(size); if (count < 0) return -EINVAL; if (count == 0) - return -EINVAL; + return 0; return count; } @@ -748,7 +748,7 @@ void posix_acl_getxattr_idmapped_mnt(struct user_namespace *mnt_userns, return; count = posix_acl_fix_xattr_common(value, size); - if (count < 0) + if (count <= 0) return; for (end = entry + count; entry != end; entry++) { @@ -788,7 +788,7 @@ void posix_acl_setxattr_idmapped_mnt(struct user_namespace *mnt_userns, return; count = posix_acl_fix_xattr_common(value, size); - if (count < 0) + if (count <= 0) return; for (end = entry + count; entry != end; entry++) { @@ -822,7 +822,7 @@ static void posix_acl_fix_xattr_userns( kgid_t gid; count = posix_acl_fix_xattr_common(value, size); - if (count < 0) + if (count <= 0) return; for (end = entry + count; entry != end; entry++) { @@ -870,16 +870,9 @@ posix_acl_from_xattr(struct user_namespace *user_ns, struct posix_acl *acl; struct posix_acl_entry *acl_e; - if (!value) - return NULL; - if (size < sizeof(struct posix_acl_xattr_header)) - return ERR_PTR(-EINVAL); - if (header->a_version != cpu_to_le32(POSIX_ACL_XATTR_VERSION)) - return ERR_PTR(-EOPNOTSUPP); - - count = posix_acl_xattr_count(size); + count = posix_acl_fix_xattr_common(value, size); if (count < 0) - return ERR_PTR(-EINVAL); + return ERR_PTR(count); if (count == 0) return NULL;