Skip to contentSkip to conversation

dump.f2fs: support to dump fsverity xattr info in print_xattr_entry()

PATCH In review Chao Yu 2 participants 2 messages Jul 18, 2023 – Jul 21, 2023

lore
Share & tools
lore

Chao Yu

author
#0 lore raw

PATCH 1/1 dump.f2fs: support to dump fsverity xattr info in print_xattr_entry()

This patch adds to support dumping fsverity xattr info in print_xattr_entry().

---
 fsck/mount.c | 13 +++++++++++++
 fsck/xattr.h | 11 +++++++++++
 2 files changed, 24 insertions(+)
fsck/mount.c +13 -0
index dbb516b..2691b2f 100644
@@ -199,6 +199,7 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
 	char *enc_name = F2FS_XATTR_NAME_ENCRYPTION_CONTEXT;
 	u32 enc_name_len = strlen(enc_name);
 	const union fscrypt_context *ctx;
+	const struct fsverity_descriptor_location *dloc;
 	int i;
 
 	MSG(0, "\nxattr: e_name_index:%d e_name:", ent->e_name_index);
@@ -250,6 +251,18 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
 			return;
 		}
 		break;
+	case F2FS_XATTR_INDEX_VERITY:
+		dloc = (const struct fsverity_descriptor_location *)value;
+		if (ent->e_name_len != strlen(F2FS_XATTR_NAME_VERITY) ||
+			memcmp(ent->e_name, F2FS_XATTR_NAME_VERITY,
+						ent->e_name_len))
+			break;
+		if (size != sizeof(*dloc))
+			break;
+		MSG(0, "version: %u\n", le32_to_cpu(dloc->version));
+		MSG(0, "size: %u\n", le32_to_cpu(dloc->size));
+		MSG(0, "pos: %lu\n", le64_to_cpu(dloc->pos));
+		return;
 	}
 	for (i = 0; i < size; i++)
 		MSG(0, "%02X", value[i]);
fsck/xattr.h +11 -0
index cddafa7..bf1dd7e 100644
@@ -90,6 +90,14 @@ static inline int fscrypt_context_size(const union fscrypt_context *ctx)
 	return 0;
 }
 
+struct fsverity_descriptor_location {
+	__le32 version;
+	__le32 size;
+	__le64 pos;
+};
+
+static_assert(sizeof(struct fsverity_descriptor_location) == 16, "");
+
 #define F2FS_ACL_VERSION	0x0001
 
 struct f2fs_acl_entry {
@@ -150,6 +158,9 @@ static inline int f2fs_acl_count(int size)
 #define F2FS_XATTR_INDEX_LUSTRE			5
 #define F2FS_XATTR_INDEX_SECURITY		6
 #define F2FS_XATTR_INDEX_ENCRYPTION		9
+#define F2FS_XATTR_INDEX_VERITY			11
+
+#define F2FS_XATTR_NAME_VERITY			"v"
 
 #define IS_XATTR_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
 
Signature · 8 lines
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw
Quoted 25 lines · Chao Yu

This patch adds to support dumping fsverity xattr info in print_xattr_entry().

---
 fsck/mount.c | 13 +++++++++++++
 fsck/xattr.h | 11 +++++++++++
 2 files changed, 24 insertions(+)
fsck/mount.c +2 -0
index dbb516b..2691b2f 100644
@@ -199,6 +199,7 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
 	char *enc_name = F2FS_XATTR_NAME_ENCRYPTION_CONTEXT;
 	u32 enc_name_len = strlen(enc_name);
 	const union fscrypt_context *ctx;
+	const struct fsverity_descriptor_location *dloc;
 	int i;
 
 	MSG(0, "\nxattr: e_name_index:%d e_name:", ent->e_name_index);
@@ -250,6 +251,18 @@ static void print_xattr_entry(const struct f2fs_xattr_entry *ent)
 			return;
 		}
 		break;
+	case F2FS_XATTR_INDEX_VERITY:

fsck/mount.c static void print_xattr_entry(const struct f2fs_xattr_entry *ent) · line 264

Quoted 10 lines
fsck/mount.c +10 -0
+		dloc = (const struct fsverity_descriptor_location *)value;
+		if (ent->e_name_len != strlen(F2FS_XATTR_NAME_VERITY) ||
+			memcmp(ent->e_name, F2FS_XATTR_NAME_VERITY,
+						ent->e_name_len))
+			break;
+		if (size != sizeof(*dloc))
+			break;
+		MSG(0, "version: %u\n", le32_to_cpu(dloc->version));
+		MSG(0, "size: %u\n", le32_to_cpu(dloc->size));
+		MSG(0, "pos: %lu\n", le64_to_cpu(dloc->pos));

Fixed build error with

		MSG(0, "pos: %"PRIu64"\n", le64_to_cpu(dloc->pos));
Quoted 35 lines
fsck/mount.c +1 -0
+		return;
 	}
 	for (i = 0; i < size; i++)
 		MSG(0, "%02X", value[i]);
fsck/xattr.h +11 -0
index cddafa7..bf1dd7e 100644
@@ -90,6 +90,14 @@ static inline int fscrypt_context_size(const union fscrypt_context *ctx)
 	return 0;
 }
 
+struct fsverity_descriptor_location {
+	__le32 version;
+	__le32 size;
+	__le64 pos;
+};
+
+static_assert(sizeof(struct fsverity_descriptor_location) == 16, "");
+
 #define F2FS_ACL_VERSION	0x0001
 
 struct f2fs_acl_entry {
@@ -150,6 +158,9 @@ static inline int f2fs_acl_count(int size)
 #define F2FS_XATTR_INDEX_LUSTRE			5
 #define F2FS_XATTR_INDEX_SECURITY		6
 #define F2FS_XATTR_INDEX_ENCRYPTION		9
+#define F2FS_XATTR_INDEX_VERITY			11
+
+#define F2FS_XATTR_NAME_VERITY			"v"
 
 #define IS_XATTR_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
 
Signature · 1 line
2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel