Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1615473pxp; Thu, 17 Mar 2022 12:47:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCUZj2osdKp/PeSPusDTuwdU0Iqr0PofrHXxQvgSZDAg2zVvrTwHZ8s0624MftLUZTOS8+ X-Received: by 2002:a05:6a00:238f:b0:4f6:b09a:4c63 with SMTP id f15-20020a056a00238f00b004f6b09a4c63mr6075777pfc.35.1647546433032; Thu, 17 Mar 2022 12:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647546433; cv=none; d=google.com; s=arc-20160816; b=0nPuuswt5jdJMZ7mk5EUXReK+0Ge9NdFoTH263IWvuzNwkHhNWbHfwoN4JVvq/ZIIS dLNPnm3SqAUiUtrhkVv7rv2eyCQTpUB5CEkIjBjQ8Yhex7olQ07Gl08yP+rXB8EC0wvq 8DDKayfr0pXF96vK7iBuNA3/s4ou3qql30V4YHbjQO/KI7jk+Q9212WFnPfmgONGSlVj d4l960tXKlsEtGYOJ6spMX3fhoo+5A34rQOVI7x+poLQ5/sDGSSwTy9O05iAwPtwBn0u /hDzzIQ7/10ahcVKW06oLoqs0VMBMvWPwnwENtb3+Fyvod/Qm83ZLoz2kHPe7GPSLM/R BJ4A== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=dN/tRmavsr/5lSp9HA/dteMDA5hXjEWxlRPogS3sLHg=; b=ckpzRbkHoZ+Nm8l8wBqFU+wPtFE9SvM91O9XMmgjjbXmNwjjEjr3jlaRnvPpTRIJ1H AAukJSiAEeoGRNfOz73UU90ixPaCTU8fgzkwcApRN8UcrLOyurOpSfGOqsq4aMrAPixE VW1zSiMGqNITPkpR1QqVEeXyj6idG6B/iBPap/rZVUMUyFP0X3Hl+Fj91ppAWUMHGH/2 iVqKDalbC6OUfe37XXgk7h4YHjR/azAT7tJJsn8MluHGwCt7lndQw6L+kyZZC/RLoUuF AwTFDzo271KJLgPxHDDaMx8SQyUg27YWUZDwWMYvgFpvgKsG7LCQpW/uUIbPRx/Pj6hI FCDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="mU/ra/Cf"; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id m5-20020a170902bb8500b0014ffb47df67si5295652pls.130.2022.03.17.12.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 12:47:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="mU/ra/Cf"; dkim=neutral (no key) header.i=@suse.de; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E27AB23FF28; Thu, 17 Mar 2022 12:45:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236048AbiCQPqY (ORCPT + 99 others); Thu, 17 Mar 2022 11:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232616AbiCQPqW (ORCPT ); Thu, 17 Mar 2022 11:46:22 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9262E126FA6; Thu, 17 Mar 2022 08:45:05 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 52A5C1F390; Thu, 17 Mar 2022 15:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1647531904; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dN/tRmavsr/5lSp9HA/dteMDA5hXjEWxlRPogS3sLHg=; b=mU/ra/CfSjsWhWo2es6LXXvuJmqF8r9Sv+2yIpOiMvy6QYuHWJx6UQHhQckZIo4MkUOqGC hWJ0y18Ap9pHq7m6GqfykJzzyK41WfYbPO5MdBBz5FGMCQqAhUNAtkg66PZD685tA46pcw /V3+pbwz70sPV50dHMaoY1zQiu85bLw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1647531904; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dN/tRmavsr/5lSp9HA/dteMDA5hXjEWxlRPogS3sLHg=; b=f61F31Nx1vnyDkSxNto/oBxKO4Fp8Gyp1Kh6DfWD5PbxR9dGNlcQ6elrVJxXaCsGEzQ7lK J5ub59l64miTlNAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D2E4D13BB7; Thu, 17 Mar 2022 15:45:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vCNVMH9XM2L6UwAAMHmgww (envelope-from ); Thu, 17 Mar 2022 15:45:03 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id b0c7e6d1; Thu, 17 Mar 2022 15:45:22 +0000 (UTC) From: =?UTF-8?q?Lu=C3=ADs=20Henriques?= To: Jeff Layton , Xiubo Li , Ilya Dryomov Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Lu=C3=ADs=20Henriques?= Subject: [RFC PATCH v3 0/4] ceph: add support for snapshot names encryption Date: Thu, 17 Mar 2022 15:45:17 +0000 Message-Id: <20220317154521.6615-1-lhenriques@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Hi! Here's another iteration on my encrypted snapshot names series. And here's the changes since v1: - Use ceph_find_inode() instead of ceph_get_inode() for finding a snapshot parent in function parse_longname(). I've also added a fallback to ceph_get_inode() in case we fail to find the inode. This may happen if, for example, the mount root doesn't include that inode. The iput() was also complemented by a discard_new_inode() if the inode is in the I_NEW state. (patch 0002) - Move the check for '_' snapshots further up in the ceph_fname_to_usr() and ceph_encode_encrypted_dname(). This fixes the case pointed out by Xiubo in v2. (patch 0002) - Use NAME_MAX for tmp arrays (patch 0002) - Added an extra patch for replacing the base64url encoding by a different encoding standard, the one used for IMAP mailboxes (which uses '+' and ',' instead of '-' and '_'). This should fix the issue with snapshot names starting with '_'. (patch 0003) Regarding this last patch, there are other alternatives: 1. Simply replace any initial '_' in snapshot names by another character (I was using the '='). This was a bit more hacky because this name could never be sent as-is to the base64 functions, so the '=' would need to be replace back by an '_'. 2. Append an extra (known) char to every snapshot name. This would also be hacky because it would need to be removed again for base64 operations. And the snapshot name size limitations would need to be adjusted too. 3. Modify the fscrypt base64 encoding/decoding functions to receive an alternative table to use in these operations. This would need to be accepted by the fscrypt maintainers, of course. As before, in order to test this code the following PRs are required: mds: add protection from clients without fscrypt support #45073 mds: use the whole string as the snapshot long name #45192 mds: support alternate names for snapshots #45224 mds: limit the snapshot names to 240 characters #45312 Changes since v1: - Dropped the dentry->d_flags change in ceph_mkdir(). Thanks to Xiubo suggestion, patch 0001 now skips calling ceph_fscrypt_prepare_context() if we're handling a snapshot. - Added error handling to ceph_get_snapdir() in patch 0001 (Jeff had already pointed that out but I forgot to include that change in previous revision). - Rebased patch 0002 to the latest wip-fscrypt branch. - Added some documentation regarding snapshots naming restrictions. Luís Henriques (4): ceph: add support for encrypted snapshot names ceph: handle encrypted snapshot names in subdirectories ceph: update documentation regarding snapshot naming limitations ceph: replace base64url by the encoding used for mailbox names Documentation/filesystems/ceph.rst | 10 ++ fs/ceph/crypto.c | 238 +++++++++++++++++++++++++---- fs/ceph/crypto.h | 14 +- fs/ceph/dir.c | 2 +- fs/ceph/inode.c | 33 +++- 5 files changed, 259 insertions(+), 38 deletions(-)