Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1134561pxb; Wed, 10 Feb 2021 00:28:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxlWmTWWnt2fNn6F59rIt658wqgNwiCmbITbR/KC52Fqka8tx3RRGRW67PO/sCnJtvQz2S X-Received: by 2002:a17:906:aed1:: with SMTP id me17mr1891196ejb.190.1612945738101; Wed, 10 Feb 2021 00:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612945738; cv=none; d=google.com; s=arc-20160816; b=kjs7w2+GunA7CXWQE0mOVBhxKsJwtMTJknhTizaKFZQLj3j0D996fE57x1ClZclvWc 4zCLQdiJ+uBVt3Z1vaLfi1sXjFxqiDKur3tcOTYMCeICKDEVyT1f5ZIC6R+vtMwJLknT QNpks/R40t5OpjgqZXR0uLTPur0uacGQE9KY1j1PRkOSzHgKYUqbgBbK1A5BscTV1ZaC r07DEFDgI29ZFDZtvy/Mq69c1shuCfG0D7lSq15jK/nXaQ5NkUWy372e9qx7TRiiDnDH 1t+5OmqZl7ftW7KMmIyN5woJr9Ql+ka5Buu93YeLYjfCBR5AkugIvP0LPEDyghiMuAcr eLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=d7Brygj3BEPnyPH7TkkpETAKfIe3olYaHlfIfBUUFM4=; b=C7cnUxkhzNmh55cESgjhzH744BX0z2hidXV3nQm51KB+6oCsmr53JzabOSvZ6NOWJr fObTIlPjxrzAmdZjOJ5wUKkVRHHwEvz5HULWXPa5JccYy3qHAQSU2Pc/Hl5PBfklnuaL IeEvc5x/9NZKgG9ZGbHrMaFzEubG7RAIa8AhPmx05mfSN/vl9k67Rr+NemV++CEANj/A zX/W4L8EzLCmX64VRrwwS+6hrkamAX8CK5smkfqMqMSE1Ot87ODX7LYZTWqHxDCmEsK2 e7XF3MgyP9UgeCxwJ57w+au4ew/MGZix/ErNu2tEx6bj9Wq5T8+UJ3mxIE90VJusSHbU rQCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b9si938222edt.398.2021.02.10.00.28.35; Wed, 10 Feb 2021 00:28:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbhBJEEx (ORCPT + 99 others); Tue, 9 Feb 2021 23:04:53 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:34724 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229969AbhBJEEs (ORCPT ); Tue, 9 Feb 2021 23:04:48 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 11A43jtE014659 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 9 Feb 2021 23:03:46 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 5627215C3601; Tue, 9 Feb 2021 23:03:45 -0500 (EST) Date: Tue, 9 Feb 2021 23:03:45 -0500 From: "Theodore Ts'o" To: Andreas Dilger Cc: Daniel Rosenberg , Eric Biggers , Ext4 Developers List , Linux Kernel Mailing List , linux-fsdevel , Gabriel Krisman Bertazi , kernel-team@android.com, Paul Lawrence Subject: Re: [PATCH 1/2] ext4: Handle casefolding with encryption Message-ID: References: <20210203090745.4103054-2-drosen@google.com> <56BC7E2D-A303-45AE-93B6-D8921189F604@dilger.ca> <42511E9D-3786-4E70-B6BE-D7CB8F524912@dilger.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42511E9D-3786-4E70-B6BE-D7CB8F524912@dilger.ca> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 09, 2021 at 08:03:10PM -0700, Andreas Dilger wrote: > Depending on the size of the "escape", it probably makes sense to move > toward having e2fsck migrate from the current mechanism to using dirdata > for all deployments. In the current implementation, tools don't really > know for sure if there is data beyond the filename in the dirent or not. It's actually quite well defined. If dirdata is enabled, then we follow the dirdata rules. If dirdata is *not* enabled, then if a directory inode has the case folding and encryption flags set, then there will be cryptographic data immediately following the filename. Otherwise, there is no valid data after the filename. > For example, what if casefold is enabled on an existing filesystem that > already has an encrypted directory? Does the code _assume_ that there is > a hash beyond the name if the rec_len is long enough for this? No, we will only expect there to be a hash beyond the name if EXT4_CASEFOLD_FL and EXT4_ENCRYPT_FL flags are set on the inode. (And if the rec_len is not large enough, then that's a corrupted directory entry.) > I guess it is implicit with the casefold+encryption case for dirents in > directories that have the encryption flag set in a filesystem that also > has casefold enabled, but it's definitely not friendly to these features > being enabled on an existing filesystem. No, it's fine. That's because the EXT4_CASEFOLD_FL inode flag can only be set if the EXT4_FEATURE_INCOMPAT_CASEFOLD is set in the superblock, and EXT4_ENCRYPT_FL inode flag can only be set if EXT4_FEATURE_INCOMPAT_ENCRYPT is set in the superblock, this is why it will be safe to enable of these features, since merely enabling the file system features only allows new directories to be created with both CASEFOLD_FL and ENCRYPT_FL set. The only restriction we would have is a file system has both the case folding and encryption features, it will *not* be safe to set the dirdata feature flag without first scanning all of the directories to see if there are any directories that have both the casefold and encrypt flags set on that inode, and if so, to convert all of the directory entries to use dirdata. I don't think this is going to be a significant restriction in practice, though. - Ted