Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1785022imi; Sat, 23 Jul 2022 18:06:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCq9czgEry3yrF3N+pNg3sFxHEPGRqDBf8pw2UUWguoyriHd65Wvj1K4Aq3erSvXAguHAn X-Received: by 2002:a05:6402:5192:b0:43a:c589:4507 with SMTP id q18-20020a056402519200b0043ac5894507mr6198097edd.177.1658624804824; Sat, 23 Jul 2022 18:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658624804; cv=none; d=google.com; s=arc-20160816; b=EUkRv72DxVN3E2jNmtANHTsL99byd4bN/C+g5B2Xi2iVra3xdHD1UZQDtM8+OJxVtn sUw2ABb+B3yZVx0wiL5piFVp7yLAbGYAD0EMwiY5bl3gQIlhaIeFhixK+zrpVIc8g3LM puS3MYJciNmF6kcoBuj4Vi/wNBAMF9ACUmlrdPn65NA0LOLkLHW94oWC7Eypa7PjMgY0 a9mnIHGYA/sLRxf5XeqgDuaLhsKDqXvuSxGE9wBji2ejMLnZFxoC55pN30JeP7YZQj2I ZCEqUeqctY/P0VzNnPclWBIH40z24r/6wsbc666pytz7g3wlV2tYa0irENCrqobGGlOB +w4w== 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=b9oSsis/VdwAzyV0+siqQlm/okw+4kR+0IF+e8wrXVs=; b=F1xN+9jSw96H7RvswjAGQeoN+tT2I+Wr0UJAv6ShA9Qxex6llKXhCQuc+v3BG3XRv8 YaVWz+lmiY+djPCeeG9MyibSV/IhtXrGJa5KUBsCVmahHgSDDddsTMH7tIyTHJLYnfD3 Jqf7iGNO7vH8HWuD0c9chOXe1Z9XuOma1N6Xi7E9a4A7OTABuZx00g+Q+dJ7ByFYqvtf HMRiDjqyDw/w3zd7wN/r1TGodB28uuGmYMu+w0T5Zw3rkhNVv2jdwBIgdfgvjWUfXfRQ g8fa1CHcrV9fHE2xgfkOILNoYokVWQVT9HNCA3buhA+XYOJJEws3ddL4ArkCaWYp4+DM B3Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=jWemjfEf; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd34-20020a17090796a200b006fed9affed0si11960426ejc.528.2022.07.23.18.06.19; Sat, 23 Jul 2022 18:06:44 -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=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=jWemjfEf; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239550AbiGXAzJ (ORCPT + 99 others); Sat, 23 Jul 2022 20:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239341AbiGXAyq (ORCPT ); Sat, 23 Jul 2022 20:54:46 -0400 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C184517583; Sat, 23 Jul 2022 17:54:45 -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 19CBC807A4; Sat, 23 Jul 2022 20:54:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1658624085; bh=TAg5/4aHXU1bFAJanLoEe80cY8bgO/5Yu5sEPkM7Jno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWemjfEfq8jOBAcylvbkDmQ2OAhLtO6W4TJskVpS7u4NqIsRPpQGn7YUTAz4jVokM 9kTJG1ACiKra2pMoeLt0FYj9vA7l/fBF+4NrbGalTO4jwyRXKEJSH3qAJzOnJgGD/+ yXTRGYUEH4qnvt/bSg29sgCY5ha2Rv1JC3wjx95NQ/Xv3FvnQm0dFnu0EgnouB/H32 JbGni79XQUiawrak35iPm7SDSR+ptCKJTy7Xe/4m2rGgEjYi6kbAGkBcdAhVjHTHow ywU/ZEwoZsXl09y/qaR6Y0jcB3lWXiSc14qUAHktuytNLTg83r6nMakdX5+uHJy3WE dwNEeJOyTzNBA== From: Sweet Tea Dorminy To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, osandov@osandov.com, kernel-team@fb.com Cc: Sweet Tea Dorminy Subject: [PATCH RFC v2 10/16] btrfs: add iv generation function for fscrypt Date: Sat, 23 Jul 2022 20:53:55 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_PASS,SPF_PASS autolearn=no 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 As btrfs cannot use the standard inode or logical block based encryption for data block encryption, it must provide a IV generation function and users must use the IV_FROM_FS policy. For filenames, we can just use the nonce that fscrypt stores per-inode, since these encrypted datum are not shared between inodes; later on, we will store an IV per file extent, and return it in this function for data encryption. Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/fscrypt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/btrfs/fscrypt.c b/fs/btrfs/fscrypt.c index 0e92acdac6d7..a11bf78c2a33 100644 --- a/fs/btrfs/fscrypt.c +++ b/fs/btrfs/fscrypt.c @@ -187,9 +187,21 @@ static bool btrfs_fscrypt_empty_dir(struct inode *inode) return true; } +static void btrfs_fscrypt_get_iv(u8 *iv, int ivsize, struct inode *inode, + u64 lblk_num) +{ + /* + * For encryption that doesn't involve extent data, juse use the + * nonce already loaded into the iv buffer. + */ + return; +} + const struct fscrypt_operations btrfs_fscrypt_ops = { + .flags = FS_CFLG_ALLOW_PARTIAL, .key_prefix = "btrfs:", .get_context = btrfs_fscrypt_get_context, .set_context = btrfs_fscrypt_set_context, .empty_dir = btrfs_fscrypt_empty_dir, + .get_fs_defined_iv = btrfs_fscrypt_get_iv, }; -- 2.35.1