Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp197647pxm; Fri, 25 Feb 2022 06:28:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2xnRq7u7m7SPidnfirDktyeChK2wn2mNtucvGHNuIEhqnVohY0SOO3xQiM/Wq1DBrF3mQ X-Received: by 2002:a17:907:3c03:b0:6cf:65ec:5f28 with SMTP id gh3-20020a1709073c0300b006cf65ec5f28mr6298350ejc.324.1645799330895; Fri, 25 Feb 2022 06:28:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645799330; cv=none; d=google.com; s=arc-20160816; b=BKZGdrRULNobi1v7XBB7JIed4AymouIJmVniuvzsnKC/wzxRJKTKIx3ZPZKJYqtfM7 pNHtZO5zCPOcy+VEvVWRL65e3KOWyrqj6BiTbX0bAxiQo31x0ECpIi/+Mfc8/hw7VUAD cJQKq4Co5lyV7puY8x0cjzK2c6hQKXjtPDD9+JmTeoH6t7sSD5NJzl5Nk6b5mkocWKRV R0n7dU+mIhsgnPrgzJ58JGagIwizMZ2a3YgsFFy6qeY6KEjQ+cuCC6otmN2pv/7UY0JU QPfDRULdHcOuyXwkYZn0mBvl9+k9PMbfUYxFjBDVSP8U7RWQJZOELxo1Z7vR4qtV2DVA STMw== 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:in-reply-to:date:references:subject:cc:to:from :dkim-signature:dkim-signature; bh=b5P4zVYBKfq9PaqqHPI7HgucU9j+DVcXognLTQWrknQ=; b=XgYDm55YNUPfYhrXmsR0KePxHTtpQbe8TWnnxWi4nrCaQWAN+uRzZzVu9GdyYGkFWe wyDaQIp5E0lTTrVswbBUg9hJdUVX4pQqFqBhDv+/3WePXp0/mSjZipjZfbkIf2umADZc dAfYYNH8wlcLy2vSsB58PrlrJu1bGPUN2TiL2fuUq/8iq1e1v3hLWtkqWSQ3csfPhT7q KI4x6GSDtJLO6YfDT0jnW2Lf/PUz4tkJ0AvRWiqfEoiSVfhzIrKqDMMo9li3r8YcEFPW lQh16vEhQ4Ll5Yk3InbvBoTBqcB4VHR2nTD7q7dZjuEXNsSlsFo4P+BkwDWMN9RUiHRI gYwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Z4Tv7DRX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a170906468a00b006cfd20e11a7si1646192ejr.171.2022.02.25.06.28.27; Fri, 25 Feb 2022 06:28:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Z4Tv7DRX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239240AbiBYJtD (ORCPT + 99 others); Fri, 25 Feb 2022 04:49:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233675AbiBYJtC (ORCPT ); Fri, 25 Feb 2022 04:49:02 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472B32255A8; Fri, 25 Feb 2022 01:48:30 -0800 (PST) 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 0523C1F380; Fri, 25 Feb 2022 09:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1645782509; 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: in-reply-to:in-reply-to:references:references; bh=b5P4zVYBKfq9PaqqHPI7HgucU9j+DVcXognLTQWrknQ=; b=Z4Tv7DRXcrN/Fg/4rhQtoqbR0F+ItAF3Gdyhbkxg9gG/PKqwvlc5TuYfBhJrxPntYRdTpb ZJEn6Il2TfmmMgOUrKSi11cdxP956hQQBh+N72nUV6jvjLrWlvKPwqBOzQ3MDl3WG1roqm 3p7xTU2EpU7e032OvIrjXpenvo5JRrs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1645782509; 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: in-reply-to:in-reply-to:references:references; bh=b5P4zVYBKfq9PaqqHPI7HgucU9j+DVcXognLTQWrknQ=; b=vEKhzATAKezWEJ7UK90x1rmj7syMsxg+id66QPLtWh7PSpsK1tBjktlkI283qzqb2/574B ucOtVIqQr09c22Cg== 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 9247713B96; Fri, 25 Feb 2022 09:48:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id S6ubIOylGGJrYQAAMHmgww (envelope-from ); Fri, 25 Feb 2022 09:48:28 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id 6e4be55a; Fri, 25 Feb 2022 09:48:42 +0000 (UTC) From: =?utf-8?Q?Lu=C3=ADs_Henriques?= To: Xiubo Li Cc: Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] ceph: add support for encrypted snapshot names References: <20220224112142.18052-1-lhenriques@suse.de> <7d2a798d-ce32-4bf7-b184-267bb79f44e3@redhat.com> Date: Fri, 25 Feb 2022 09:48:42 +0000 In-Reply-To: <7d2a798d-ce32-4bf7-b184-267bb79f44e3@redhat.com> (Xiubo Li's message of "Fri, 25 Feb 2022 14:55:02 +0800") Message-ID: <87h78ni8ed.fsf@brahms.olymp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Xiubo Li writes: > On 2/24/22 7:21 PM, Lu=C3=ADs Henriques wrote: >> Since filenames in encrypted directories are already encrypted and shown >> as a base64-encoded string when the directory is locked, snapshot names >> should show a similar behaviour. >> >> Signed-off-by: Lu=C3=ADs Henriques >> --- >> fs/ceph/dir.c | 15 +++++++++++++++ >> fs/ceph/inode.c | 10 +++++++++- >> 2 files changed, 24 insertions(+), 1 deletion(-) >> >> Support on the MDS for names that'll be > MAX_NAME when base64 encoded is >> still TBD. I thought it would be something easy to do, but snapshots >> don't seem to make use of the CDir/CDentry (which is where alternate_name >> is stored on the MDS). I'm still looking into this, but I may need some >> help there :-( >> >> Cheers, >> -- >> Lu=C3=ADs >> >> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c >> index a449f4a07c07..20ae600ee7cd 100644 >> --- a/fs/ceph/dir.c >> +++ b/fs/ceph/dir.c >> @@ -1065,6 +1065,13 @@ static int ceph_mkdir(struct user_namespace *mnt_= userns, struct inode *dir, >> op =3D CEPH_MDS_OP_MKSNAP; >> dout("mksnap dir %p snap '%pd' dn %p\n", dir, >> dentry, dentry); >> + /* XXX missing support for alternate_name in snapshots */ >> + if (IS_ENCRYPTED(dir) && (dentry->d_name.len >=3D 189)) { >> + dout("encrypted snapshot name too long: %pd len: %d\n", >> + dentry, dentry->d_name.len); >> + err =3D -ENAMETOOLONG; >> + goto out; >> + } >> } else if (ceph_snap(dir) =3D=3D CEPH_NOSNAP) { >> dout("mkdir dir %p dn %p mode 0%ho\n", dir, dentry, mode); >> op =3D CEPH_MDS_OP_MKDIR; >> @@ -1109,6 +1116,14 @@ static int ceph_mkdir(struct user_namespace *mnt_= userns, struct inode *dir, >> !req->r_reply_info.head->is_target && >> !req->r_reply_info.head->is_dentry) >> err =3D ceph_handle_notrace_create(dir, dentry); >> + >> + /* >> + * If we have created a snapshot we need to clear the cache, otherwise >> + * snapshot will show encrypted filenames in readdir. >> + */ > > Do you mean dencrypted filenames ? What I see without this d_drop() is that, if I run an 'ls' in a snapshot directory immediately after creating it, the filenames in that snapshot will be encrypted. Maybe there's a bug somewhere else and this d_drop() isn't the right fix...? Cheers, --=20 Lu=C3=ADs > > - Xiubo > > >> + if (ceph_snap(dir) =3D=3D CEPH_SNAPDIR) >> + d_drop(dentry); >> + >> out_req: >> ceph_mdsc_put_request(req); >> out: >> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c >> index 8b0832271fdf..080824610b73 100644 >> --- a/fs/ceph/inode.c >> +++ b/fs/ceph/inode.c >> @@ -182,6 +182,13 @@ struct inode *ceph_get_snapdir(struct inode *parent) >> ci->i_rbytes =3D 0; >> ci->i_btime =3D ceph_inode(parent)->i_btime; >> + /* if encrypted, just borough fscrypt_auth from parent */ >> + if (IS_ENCRYPTED(parent)) { >> + struct ceph_inode_info *pci =3D ceph_inode(parent); >> + inode->i_flags |=3D S_ENCRYPTED; >> + ci->fscrypt_auth_len =3D pci->fscrypt_auth_len; >> + ci->fscrypt_auth =3D pci->fscrypt_auth; >> + } >> if (inode->i_state & I_NEW) { >> inode->i_op =3D &ceph_snapdir_iops; >> inode->i_fop =3D &ceph_snapdir_fops; >> @@ -632,7 +639,8 @@ void ceph_free_inode(struct inode *inode) >> kfree(ci->i_symlink); >> #ifdef CONFIG_FS_ENCRYPTION >> - kfree(ci->fscrypt_auth); >> + if (ceph_snap(inode) !=3D CEPH_SNAPDIR) >> + kfree(ci->fscrypt_auth); >> #endif >> fscrypt_free_inode(inode); >> kmem_cache_free(ceph_inode_cachep, ci); >> >