]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: Check for supported fscrypt policy
authorChristopher Hoffman <choffman@redhat.com>
Thu, 21 Aug 2025 19:23:44 +0000 (19:23 +0000)
committerVenky Shankar <vshankar@redhat.com>
Mon, 22 Sep 2025 14:53:17 +0000 (14:53 +0000)
When setting a policy on a directory, check to make sure
policy is supported.

Signed-off-by: Christopher Hoffman <choffman@redhat.com>
(cherry picked from commit e3c5d4de0d8f528092e8ed33905e29d460ecb2c6)
Resolves: rhbz#2362686

src/client/Client.cc
src/client/FSCrypt.h

index 99ece2cb4f412e0e433c973ce9df23a970e4063d..7d6e6e4781bdc5bc4944ab0f1f3ba45f0783259b 100644 (file)
@@ -18192,6 +18192,11 @@ int Client::ll_set_fscrypt_policy_v2(Inode *in, const struct fscrypt_policy_v2&
   }
 
   FSCryptContext fsc(cct);
+
+  if (!fsc.is_supported_policy(policy)) {
+    return -EINVAL;
+  }
+
   fsc.init(policy);
   fsc.generate_new_nonce();
 
index 97d3f1029522e2d661f7d7c4485607e630ef2a72..58f1070417337797b48830780cbc543f2b8fb4dd 100644 (file)
@@ -125,6 +125,19 @@ public:
 
   virtual ~FSCryptPolicy() {}
 
+  bool is_supported_policy(fscrypt_policy_v2 policy) {
+    if (policy.version != 2) {
+      return false;
+    }
+
+    if (policy.contents_encryption_mode != FSCRYPT_MODE_AES_256_XTS ||
+       policy.filenames_encryption_mode != FSCRYPT_MODE_AES_256_CTS) {
+      return false;
+    }
+
+    return true;
+  }
+
   void init(const struct fscrypt_policy_v2& policy) {
     version = policy.version;
     contents_encryption_mode = policy.contents_encryption_mode;