Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1573231pxp; Thu, 17 Mar 2022 11:50:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzy8Hmlhw7NsfXqEAOsyh3vA9uu105HGFPss/dcxEIC2ev3FDamwPlVijUntr4oNz60Iqrv X-Received: by 2002:a05:6402:50cf:b0:418:ee57:ed9 with SMTP id h15-20020a05640250cf00b00418ee570ed9mr5968562edb.37.1647543030800; Thu, 17 Mar 2022 11:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647543030; cv=none; d=google.com; s=arc-20160816; b=Z/39pwk1vnFjAv+5UbJq7HcgBOQcAIPyMZOwkBwyNbY6A5KOokJGkv1la245Ei0aQ8 1mJdmNht0c1L6DNMCRq/HSIhjn1PlxvJpasBMIyTgKnw0VpnSlV7grzEa8wPyYdBublS Fwv6ovyADij1qaXmfQC9z/HwMyRKrgLsQQH88Xg3HTKlszBK+9MrAw+Nvg1w1KNjDTg1 or+534H1mGBk2pcNXCVCxAkWxsnWJRSavx96SLtjWm8tAYjVKyi5UismLyJ71e3Ikc6P LMJ04YPKOhABP2rEsF2jN9xlpp7tej4gSu0+n4rBriuBVv0xaQa20lWYtcXjq0ybn9go 7V2w== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=G+Hm1tE+ylkklWmR/EEYcvA28RBbH4INsDSUTNIC084=; b=wsm9hlnQssYTuRjKZp4T3wMzBF4EvZSo0jOgPivYUznEicGOF4SnH2WbJn0gpny2RR hquyP5kPwyrrUkQJF9mssSu+vW99wLXDmndk0T/GObNItp9nkQp1eBQHkyPrjGcgoIwz BOUioMh5464NGrQpKWtKjg83Yy43mnPVw4lmh0KZ6O11f9bpbX6ZyFKVecOtXChOmki4 GFHy9nW+/AGW0yOxavmW0Rk6mgIm3snPtk2fAiSdoxTCFupcxZX2Yn7i0iHxE8Db7mn4 l9sqyRFWfqr2iYvIiWAjYErSDrTBseHsu4ABV+2fh2SiTadKKqlIayX7o2PHhpr0qWmy MjYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kzpc63bz; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z68-20020a509e4a000000b00418c2b5bdf7si2236729ede.217.2022.03.17.11.50.04; Thu, 17 Mar 2022 11:50:30 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=Kzpc63bz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbiCQMmk (ORCPT + 99 others); Thu, 17 Mar 2022 08:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233620AbiCQMmi (ORCPT ); Thu, 17 Mar 2022 08:42:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ABCF1EB834; Thu, 17 Mar 2022 05:41:22 -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 26404B81E8F; Thu, 17 Mar 2022 12:41:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46EC3C340E9; Thu, 17 Mar 2022 12:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647520879; bh=Q2zQ1j++uo4SPJHvL7ppclf6sdLAYnjUjIQC+75VC2Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Kzpc63bzAb9pwxNtUMK7B8mLVl2Ej3H2ZdFhn4yT2JLlERfLJPIU/LS5J9R+SjArU uaYzliMUybvvU3r/j/mnYTHNn97/thrHQ1ZI403a6Tp+kvc0npCupAxNwJ0m5RCK34 HPl/5cOaFpqTlsrstZI+kQj2YOW10vIobG12blK4/XHBftQxK1YtHNLLj1cpEA01Ed 4Yo3Ra+WsXL/pCV1fSNGNWHcUnyHV8Lroyrx8lrRq9pNK6iJzH3TX1vCWL/CVvwKP6 v0IvT8BIARm0yT7ZDHEyVeL7/1blnTwAIDqzSkAeyHhFNCdl7Fy6+BiMlmo0ojuk2L 8eCL4ibpOJJ7A== Message-ID: <93ac97c750456fe77d33f432629bad209dc14e81.camel@kernel.org> Subject: Re: [RFC PATCH v2 0/3] ceph: add support for snapshot names encryption From: Jeff Layton To: Xiubo Li , =?ISO-8859-1?Q?Lu=EDs?= Henriques Cc: Ilya Dryomov , Ceph Development , linux-kernel@vger.kernel.org Date: Thu, 17 Mar 2022 08:41:17 -0400 In-Reply-To: References: <20220315161959.19453-1-lhenriques@suse.de> <5b53e812-d49b-45f0-1219-3dbc96febbc1@redhat.com> <329abedd9d9938de95bf4f5600acdcd6a846e6be.camel@kernel.org> <3c8b78c4-5392-b81c-e76f-64fcce4f3c0f@redhat.com> <87wngshlzb.fsf@brahms.olymp> Content-Type: text/plain; charset="ISO-8859-15" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Thu, 2022-03-17 at 20:31 +0800, Xiubo Li wrote: > On 3/17/22 8:01 PM, Jeff Layton wrote: > > On Thu, 2022-03-17 at 11:11 +0000, Lu?s Henriques wrote: > > > Xiubo Li writes: > > > > > > > On 3/17/22 6:01 PM, Jeff Layton wrote: > > > > > I'm not sure we want to worry about .snap directories here since they > > > > > aren't "real". IIRC, snaps are inherited from parents too, so you could > > > > > do something like > > > > > > > > > > mkdir dir1 > > > > > mkdir dir1/.snap/snap1 > > > > > mkdir dir1/dir2 > > > > > fscrypt encrypt dir1/dir2 > > > > > > > > > > There should be nothing to prevent encrypting dir2, but I'm pretty sure > > > > > dir2/.snap will not be empty at that point. > > > > If we don't take care of this. Then we don't know which snapshots should do > > > > encrypt/dencrypt and which shouldn't when building the path in lookup and when > > > > reading the snapdir ? > > > In my patchset (which I plan to send a new revision later today, I think I > > > still need to rebase it) this is handled by using the *real* snapshot > > > parent inode. If we're decrypting/encrypting a name for a snapshot that > > > starts with a '_' character, we first find the parent inode for that > > > snapshot and only do the operation if that parent is encrypted. > > > > > > In the other email I suggested that we could prevent enabling encryption > > > in a directory when there are snapshots above in the hierarchy. But now > > > that I think more about it, it won't solve any problem because you could > > > create those snapshots later and then you would still need to handle these > > > (non-encrypted) "_name_xxxx" snapshots anyway. > > > > > Yeah, that sounds about right. > > > > What happens if you don't have the snapshot parent's inode in cache? > > That can happen if you (e.g.) are running NFS over ceph, or if you get > > crafty with name_to_handle_at() and open_by_handle_at(). > > > > Do we have to do a LOOKUPINO in that case or does the trace contain that > > info? If it doesn't then that could really suck in a big hierarchy if > > there are a lot of different snapshot parent inodes to hunt down. > > > > I think this is a case where the client just doesn't have complete > > control over the dentry name. It may be better to just not encrypt them > > if it's too ugly. > > > > Another idea might be to just use the same parent inode (maybe the > > root?) for all snapshot names. It's not as secure, but it's probably > > better than nothing. > > Does it allow to have different keys for the subdirs in the hierarchy ? > From my test it doesn't. > No. Once you set a key on directory you can't set another on a subtree of it. > If so we can always use the same oldest ancestor in the hierarchy, who > has encryption key, to encyrpt/decrypt all the .snap in the hierarchy, > then just need to lookup oldest ancestor inode only once. > That's a possibility. -- Jeff Layton