From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
osandov@osandov.com, kernel-team@fb.com
Cc: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: [PATCH RFC v2 09/16] btrfs: translate btrfs encryption flags and encrypted inode flag.
Date: Sat, 23 Jul 2022 20:53:54 -0400 [thread overview]
Message-ID: <3f8eaa2ac5226dba403197398ebbd5208ccd9cc0.1658623319.git.sweettea-kernel@dorminy.me> (raw)
In-Reply-To: <cover.1658623319.git.sweettea-kernel@dorminy.me>
From: Omar Sandoval <osandov@osandov.com>
In btrfs, a file can be encrypted either if its directory is encrypted
or its root subvolume is encrypted, so translate both to the standard
flags.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
fs/btrfs/ioctl.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8f5b65c43c8d..708e514aca25 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -7,6 +7,7 @@
#include <linux/bio.h>
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/fscrypt.h>
#include <linux/fsnotify.h>
#include <linux/pagemap.h>
#include <linux/highmem.h>
@@ -147,6 +148,10 @@ static unsigned int btrfs_inode_flags_to_fsflags(struct btrfs_inode *binode)
iflags |= FS_NOCOW_FL;
if (ro_flags & BTRFS_INODE_RO_VERITY)
iflags |= FS_VERITY_FL;
+ if ((binode->flags & BTRFS_INODE_FSCRYPT_CONTEXT) ||
+ (btrfs_root_flags(&binode->root->root_item) &
+ BTRFS_ROOT_SUBVOL_FSCRYPT))
+ iflags |= FS_ENCRYPT_FL;
if (flags & BTRFS_INODE_NOCOMPRESS)
iflags |= FS_NOCOMP_FL;
@@ -176,10 +181,14 @@ void btrfs_sync_inode_flags_to_i_flags(struct inode *inode)
new_fl |= S_DIRSYNC;
if (binode->ro_flags & BTRFS_INODE_RO_VERITY)
new_fl |= S_VERITY;
+ if ((binode->flags & BTRFS_INODE_FSCRYPT_CONTEXT) ||
+ (btrfs_root_flags(&binode->root->root_item) &
+ BTRFS_ROOT_SUBVOL_FSCRYPT))
+ new_fl |= S_ENCRYPTED;
set_mask_bits(&inode->i_flags,
S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC |
- S_VERITY, new_fl);
+ S_VERITY | S_ENCRYPTED, new_fl);
}
/*
@@ -192,7 +201,7 @@ static int check_fsflags(unsigned int old_flags, unsigned int flags)
FS_NOATIME_FL | FS_NODUMP_FL | \
FS_SYNC_FL | FS_DIRSYNC_FL | \
FS_NOCOMP_FL | FS_COMPR_FL |
- FS_NOCOW_FL))
+ FS_NOCOW_FL | FS_ENCRYPT_FL))
return -EOPNOTSUPP;
/* COMPR and NOCOMP on new/old are valid */
--
2.35.1
next prev parent reply other threads:[~2022-07-24 0:55 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-24 0:53 [PATCH RFC v2 00/16] btrfs: add fscrypt integration Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 01/16] btrfs: store directorys' encryption state Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 02/16] btrfs: use fscrypt_name's instead of name/len everywhere Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 03/16] btrfs: setup fscrypt_names from dentrys using helper Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 04/16] btrfs: factor a fscrypt_name matching method Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 05/16] btrfs: disable various operations on encrypted inodes Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 06/16] btrfs: add fscrypt operation table to superblock Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 07/16] btrfs: start using fscrypt hooks Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 08/16] btrfs: add a subvolume flag for whole-volume encryption Sweet Tea Dorminy
2022-07-24 0:53 ` Sweet Tea Dorminy [this message]
2022-07-24 0:53 ` [PATCH RFC v2 10/16] btrfs: add iv generation function for fscrypt Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 11/16] btrfs: store an IV per encrypted normal file extent Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 12/16] btrfs: Add new FEATURE_INCOMPAT_FSCRYPT feature flag Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 13/16] btrfs: reuse encrypted filename hash when possible Sweet Tea Dorminy
2022-07-24 0:53 ` [PATCH RFC v2 14/16] btrfs: adapt directory read and lookup to potentially encrypted filenames Sweet Tea Dorminy
2022-07-24 0:54 ` [PATCH RFC v2 15/16] btrfs: encrypt normal file extent data if appropriate Sweet Tea Dorminy
2022-07-24 0:54 ` [PATCH RFC v2 16/16] btrfs: implement fscrypt ioctls Sweet Tea Dorminy
2022-10-13 12:14 ` [PATCH RFC v2 00/16] btrfs: add fscrypt integration Muhammad Usama Anjum
2022-10-14 10:54 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3f8eaa2ac5226dba403197398ebbd5208ccd9cc0.1658623319.git.sweettea-kernel@dorminy.me \
--to=sweettea-kernel@dorminy.me \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=osandov@osandov.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).