Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6105543rwl; Tue, 4 Apr 2023 07:58:00 -0700 (PDT) X-Google-Smtp-Source: AKy350aofCZGyN4FGqBL8AhERyktXmxqfAjq4Dpd9jI7ANYyhpjvswv2gEDIBR00IPPitQOgDiUt X-Received: by 2002:a17:906:d788:b0:91f:32f9:82f0 with SMTP id pj8-20020a170906d78800b0091f32f982f0mr2532140ejb.29.1680620280423; Tue, 04 Apr 2023 07:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680620280; cv=none; d=google.com; s=arc-20160816; b=lQ5UVjBYNoAjP+CQzPD/6p/8Rflx1HZQETH54a5dnGQBUfC0F7fDTQI59QE9yj2UAq qvz3/njT9CNLxMGccXTkZcwDP9wt49sHpKktbEoEMyjabCEQYS0VurFmfB2fpY4RfUxU fOYHELTHePJN2Sh8/RtH4iYnw6LqQ47A2bQFUIquIPMJoLtnnaSTxpOFQvCMUCwYbhuQ 1WA0LtqmDmx2GQWpR48d6RJxnujNDMJim/+MBWJUWAQFFATAJCXas5dQFB/Z6KE+xWV6 KerT4cWSJdxFvXtn+P8Pq6Ag8os9U7Aq4Sl1g3hY5BIbXZeUkQEhkpz5Cj4hoRJ5yVK3 5oaA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qBYfR9y7mc4emCV9kD7O8/LELcLcH0cCLkcuznWVRNE=; b=O8S75ZLMPiy2H2a2SkUavDllJMGg1KPynxFsj3wxfJUDAm4e3E298Urpo6/vl3yuME mKgfTbQeR2eyqyrooejIpTgQ22Tx32WOO3Icf+FNSTJDyi8LcwT/qmqCUt2FlgZjfFc4 JjhOllBjINw5uCNdaryxYNVm/aWgX4Khq3L/dNej9g3yePwI+1by1w12YKJIZuM+2fFO xSpCtbsAKyVzp9wk8FWwOwLTe7/c7hDVIZbW/+ZXyX7onjDnQxkShWnah57s+VbqBS4S 9Av2jvU1qVSVzDckb0D/ii/N1TnmRXd5hahd+EnILYeL0VIWLbs+DiVc0dZPavP/b2pC gUpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DNUo9tSN; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a1709061f1100b0093defbd626csi184555ejj.1011.2023.04.04.07.57.36; Tue, 04 Apr 2023 07:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@redhat.com header.s=mimecast20190719 header.b=DNUo9tSN; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233533AbjDDO5C (ORCPT + 99 others); Tue, 4 Apr 2023 10:57:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234717AbjDDO4e (ORCPT ); Tue, 4 Apr 2023 10:56:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F6834ED7 for ; Tue, 4 Apr 2023 07:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680620130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qBYfR9y7mc4emCV9kD7O8/LELcLcH0cCLkcuznWVRNE=; b=DNUo9tSNTan58T6LHxEDqKaztHmu8LQWTmtbAJskIBigdIT0l34qK9eWIgl+FMZfP+gIkS iSKtGnsWZwKEOfYykrzg4dDDi4uVG4+u48zp+Y0jJvJr5xpl7e/lckzv5wWevXEzBNafGh QiBEriG8YjsqjATwle2zgtgu5N/x26k= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-VtESmxkpNfStl22kFzP27Q-1; Tue, 04 Apr 2023 10:55:28 -0400 X-MC-Unique: VtESmxkpNfStl22kFzP27Q-1 Received: by mail-qt1-f197.google.com with SMTP id h6-20020ac85846000000b003e3c23d562aso22281251qth.1 for ; Tue, 04 Apr 2023 07:55:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680620127; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qBYfR9y7mc4emCV9kD7O8/LELcLcH0cCLkcuznWVRNE=; b=NwKROZzLok6ULta6KJTm/dJ3xrs9FC1OYhTmk+tUrlZRDi/bSAbHSgY7I5GPeeq8Bl Odgh39/yhKOxSuwjZWtDDOfNWzi+Wt1RSgsE6hElTdqUDtTi430HMwFKS38zhXl6aeSF TuQAAHAco7l/bPRH6jSHnrCoGbMtEomCYd8C0fCBt2lsM3j7PnlexuZwigmoOSBas34h 6jq57aM0CQ8mxOurAMIAJfsOaaCyk4OMjg1bKCU0ltbm1ZkUJjig3SFNYUgqZwcEVh5z G/761xdL6mOtO+i/GsXyn2WCHxhKUhhqSVNxqC5bee/LH8COsLTuCKbzJONBWlagp4cP zgTQ== X-Gm-Message-State: AAQBX9fqc4S3piv2UhlNArBvuSF0CL3C4hBJaaAnAnHtR2jARX2ETq31 ZHxQzZcRu/J1V53/Ersjq1FxXiv6GuW5j1WVUzIeHd38mZ9HIV+1RponoSfdTotSuiKzDZCzYGX jJGiTojNHCmA36FAz54C/ X-Received: by 2002:a05:622a:199c:b0:3e4:3f79:9d7b with SMTP id u28-20020a05622a199c00b003e43f799d7bmr3716061qtc.55.1680620127346; Tue, 04 Apr 2023 07:55:27 -0700 (PDT) X-Received: by 2002:a05:622a:199c:b0:3e4:3f79:9d7b with SMTP id u28-20020a05622a199c00b003e43f799d7bmr3716007qtc.55.1680620126943; Tue, 04 Apr 2023 07:55:26 -0700 (PDT) Received: from aalbersh.remote.csb ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id j4-20020ac86644000000b003e6387431dcsm3296539qtp.7.2023.04.04.07.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 07:55:26 -0700 (PDT) From: Andrey Albershteyn To: djwong@kernel.org, dchinner@redhat.com, ebiggers@kernel.org, hch@infradead.org, linux-xfs@vger.kernel.org, fsverity@lists.linux.dev Cc: rpeterso@redhat.com, agruenba@redhat.com, xiang@kernel.org, chao@kernel.org, damien.lemoal@opensource.wdc.com, jth@kernel.org, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, Andrey Albershteyn Subject: [PATCH v2 14/23] xfs: add attribute type for fs-verity Date: Tue, 4 Apr 2023 16:53:10 +0200 Message-Id: <20230404145319.2057051-15-aalbersh@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230404145319.2057051-1-aalbersh@redhat.com> References: <20230404145319.2057051-1-aalbersh@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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-ext4@vger.kernel.org The Merkle tree blocks and descriptor are stored in the extended attributes of the inode. Add new attribute type for fs-verity metadata. Add XFS_ATTR_INTERNAL_MASK to skip parent pointer and fs-verity attributes as those are only for internal use. While we're at it add a few comments in relevant places that internally visible attributes are not suppose to be handled via interface defined in xfs_xattr.c. Signed-off-by: Andrey Albershteyn --- fs/xfs/libxfs/xfs_da_format.h | 10 +++++++++- fs/xfs/libxfs/xfs_log_format.h | 1 + fs/xfs/xfs_ioctl.c | 5 +++++ fs/xfs/xfs_trace.h | 1 + fs/xfs/xfs_xattr.c | 9 +++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h index 75b13807145d..2b5967befc2e 100644 --- a/fs/xfs/libxfs/xfs_da_format.h +++ b/fs/xfs/libxfs/xfs_da_format.h @@ -689,14 +689,22 @@ struct xfs_attr3_leafblock { #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */ #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */ #define XFS_ATTR_PARENT_BIT 3 /* parent pointer attrs */ +#define XFS_ATTR_VERITY_BIT 4 /* verity merkle tree and descriptor */ #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */ #define XFS_ATTR_LOCAL (1u << XFS_ATTR_LOCAL_BIT) #define XFS_ATTR_ROOT (1u << XFS_ATTR_ROOT_BIT) #define XFS_ATTR_SECURE (1u << XFS_ATTR_SECURE_BIT) #define XFS_ATTR_PARENT (1u << XFS_ATTR_PARENT_BIT) +#define XFS_ATTR_VERITY (1u << XFS_ATTR_VERITY_BIT) #define XFS_ATTR_INCOMPLETE (1u << XFS_ATTR_INCOMPLETE_BIT) #define XFS_ATTR_NSP_ONDISK_MASK \ - (XFS_ATTR_ROOT | XFS_ATTR_SECURE | XFS_ATTR_PARENT) + (XFS_ATTR_ROOT | XFS_ATTR_SECURE | XFS_ATTR_PARENT | \ + XFS_ATTR_VERITY) + +/* + * Internal attributes not exposed to the user + */ +#define XFS_ATTR_INTERNAL_MASK (XFS_ATTR_PARENT | XFS_ATTR_VERITY) /* * Alignment for namelist and valuelist entries (since they are mixed diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index 727b5a858028..678eacb7925c 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -968,6 +968,7 @@ struct xfs_icreate_log { #define XFS_ATTRI_FILTER_MASK (XFS_ATTR_ROOT | \ XFS_ATTR_SECURE | \ XFS_ATTR_PARENT | \ + XFS_ATTR_VERITY | \ XFS_ATTR_INCOMPLETE) /* diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 55bb01173cde..3d6d680b6cf3 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c @@ -351,6 +351,11 @@ static unsigned int xfs_attr_filter( u32 ioc_flags) { + /* + * Only externally visible attributes should be specified here. + * Internally used attributes (such as parent pointers or fs-verity) + * should not be exposed to userspace. + */ if (ioc_flags & XFS_IOC_ATTR_ROOT) return XFS_ATTR_ROOT; if (ioc_flags & XFS_IOC_ATTR_SECURE) diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 9c0006c55fec..e842b9d145cb 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -79,6 +79,7 @@ struct xfs_perag; #define XFS_ATTR_FILTER_FLAGS \ { XFS_ATTR_ROOT, "ROOT" }, \ { XFS_ATTR_SECURE, "SECURE" }, \ + { XFS_ATTR_VERITY, "VERITY" }, \ { XFS_ATTR_INCOMPLETE, "INCOMPLETE" } DECLARE_EVENT_CLASS(xfs_attr_list_class, diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 7b9a0ed1b11f..5a71797fbd44 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -20,6 +20,12 @@ #include +/* + * This file defines interface to work with externally visible extended + * attributes, such as those in system or security namespaces. This interface + * should not be used for internally used attributes (consider xfs_attr.c). + */ + /* * Get permission to use log-assisted atomic exchange of file extents. * @@ -234,6 +240,9 @@ xfs_xattr_put_listent( ASSERT(context->count >= 0); + if (flags & XFS_ATTR_INTERNAL_MASK) + return; + if (flags & XFS_ATTR_ROOT) { #ifdef CONFIG_XFS_POSIX_ACL if (namelen == SGI_ACL_FILE_SIZE && -- 2.38.4