From patchwork Thu Jun 29 19:57:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297267 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 500ECEB64D9 for ; Thu, 29 Jun 2023 19:58:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbjF2T6e (ORCPT ); Thu, 29 Jun 2023 15:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbjF2T6Y (ORCPT ); Thu, 29 Jun 2023 15:58:24 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B802A30F0 for ; Thu, 29 Jun 2023 12:58:22 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 1CAF280B01; Thu, 29 Jun 2023 15:58:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068702; bh=eiPkmhJ/0kTTt/2ieHVJm4oDVxiTiwMRmaWQdcSS1XI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMnIQQgFOppNsSNeyBSDWPkpjNrJZPtG12P3RojksdndGIU2EMnc4vWWWMnxMvy7z k7cztDA0gpsvbF5oJ9JD5AM19f1bI8S8M9HV4Ot5/F/c0amssAb/Fan1/mBPLLx2aZ sUDHaYsEduR/c1h8tbA5jZzNiADn2Se/+SNwtGDi3gcB2Zx2a5hxfus3+1j9q2Xw+f PQSoHS5C/1/GGvs5ybf15OhRKVLWA3g31mugV4YSzlo4hRg1IMFfCVu9cyQC2jjxRd +z1nXf7OHCuKd1zGQxsZupEgTB0MCh6aDeQa218LyuQxhzCVbRcPpyy8Zt8lmsAlc7 RhO7CK1MzGDIw== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 1/8] btrfs-progs: add new FEATURE_INCOMPAT_ENCRYPT flag Date: Thu, 29 Jun 2023 15:57:59 -0400 Message-Id: <812e244a1a54bfa9046d36867bf913c9e99e99a3.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Matches kernel change by the same name. Signed-off-by: Sweet Tea Dorminy --- kernel-shared/ctree.h | 3 ++- kernel-shared/uapi/btrfs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 59533879..6c9ff866 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -103,7 +103,8 @@ static inline u32 __BTRFS_LEAF_DATA_SIZE(u32 nodesize) BTRFS_FEATURE_INCOMPAT_RAID1C34 | \ BTRFS_FEATURE_INCOMPAT_METADATA_UUID | \ BTRFS_FEATURE_INCOMPAT_ZONED | \ - BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2) + BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 | \ + BTRFS_FEATURE_INCOMPAT_ENCRYPT) #else #define BTRFS_FEATURE_INCOMPAT_SUPP \ (BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF | \ diff --git a/kernel-shared/uapi/btrfs.h b/kernel-shared/uapi/btrfs.h index 85b04f89..e347cceb 100644 --- a/kernel-shared/uapi/btrfs.h +++ b/kernel-shared/uapi/btrfs.h @@ -356,6 +356,7 @@ _static_assert(sizeof(struct btrfs_ioctl_fs_info_args) == 1024); #define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11) #define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12) #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13) +#define BTRFS_FEATURE_INCOMPAT_ENCRYPT (1ULL << 14) struct btrfs_ioctl_feature_flags { __u64 compat_flags; From patchwork Thu Jun 29 19:58:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297270 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 09BFCC001DE for ; Thu, 29 Jun 2023 19:58:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbjF2T6j (ORCPT ); Thu, 29 Jun 2023 15:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231981AbjF2T60 (ORCPT ); Thu, 29 Jun 2023 15:58:26 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2EA02D66 for ; Thu, 29 Jun 2023 12:58:25 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 148A580AEE; Thu, 29 Jun 2023 15:58:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068705; bh=UDARkU4OJmJgupwWCeVV25TAENWyUquPRTK6aoAJWS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/uh/r+PNOWYoLt+4klLA4mhf+3do6bwrt2i2Z8wFaH4CBGj6fho3QkcZnpQGk4sC oLW4+4pnGFAa6DVf+Se/9fg7jNVc9KaO6xZR8JN6kOTrMTQ97Q1IlmYDFtQkiTsK9s EWDkF0H71/CTA0JPzms+fCnpws67aOYTnL/j8iACj1QXO0jO2ps9RQnH+ci22OF7Aa ZxgPBxm+yZm5De9yULFXzHJqSv3WzLugSqUGErmT5BSBcQ0MuBMe6KiOc+gdKH4uti 7Eb0KsN3bVoPtvYpmwyMj/LLgpe2oZuwtTpiI6vnvQ+cATUw9um9a1FkQkMWr7SPwk FHiIVsFAGdqug== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 2/8] btrfs-progs: start tracking extent encryption context info Date: Thu, 29 Jun 2023 15:58:01 -0400 Message-Id: <46adace2c8d4317962ecdcc04b92e1bda3a5a4c8.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This recapitulates the kernel change named 'btrfs: start tracking extent encryption context info". Signed-off-by: Sweet Tea Dorminy --- kernel-shared/accessors.h | 31 ++++++++++++++++++++++++++++++ kernel-shared/fscrypt.h | 30 +++++++++++++++++++++++++++++ kernel-shared/tree-checker.c | 37 ++++++++++++++++++++++++++++-------- 3 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 kernel-shared/fscrypt.h diff --git a/kernel-shared/accessors.h b/kernel-shared/accessors.h index 539c20d0..62e9282d 100644 --- a/kernel-shared/accessors.h +++ b/kernel-shared/accessors.h @@ -3,6 +3,8 @@ #ifndef BTRFS_ACCESSORS_H #define BTRFS_ACCESSORS_H +#include "fscrypt.h" + #include "kerncompat.h" #ifndef _static_assert @@ -949,6 +951,16 @@ BTRFS_SETGET_STACK_FUNCS(stack_file_extent_disk_num_bytes, struct btrfs_file_extent_item, disk_num_bytes, 64); BTRFS_SETGET_STACK_FUNCS(stack_file_extent_compression, struct btrfs_file_extent_item, compression, 8); +BTRFS_SETGET_STACK_FUNCS(stack_file_extent_encryption, + struct btrfs_file_extent_item, encryption, 8); +static inline u8 btrfs_stack_file_extent_encryption_ctxsize( + struct btrfs_file_extent_item *e) +{ + u8 ctxsize; + + btrfs_unpack_encryption(e->encryption, NULL, &ctxsize); + return ctxsize; +} BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type, 8); BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item, @@ -970,6 +982,25 @@ BTRFS_SETGET_FUNCS(file_extent_encryption, struct btrfs_file_extent_item, BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_item, other_encoding, 16); +static inline u8 +btrfs_file_extent_encryption_ctxsize(const struct extent_buffer *eb, + struct btrfs_file_extent_item *e) +{ + u8 ctxsize; + + btrfs_unpack_encryption(btrfs_file_extent_encryption(eb, e), + NULL, &ctxsize); + return ctxsize; +} + +static inline u8 +btrfs_file_extent_ctxsize_from_item(const struct extent_buffer *leaf, + int nr) +{ + return (btrfs_item_size(leaf, nr) - + sizeof(struct btrfs_file_extent_item)); +} + /* btrfs_qgroup_status_item */ BTRFS_SETGET_FUNCS(qgroup_status_generation, struct btrfs_qgroup_status_item, generation, 64); diff --git a/kernel-shared/fscrypt.h b/kernel-shared/fscrypt.h new file mode 100644 index 00000000..de32593e --- /dev/null +++ b/kernel-shared/fscrypt.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef BTRFS_FSCRYPT_H +#define BTRFS_FSCRYPT_H + +#define BTRFS_ENCRYPTION_POLICY_BITS 2 +#define BTRFS_ENCRYPTION_CTXSIZE_BITS 6 + +#define BTRFS_ENCRYPTION_POLICY_MASK ((1 << BTRFS_ENCRYPTION_POLICY_BITS) - 1) +#define BTRFS_ENCRYPTION_CTXSIZE_MASK \ + (((1 << BTRFS_ENCRYPTION_CTXSIZE_BITS) - 1) << \ + BTRFS_ENCRYPTION_POLICY_BITS) + +static inline void btrfs_unpack_encryption(u8 encryption, + u8 *policy, + u8 *ctxsize) +{ + if (policy) + *policy = encryption & BTRFS_ENCRYPTION_POLICY_MASK; + if (ctxsize) + *ctxsize = ((encryption & BTRFS_ENCRYPTION_CTXSIZE_MASK) >> + BTRFS_ENCRYPTION_POLICY_BITS); +} + +static inline u8 btrfs_pack_encryption(u8 policy, u8 ctxsize) +{ + return policy | (ctxsize << BTRFS_ENCRYPTION_POLICY_BITS); +} + +#endif diff --git a/kernel-shared/tree-checker.c b/kernel-shared/tree-checker.c index 10797589..0412e97d 100644 --- a/kernel-shared/tree-checker.c +++ b/kernel-shared/tree-checker.c @@ -229,6 +229,7 @@ static int check_extent_data_item(struct extent_buffer *leaf, u32 sectorsize = fs_info->sectorsize; u32 item_size = btrfs_item_size(leaf, slot); u64 extent_end; + u8 policy; if (unlikely(!IS_ALIGNED(key->offset, sectorsize))) { file_extent_err(leaf, slot, @@ -280,10 +281,12 @@ static int check_extent_data_item(struct extent_buffer *leaf, BTRFS_NR_COMPRESS_TYPES - 1); return -EUCLEAN; } - if (unlikely(btrfs_file_extent_encryption(leaf, fi))) { + btrfs_unpack_encryption(btrfs_file_extent_encryption(leaf, fi), + &policy, NULL); + if (unlikely(policy >= BTRFS_NR_ENCRYPTION_TYPES)) { file_extent_err(leaf, slot, - "invalid encryption for file extent, have %u expect 0", - btrfs_file_extent_encryption(leaf, fi)); + "invalid encryption for file extent, have %u expect range [0, %u]", + policy, BTRFS_NR_ENCRYPTION_TYPES - 1); return -EUCLEAN; } if (btrfs_file_extent_type(leaf, fi) == BTRFS_FILE_EXTENT_INLINE) { @@ -312,12 +315,30 @@ static int check_extent_data_item(struct extent_buffer *leaf, return 0; } - /* Regular or preallocated extent has fixed item size */ - if (unlikely(item_size != sizeof(*fi))) { - file_extent_err(leaf, slot, + if (policy == BTRFS_ENCRYPTION_FSCRYPT) { + u8 ctxsize = btrfs_file_extent_encryption_ctxsize(leaf, fi); + + if (unlikely(item_size != sizeof(*fi) + ctxsize)) { + file_extent_err(leaf, slot, + "invalid item size for encrypted file extent, have %u expect = %zu + context of size %u", + item_size, sizeof(*fi), ctxsize); + return -EUCLEAN; + } + /* Only regular extents should be encrypted. */ + if (btrfs_file_extent_type(leaf, fi) != BTRFS_FILE_EXTENT_REG) { + file_extent_err(leaf, slot, + "invalid type for encrypted file extent, have %u expect %u", + btrfs_file_extent_type(leaf, fi), + BTRFS_FILE_EXTENT_REG); + return -EUCLEAN; + } + } else { + if (unlikely(item_size != sizeof(*fi))) { + file_extent_err(leaf, slot, "invalid item size for reg/prealloc file extent, have %u expect %zu", - item_size, sizeof(*fi)); - return -EUCLEAN; + item_size, sizeof(*fi)); + return -EUCLEAN; + } } if (unlikely(CHECK_FE_ALIGNED(leaf, slot, fi, ram_bytes, sectorsize) || CHECK_FE_ALIGNED(leaf, slot, fi, disk_bytenr, sectorsize) || From patchwork Thu Jun 29 19:58:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297272 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 B5609EB64D9 for ; Thu, 29 Jun 2023 19:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231825AbjF2T6l (ORCPT ); Thu, 29 Jun 2023 15:58:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbjF2T63 (ORCPT ); Thu, 29 Jun 2023 15:58:29 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E9882D71 for ; Thu, 29 Jun 2023 12:58:28 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id F0D8980AEE; Thu, 29 Jun 2023 15:58:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068708; bh=kwpFfj+NnrvPQCaEv/DtQ9QsxS3IpDZzfXx1AMJqIiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tK15WSs1vhvcSfWwVriyeLf0mhy8WsjT+Zrdh2T/Ioqnj/XgAM0RvlMbklOtOIs35 8A+QDbPqUaKMIeu/nHFTKuC2aTcFHc+vzcE/tiQcsW2kY06PL9eB9XXD0aNSkt9zXY SEHonhpMc755a2J8OLjL6wLmw8mNoK8e+bxe2PJ+yil4E1maLGuum+f1YgCOp1ukbN z/OOqR0cJsAxbuVZrrTFnTD25+Fua8ieb9yif9IZwOwRwrZuXKLqZ0MXU/c7duDejH ozGGSe/8P4GTFm3Nla4nSKcpR688Ao+VyywRFpx8aBFWwlo1jYqyrYEb5zDnT2Ie4j L1Ujc37VIklbw== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 3/8] btrfs-progs: add inode encryption contexts Date: Thu, 29 Jun 2023 15:58:03 -0400 Message-Id: <639b3158cef2fa35619d4b2b9871d56c88c5f81b.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Recapitulates relevant parts of kernel change 'btrfs: add inode encryption contexts'. Signed-off-by: Sweet Tea Dorminy --- kernel-shared/uapi/btrfs_tree.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel-shared/uapi/btrfs_tree.h b/kernel-shared/uapi/btrfs_tree.h index ad555e70..2df7cfec 100644 --- a/kernel-shared/uapi/btrfs_tree.h +++ b/kernel-shared/uapi/btrfs_tree.h @@ -162,6 +162,8 @@ #define BTRFS_VERITY_DESC_ITEM_KEY 36 #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 +#define BTRFS_FSCRYPT_CTXT_ITEM_KEY 41 + #define BTRFS_ORPHAN_ITEM_KEY 48 /* reserve 2-15 close to the inode for later flexibility */ @@ -400,6 +402,7 @@ static inline __u8 btrfs_dir_flags_to_ftype(__u8 flags) #define BTRFS_INODE_NOATIME (1U << 9) #define BTRFS_INODE_DIRSYNC (1U << 10) #define BTRFS_INODE_COMPRESS (1U << 11) +#define BTRFS_INODE_ENCRYPT (1U << 12) #define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31) @@ -416,6 +419,7 @@ static inline __u8 btrfs_dir_flags_to_ftype(__u8 flags) BTRFS_INODE_NOATIME | \ BTRFS_INODE_DIRSYNC | \ BTRFS_INODE_COMPRESS | \ + BTRFS_INODE_ENCRYPT | \ BTRFS_INODE_ROOT_ITEM_INIT) #define BTRFS_INODE_RO_VERITY (1U << 0) @@ -1016,6 +1020,12 @@ enum { BTRFS_NR_FILE_EXTENT_TYPES = 3, }; +enum { + BTRFS_ENCRYPTION_NONE, + BTRFS_ENCRYPTION_FSCRYPT, + BTRFS_NR_ENCRYPTION_TYPES, +}; + struct btrfs_file_extent_item { /* * transaction id that created this extent From patchwork Thu Jun 29 19:58:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297273 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 2E087EB64DD for ; Thu, 29 Jun 2023 19:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbjF2T6n (ORCPT ); Thu, 29 Jun 2023 15:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbjF2T6c (ORCPT ); Thu, 29 Jun 2023 15:58:32 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C19930D1 for ; Thu, 29 Jun 2023 12:58:30 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 8390980AE0; Thu, 29 Jun 2023 15:58:30 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068710; bh=52Rr41aw2Qb6bdIRB7+n5MrXfQfrmDX6iS0fQCHf6sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KEJufDkxcLCH0Fr0/lcpvQeQ1av9f+4qSPudeeKrnr03V1G8GiuD4o/6Gba5Ips2F wvkQ76ytRkjJNQG8Jmof83n9/H0wCIadFYhbP7IOWLq5NCU77WbLHWPTAbbXPIHSJ5 KdgFbNU4TkDdU/81wssQW81ELZk48H8NB12qf//uAOicVfSRTmWZMr3l6e/S32/Dhc 0hg0+IBFCtpCMyXkZsPz3j5kEjkSf3ot6l0BFGBoAaEXfXlv3KNtIOPYDG+T28CjI3 dDumfR6lwiotzOoO7N5k1L4E5HYEtTOaK537EDrMEbOkAAt5ws80nEshim9HE1OLVr i824hcHfWulsw== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 4/8] btrfs-progs: save and load fscrypt extent contexts Date: Thu, 29 Jun 2023 15:58:05 -0400 Message-Id: <09d097a9b94ebf658f552537c5db66a4c87a4f4d.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Mirrors the relevant part of kernel change 'btrfs: save and load fscrypt extent contexts' to progs. Signed-off-by: Sweet Tea Dorminy --- kernel-shared/uapi/btrfs_tree.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel-shared/uapi/btrfs_tree.h b/kernel-shared/uapi/btrfs_tree.h index 2df7cfec..0e62f46b 100644 --- a/kernel-shared/uapi/btrfs_tree.h +++ b/kernel-shared/uapi/btrfs_tree.h @@ -1075,7 +1075,11 @@ struct btrfs_file_extent_item { * always reflects the size uncompressed and without encoding. */ __le64 num_bytes; - + /* + * fscrypt extent encryption context. Only present if extent is + * encrypted (stored in the encryption field). + */ + __u8 fscrypt_context[0]; } __attribute__ ((__packed__)); struct btrfs_csum_item { From patchwork Thu Jun 29 19:58:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297276 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 4AA9BC001B0 for ; Thu, 29 Jun 2023 19:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbjF2T6p (ORCPT ); Thu, 29 Jun 2023 15:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232081AbjF2T6e (ORCPT ); Thu, 29 Jun 2023 15:58:34 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A52C62D5B for ; Thu, 29 Jun 2023 12:58:33 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 2DE8080AE0; Thu, 29 Jun 2023 15:58:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068713; bh=NgXXFOl6a0/2PDL9/z/npYv+hjP2oswD7MP8NJsvONA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bj1BoHgSdQHAALTTevh7ZAjN1q5U4QRLhePp59YFyOwBtPDhUnznTNqGPVHvj3FLX YCrFvcddOGGKj6tEwAYUn6oc95DHmk+svOfxwRIJ8F7XSPyTBhKceLaCIJ+pUncVQR eM166Nm3XEIMgeMz6sNeDDgkZynfKYBqrkEQ1qQyi0qHiVF/4GvoDYLAFw47YUpKjk 7RdjshECPWMueO4lMvY/rC0PGzj5kY9k6Y8OIifEcWpT07H6V/kLB8aZW79V6GL3sD v/spNL2DUu0fV7vo9MHyB49XTgoNMsmKSWsXvxherS2sHsi2UgALeQFHVJbWHAXC/n PCpovk4Do8crA== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 5/8] btrfs-progs: interpret encrypted file extents. Date: Thu, 29 Jun 2023 15:58:07 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Encrypted file extents now have the 'encryption' field set to a encryption type plus a context length, and have an extent context appended to the item. This necessitates adjusting the struct to have a variable-length fscrypt_context member at the end, and printing contexts if one is provided. Signed-off-by: Sweet Tea Dorminy --- check/main.c | 4 +++- kernel-shared/print-tree.c | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/check/main.c b/check/main.c index 77bb50a0..ce64f762 100644 --- a/check/main.c +++ b/check/main.c @@ -6345,6 +6345,7 @@ static int run_next_block(struct btrfs_root *root, for (i = 0; i < nritems; i++) { struct btrfs_file_extent_item *fi; unsigned long inline_offset; + u8 ctxsize; inline_offset = offsetof(struct btrfs_file_extent_item, disk_bytenr); @@ -6480,8 +6481,9 @@ static int run_next_block(struct btrfs_root *root, continue; /* Prealloc/regular extent must have fixed item size */ + ctxsize = btrfs_file_extent_encryption_ctxsize(buf, fi); if (btrfs_item_size(buf, i) != - sizeof(struct btrfs_file_extent_item)) { + sizeof(struct btrfs_file_extent_item) + ctxsize) { ret = -EUCLEAN; error( "invalid file extent item size, have %u expect %zu", diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 0f7f7b72..688e4c1a 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -356,6 +356,28 @@ static void compress_type_to_str(u8 compress_type, char *ret) } } +static void generate_encryption_string(struct extent_buffer *leaf, + struct btrfs_file_extent_item *fi, + char *ret) +{ + u8 encryption = btrfs_file_extent_encryption(leaf, fi); + u8 policy, ctxsize; + unsigned long offset = (unsigned long) fi; + const struct btrfs_file_extent_item *fi2 = (struct btrfs_file_extent_item *)(leaf->data + offset); + const __u8 *ctx = fi2->fscrypt_context; + + btrfs_unpack_encryption(encryption, &policy, &ctxsize); + ret += sprintf(ret, "(%hhu, %hhu", policy, ctxsize); + + if (ctxsize) { + int i; + ret += sprintf(ret, ": context "); + for (i = 0; i < ctxsize; i++) + ret += sprintf(ret, "%02hhx", ctx[i]); + } + sprintf(ret, ")"); +} + static const char* file_extent_type_to_str(u8 type) { switch (type) { @@ -372,9 +394,11 @@ static void print_file_extent_item(struct extent_buffer *eb, { unsigned char extent_type = btrfs_file_extent_type(eb, fi); char compress_str[16]; + char encrypt_str[16]; compress_type_to_str(btrfs_file_extent_compression(eb, fi), compress_str); + generate_encryption_string(eb, fi, encrypt_str); printf("\t\tgeneration %llu type %hhu (%s)\n", btrfs_file_extent_generation(eb, fi), @@ -407,6 +431,9 @@ static void print_file_extent_item(struct extent_buffer *eb, printf("\t\textent compression %hhu (%s)\n", btrfs_file_extent_compression(eb, fi), compress_str); + printf("\t\textent encryption %hhu (%s)\n", + btrfs_file_extent_encryption(eb, fi), + encrypt_str); } /* Caller should ensure sizeof(*ret) >= 16("DATA|TREE_BLOCK") */ From patchwork Thu Jun 29 19:58:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297275 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 93C7CEB64D9 for ; Thu, 29 Jun 2023 19:58:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232194AbjF2T6o (ORCPT ); Thu, 29 Jun 2023 15:58:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232316AbjF2T6f (ORCPT ); Thu, 29 Jun 2023 15:58:35 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C6382D52 for ; Thu, 29 Jun 2023 12:58:35 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 8C99B80AEE; Thu, 29 Jun 2023 15:58:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068714; bh=hpN54LJR3hQl+NHy4p9FcgUzWadyhKColShXyQbVu7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z63vg20Z8PGh2yaw3F8sQ0OVB7m69l4BuqtX1KnQ9zQNE96jPxi/FNFDxiyYudEH3 K/csov2tc0iwMOgz+EaRa68rArSDtRVIiFk3lk+3KrPBRPPx1r3YjmTR23cYQCtHyb OhNEAmjOY0HSf/egeKixW1TQz7csmTUthxqfM8hozWTmzv4ROYgKGr7WsRSgd5Q2yW WZhUsgCfIKHMYJidzr6A8yZzigBstP0eBhK7QKwgbJez+Ab9UPZzViyLOZUmca0VQe os1NaLUWVeEWZmcclwx4Ecy4Jq7i1Nsc6i3kO2v8Ee7no1iIVU/pihWDs6skQZ2jWz doEHQsOil9omA== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 6/8] btrfs-progs: handle fscrypt context items Date: Thu, 29 Jun 2023 15:58:08 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Encrypted inodes have a new associated item, the fscrypt context, which can be printed as a pure hex string in dump-tree. Signed-off-by: Sweet Tea Dorminy --- kernel-shared/print-tree.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index 688e4c1a..fa32b586 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -99,6 +99,20 @@ static void print_dir_item(struct extent_buffer *eb, u32 size, } } +static void print_fscrypt_context(struct extent_buffer *eb, int slot) +{ + int i; + unsigned long ptr = btrfs_item_ptr_offset(eb, slot); + u32 item_size = btrfs_item_size(eb, slot); + u8 ctx_buf[item_size]; + + read_extent_buffer(eb, ctx_buf, ptr, item_size); + printf("\t\tvalue: "); + for(i = 0; i < item_size; i++) + printf("%02x", ctx_buf[i]); + printf("\n"); +} + static void print_inode_extref_item(struct extent_buffer *eb, u32 size, struct btrfs_inode_extref *extref) { @@ -675,6 +689,7 @@ void print_key_type(FILE *stream, u64 objectid, u8 type) [BTRFS_DIR_LOG_ITEM_KEY] = "DIR_LOG_ITEM", [BTRFS_DIR_LOG_INDEX_KEY] = "DIR_LOG_INDEX", [BTRFS_XATTR_ITEM_KEY] = "XATTR_ITEM", + [BTRFS_FSCRYPT_CTXT_ITEM_KEY] = "FSCRYPT_CTXT_ITEM", [BTRFS_VERITY_DESC_ITEM_KEY] = "VERITY_DESC_ITEM", [BTRFS_VERITY_MERKLE_ITEM_KEY] = "VERITY_MERKLE_ITEM", [BTRFS_ORPHAN_ITEM_KEY] = "ORPHAN_ITEM", @@ -1395,6 +1410,9 @@ void btrfs_print_leaf(struct extent_buffer *eb, unsigned int mode) case BTRFS_XATTR_ITEM_KEY: print_dir_item(eb, item_size, ptr); break; + case BTRFS_FSCRYPT_CTXT_ITEM_KEY: + print_fscrypt_context(eb, i); + break; case BTRFS_DIR_LOG_INDEX_KEY: case BTRFS_DIR_LOG_ITEM_KEY: { struct btrfs_dir_log_item *dlog; From patchwork Thu Jun 29 19:58:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297277 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 8C63AC001B3 for ; Thu, 29 Jun 2023 19:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231407AbjF2T6q (ORCPT ); Thu, 29 Jun 2023 15:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232178AbjF2T6h (ORCPT ); Thu, 29 Jun 2023 15:58:37 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 802D42D60 for ; Thu, 29 Jun 2023 12:58:36 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id E965080AE0; Thu, 29 Jun 2023 15:58:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068716; bh=i64gJVxvY5Ht/txyZeejco2uaF2Z0SxWoUdP4xMQqzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mZ6Pxav+rLQFB0UmDjvCzItJ38iH+p1/wM1H+RgSox8sCvOLFGSqXxBNk8RMj9Dm9 TFSPKhG0n4cqmd/4zpDKRHCiHzBhlJKYH1By2TWEaL7t88kqyswyU+7e0jGRL68bQX cx2r86IDtGKbVs9Xu/G7B3qKyMcA4P6nQMcBNvlVQ3uqdJv5iTauwpUxcDfd+tlyMF QBAm7YOxA5EY9J4JNNdi5XXLk5NGOeQmCaHei3AG7uAF6ZHIccvnFiokbke2CWTVqX f2xBg8GsCtiFfH+++lbFJZyGCYJemB2MmpHS9uT90C4R8wTnAmBbPaHPhV5dCcsvOa Q7KiTBPzPaUzg== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 7/8] btrfs-progs: escape unprintable characters in names Date: Thu, 29 Jun 2023 15:58:09 -0400 Message-Id: <57fd51e1bb53568633b6c92ac12f6dfbce7be404.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org There are several item types which have an associated name: inode refs and dir items. While they could always be unprintable, the advent of encryption makes it much more likely that the names contain characters outside the normal ASCII range. As such, it's useful to print the characters outside normal ASCII in hex format. Signed-off-by: Sweet Tea Dorminy --- kernel-shared/print-tree.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index fa32b586..c02c00d7 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -30,6 +30,19 @@ #include "kernel-shared/file-item.h" #include "common/utils.h" +static void print_name(const char *buf, size_t len) +{ + size_t i; + printf("name: "); + for(i = 0; i < len; i++) { + if (buf[i] >= ' ' && buf[i] <= '~') + printf("%c", buf[i]); + else + printf("\\x%02hhx", buf[i]); + } + printf("\n"); +} + static void print_dir_item_type(struct extent_buffer *eb, struct btrfs_dir_item *di) { @@ -79,7 +92,7 @@ static void print_dir_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)(di + 1), len); - printf("\t\tname: %.*s\n", len, namebuf); + print_name(namebuf, len); } if (data_len) { @@ -137,7 +150,7 @@ static void print_inode_extref_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)extref->name, len); - printf("name: %.*s\n", len, namebuf); + print_name(namebuf, len); } len = sizeof(*extref) + name_len; @@ -167,7 +180,7 @@ static void print_inode_ref_item(struct extent_buffer *eb, u32 size, } else { read_extent_buffer(eb, namebuf, (unsigned long)(ref + 1), len); - printf("name: %.*s\n", len, namebuf); + print_name(namebuf, len); } len = sizeof(*ref) + name_len; ref = (struct btrfs_inode_ref *)((char *)ref + len); From patchwork Thu Jun 29 19:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13297278 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 37B8EEB64D9 for ; Thu, 29 Jun 2023 19:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232081AbjF2T6q (ORCPT ); Thu, 29 Jun 2023 15:58:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232357AbjF2T6i (ORCPT ); Thu, 29 Jun 2023 15:58:38 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02CD42D52 for ; Thu, 29 Jun 2023 12:58:37 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 5103180AEE; Thu, 29 Jun 2023 15:58:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1688068717; bh=Rb+LDYFucyxkKcDOjwpPCnP+fW/g0BFcFV3hATIdsBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BtZH70OQfYfMulJAv6wwy0yAHkoN+mBdWlpVHazeo9S9qI84H6w+0+1RJ4ZnoYwuY QlDSTiMWNVIfWDOPNXfUmf382eXdy6y2NvDiByofGdrTWHA8/6T/DaXbOi4VMwHOsU cWIlv/thruYWffoVs+skKBvHolGvZMMq7D24kVwzJeA5wOx7bp8Sxb+0g7YcxwLtW2 AHE9PcqPGdaboDnPk5ac3a7dUKhGZyJ3AfNR1ziIIbhv8CpX/04Mh4L580HdvykBvE f6Ow8MkLW3Qw/ChRdAKsGavubOQcYVrBnsOabBvcYaxzIZ3xN5rpCXBxrQsBkIsefX wetvr8yJC32yQ== From: Sweet Tea Dorminy To: linux-btrfs@vger.kernel.org, kernel-team@meta.com Cc: Sweet Tea Dorminy Subject: [PATCH 8/8] btrfs-progs: check: update inline extent length checking Date: Thu, 29 Jun 2023 15:58:10 -0400 Message-Id: <6353d885513fbe47a525bb56212cff86eee174ef.1688068420.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org As part of the encryption changes, encrypted inline file extents record their actual data length in ram_bytes, like compressed inline file extents, while the item's length records the actual size. As such, encrypted inline extents must be treated like compressed ones for inode length consistency checking. Signed-off-by: Sweet Tea Dorminy --- check/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/check/main.c b/check/main.c index ce64f762..9a17c121 100644 --- a/check/main.c +++ b/check/main.c @@ -1642,7 +1642,7 @@ static int process_file_extent(struct btrfs_root *root, u64 mask = gfs_info->sectorsize - 1; u32 max_inline_size = min_t(u32, mask, BTRFS_MAX_INLINE_DATA_SIZE(gfs_info)); - u8 compression; + u8 compression, encryption; int extent_type; int ret; @@ -1667,25 +1667,25 @@ static int process_file_extent(struct btrfs_root *root, fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item); extent_type = btrfs_file_extent_type(eb, fi); compression = btrfs_file_extent_compression(eb, fi); + encryption = btrfs_file_extent_encryption(eb, fi); if (extent_type == BTRFS_FILE_EXTENT_INLINE) { - num_bytes = btrfs_file_extent_ram_bytes(eb, fi); - if (num_bytes == 0) + u64 num_decoded_bytes = btrfs_file_extent_ram_bytes(eb, fi); + u64 num_disk_bytes = btrfs_file_extent_inline_item_len(eb, slot); + if (num_decoded_bytes == 0) rec->errors |= I_ERR_BAD_FILE_EXTENT; - if (compression) { - if (btrfs_file_extent_inline_item_len(eb, slot) > - max_inline_size || - num_bytes > gfs_info->sectorsize) + if (compression || encryption) { + if (num_disk_bytes > max_inline_size || + num_decoded_bytes > gfs_info->sectorsize) rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE; } else { - if (num_bytes > max_inline_size) + if (num_decoded_bytes > max_inline_size) rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE; - if (btrfs_file_extent_inline_item_len(eb, slot) != - num_bytes) + if (num_disk_bytes != num_decoded_bytes) rec->errors |= I_ERR_INLINE_RAM_BYTES_WRONG; } - rec->found_size += num_bytes; - num_bytes = (num_bytes + mask) & ~mask; + rec->found_size += num_decoded_bytes; + num_bytes = (num_decoded_bytes + mask) & ~mask; } else if (extent_type == BTRFS_FILE_EXTENT_REG || extent_type == BTRFS_FILE_EXTENT_PREALLOC) { num_bytes = btrfs_file_extent_num_bytes(eb, fi);