From patchwork Thu Aug 25 13:31:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 12954700 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 5703FC04AA5 for ; Thu, 25 Aug 2022 13:31:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242697AbiHYNbl (ORCPT ); Thu, 25 Aug 2022 09:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237455AbiHYNbi (ORCPT ); Thu, 25 Aug 2022 09:31:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888A0AE86A for ; Thu, 25 Aug 2022 06:31:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4A40EB829AB for ; Thu, 25 Aug 2022 13:31:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DD09C433D7; Thu, 25 Aug 2022 13:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661434295; bh=b6q/dgHZqMFAdJscDxeo6FAPg7tPcikrLJzB0zEnC9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qV0jIuovUwadHnDpsJjqtu4cTCFVHxvenm+x+Kqbrlb4RplZboLCncV8W7cpFBwG5 fnPJcVFzlvdryHokPlair7JRm7RLpF9t/TWizndDvIRHdaYOGy8yKEYcu9T4Fp7Gxx 7iFa3FiiGJAQJ3j4rrN1N0QnNCVu4/iwWc//3n72pYwUPOhRfcXyjfBTov4DKHtjgy iB1PqcSsIkKLrc3bk0UEvYf7CpSeOHcli3dIAqty8JUhT47e+AI9wsMpzcdkCSQlLM 9PaV+YH6NsG0Vjn+zp9Gsm1/7ovFeWkiNDd4Gpp/8QmhyTiqsjt1d8dAD2x1DFWeHY s8A1iR+GFnLwg== From: Jeff Layton To: xiubli@redhat.com, idryomov@gmail.com Cc: lhenriques@suse.de, ceph-devel@vger.kernel.org Subject: [PATCH v15 01/29] ceph: don't allow changing layout on encrypted files/directories Date: Thu, 25 Aug 2022 09:31:04 -0400 Message-Id: <20220825133132.153657-2-jlayton@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220825133132.153657-1-jlayton@kernel.org> References: <20220825133132.153657-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Luís Henriques Encryption is currently only supported on files/directories with layouts where stripe_count=1. Forbid changing layouts when encryption is involved. Signed-off-by: Luis Henriques Reviewed-by: Xiubo Li Signed-off-by: Jeff Layton --- fs/ceph/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index b9f0f4e460ab..9675ef3a6c47 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -294,6 +294,10 @@ static long ceph_set_encryption_policy(struct file *file, unsigned long arg) struct inode *inode = file_inode(file); struct ceph_inode_info *ci = ceph_inode(inode); + /* encrypted directories can't have striped layout */ + if (ci->i_layout.stripe_count > 1) + return -EINVAL; + ret = vet_mds_for_fscrypt(file); if (ret) return ret;