Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp867724pxb; Fri, 22 Apr 2022 13:02:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4Na/Z0Yywa0yCBF/lXcW8t6BMp+gNzUxmG7zdejYKzyz7pi3tKWtv8Fh3HNXfLwfmB/v6 X-Received: by 2002:a17:90a:4bc2:b0:1b8:cdd3:53e2 with SMTP id u2-20020a17090a4bc200b001b8cdd353e2mr17759701pjl.219.1650657734170; Fri, 22 Apr 2022 13:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650657734; cv=none; d=google.com; s=arc-20160816; b=dMRhwIFV9iROqIFI6sr5plQzbJ44KNSCo2VHJS9fxcAvgOE6kxNecQUtniR2ChGMM6 rHjhQKuzevl+g4YpYRiBNhEh3CJDdhUYMwzNhppIlCleWXLQQyIBls+fMwqSKW06qCjz UhLxKVeIWjyQiuv3pJQuO2OewDq00IzvGOL/2oo5B1M5SELLUXc5/OJHzXApX9tNXyK9 8W8D29FUrvM3DHtcxGcSVnC3caozJIijIESgYV35VQXTimWnfFVGCap38+n5XKb5mwVX 30xBT9P4ZLgTzIZA9DV/51TmhQ1sDiRYft0jfudVz0r59t4PHC0dboo1lFTdGwZ7ajnj 2IMg== 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=dq8YNbXAE834M1QUb2YVyiKzk/PMukhaArBlMLDdUQI=; b=gZ1D9Wj44ict15xbCBvaCNLHObrXFGwS8UTOvIn+A9iPzXnUM72IA5E60hzoAV4eiH pLihrfyOvDCcQFBjSN2algxV1cawrZJVWQmHlsZeAybzFhGTTEN/+ntoLzIDtTHl2SPC sMZUjWLCnuQxNQeqQNflY0NW7AdWJyg6BtDqY04WnxgQGaLY83I93HYuD67ylXPja0Nr 0vc3zvzPjQkQ4i150sQjNpf1+3vnuWz0KzmfaWEokvNB9617bSHyaFa+F+hP++MdCRxZ h/QAm1bknoB1k8UDPi54td/e4wf5tPQSj1xTiImPm2C5/oaUmjuieToqJT0cCN0Nmn0S 6+sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=rWsXoUFd; 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 b17-20020a056a000a9100b00505b3204852si10099068pfl.270.2022.04.22.13.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:02:14 -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=rWsXoUFd; 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 150A91430EA; Fri, 22 Apr 2022 12:00:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240573AbiDRPIp (ORCPT + 99 others); Mon, 18 Apr 2022 11:08:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345369AbiDRPHk (ORCPT ); Mon, 18 Apr 2022 11:07:40 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B8C2CE0A; Mon, 18 Apr 2022 06:59:33 -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-out1.suse.de (Postfix) with ESMTPS id D1D5A2161D; Mon, 18 Apr 2022 13:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1650290371; 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=dq8YNbXAE834M1QUb2YVyiKzk/PMukhaArBlMLDdUQI=; b=rWsXoUFdmWF9h2C9XaehirIrKSiHsyys3BkFa41aY3eU6+iSH8UAhHCgH1OVBH+WyyrFpn dw/5bsEZFNtpC0fNGp1rhDieaknlnpVdzs52+uRjlgEyVWXNjVkCzIpeHNj8k0kHiFjzpc Yn+RpSOcON+u1e9weLFHkdJLRwPAHew= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1650290371; 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=dq8YNbXAE834M1QUb2YVyiKzk/PMukhaArBlMLDdUQI=; b=UXDhCsIm868KMg44CpXYMbAB/ityAQ4j4utoEulTatT+2ciKRW92IyiiqJdSBMmBxfac3M wvLGt5hwSzfWaFBw== 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 5343113A9B; Mon, 18 Apr 2022 13:59:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id je1DEcNuXWLiOwAAMHmgww (envelope-from ); Mon, 18 Apr 2022 13:59:31 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id a8b50ae4; Mon, 18 Apr 2022 13:59:58 +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: [PATCH v5 0/5] ceph: add support for snapshot names encryption Date: Mon, 18 Apr 2022 14:59:52 +0100 Message-Id: <20220418135957.12056-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 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! And here's yet another revision. The main difference from v4 is the addition of a patch to prevent the creation of snapshots in directories that are encrypted but that are not unlocked (i.e. no key available). As before, the following ceph 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 v4: - Explicitly added the encoding base for kstrtou64() as we do know that the inode numbers are in decimal. - New patch to prevent the creation of snapshots in encrypted directories that do not have the key loaded. Changes since v3: - Fixed WARN_ON() in ceph_encode_encrypted_dname() - Updated documentation and copyright notice for the base64 encoding/decoding implementaiton which was taken from the fscrypt base. Changes since v2: - 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) 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 (5): ceph: add support for encrypted snapshot names ceph: add support for handling encrypted snapshot names ceph: update documentation regarding snapshot naming limitations ceph: replace base64url by the encoding used for mailbox names ceph: prevent snapshots to be created in encrypted locked directories Documentation/filesystems/ceph.rst | 10 ++ fs/ceph/crypto.c | 252 +++++++++++++++++++++++++---- fs/ceph/crypto.h | 14 +- fs/ceph/dir.c | 7 +- fs/ceph/inode.c | 33 +++- 5 files changed, 278 insertions(+), 38 deletions(-)