From: "Luís Henriques" <lhenriques@suse.de>
To: Eric Biggers <ebiggers@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>,
idryomov@gmail.com, xiubli@redhat.com,
ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-fscrypt@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v11 02/51] fscrypt: export fscrypt_base64url_encode and fscrypt_base64url_decode
Date: Fri, 25 Mar 2022 09:59:08 +0000 [thread overview]
Message-ID: <87sfr6nyj7.fsf@brahms.olymp> (raw)
In-Reply-To: <YjyubQgfbQbUn4Ct@gmail.com> (Eric Biggers's message of "Thu, 24 Mar 2022 17:46:21 +0000")
Eric Biggers <ebiggers@kernel.org> writes:
> On Wed, Mar 23, 2022 at 02:33:17PM +0000, Luís Henriques wrote:
>> Hi Eric,
>>
>> Jeff Layton <jlayton@kernel.org> writes:
>>
>> > Ceph is going to add fscrypt support, but we still want encrypted
>> > filenames to be composed of printable characters, so we can maintain
>> > compatibility with clients that don't support fscrypt.
>> >
>> > We could just adopt fscrypt's current nokey name format, but that is
>> > subject to change in the future, and it also contains dirhash fields
>> > that we don't need for cephfs. Because of this, we're going to concoct
>> > our own scheme for encoding encrypted filenames. It's very similar to
>> > fscrypt's current scheme, but doesn't bother with the dirhash fields.
>> >
>> > The ceph encoding scheme will use base64 encoding as well, and we also
>> > want it to avoid characters that are illegal in filenames. Export the
>> > fscrypt base64 encoding/decoding routines so we can use them in ceph's
>> > fscrypt implementation.
>> >
>> > Acked-by: Eric Biggers <ebiggers@google.com>
>> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
>> > ---
>> > fs/crypto/fname.c | 8 ++++----
>> > include/linux/fscrypt.h | 5 +++++
>> > 2 files changed, 9 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
>> > index a9be4bc74a94..1e4233c95005 100644
>> > --- a/fs/crypto/fname.c
>> > +++ b/fs/crypto/fname.c
>> > @@ -182,8 +182,6 @@ static int fname_decrypt(const struct inode *inode,
>> > static const char base64url_table[65] =
>> > "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
>> >
>> > -#define FSCRYPT_BASE64URL_CHARS(nbytes) DIV_ROUND_UP((nbytes) * 4, 3)
>> > -
>> > /**
>> > * fscrypt_base64url_encode() - base64url-encode some binary data
>> > * @src: the binary data to encode
>> > @@ -198,7 +196,7 @@ static const char base64url_table[65] =
>> > * Return: the length of the resulting base64url-encoded string in bytes.
>> > * This will be equal to FSCRYPT_BASE64URL_CHARS(srclen).
>> > */
>> > -static int fscrypt_base64url_encode(const u8 *src, int srclen, char *dst)
>> > +int fscrypt_base64url_encode(const u8 *src, int srclen, char *dst)
>>
>> I know you've ACK'ed this patch already, but I was wondering if you'd be
>> open to change these encode/decode interfaces so that they could be used
>> for non-url base64 too.
>>
>> My motivation is that ceph has this odd limitation where snapshot names
>> can not start with the '_' character. And I've an RFC that adds snapshot
>> names encryption support which, unfortunately, can end up starting with
>> this char after base64 encoding.
>>
>> So, my current proposal is to use a different encoding table. I was
>> thinking about the IMAP mailboxes naming which uses '+' and ',' instead of
>> the '-' and '_', but any other charset would be OK (except those that
>> include '/' of course). So, instead of adding yet another base64
>> implementation to the kernel, I was wondering if you'd be OK accepting a
>> patch to add an optional arg to these encoding/decoding functions to pass
>> an alternative table. Or, if you'd prefer, keep the existing interface
>> but turning these functions into wrappers to more generic functions.
>>
>> Obviously, Jeff, please feel free to comment too if you have any reserves
>> regarding this approach.
>>
>> Cheers,
>> --
>> Luís
>>
>
> Base64 encoding/decoding is trivial enough that I think you should just add your
> own functions to fs/ceph/ for now if you need yet another Base64 variant. If we
> were to add general functions that allow "building your own" Base64 variant, I
> think they'd belong in lib/, not fs/crypto/. (I objected to lib/ in the first
> version of Jeff's patchset because that patchset proposed adding just the old,
> idiosyncratic fscrypt Base64 variant to lib/ and just calling it "base64", which
> was misleading. But, if there were to be properly documented functions to
> "build your own" Base64 variant, allowing control over both the character set
> and whether padding is done, lib/ would be the place...)
OK, that makes sense. I agree that the right place for a generic
implementation would be somewhere out of the fs/crypto/ directory. I
guess that, for now, I'll follow your advice and keep a local
implementation (in fact, the libceph *has* already an implementation!).
But adding a generic implementation and clean-up all the different
implementations in the kernel tree is probably a nice project. For the
future. Maybe. *sigh*
Cheers,
--
Luís
next prev parent reply other threads:[~2022-03-25 9:58 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 14:12 [RFC PATCH v11 00/51] ceph+fscrypt : full support Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 01/51] vfs: export new_inode_pseudo Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 02/51] fscrypt: export fscrypt_base64url_encode and fscrypt_base64url_decode Jeff Layton
2022-03-23 14:33 ` Luís Henriques
2022-03-24 17:46 ` Eric Biggers
2022-03-25 9:59 ` Luís Henriques [this message]
2022-03-24 18:20 ` Colin Walters
2022-03-22 14:12 ` [RFC PATCH v11 03/51] fscrypt: export fscrypt_fname_encrypt and fscrypt_fname_encrypted_size Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 04/51] fscrypt: add fscrypt_context_for_new_inode Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 05/51] ceph: preallocate inode for ops that may create one Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 06/51] ceph: crypto context handling for ceph Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 07/51] ceph: parse new fscrypt_auth and fscrypt_file fields in inode traces Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 08/51] ceph: add support for fscrypt_auth/fscrypt_file to cap messages Jeff Layton
2022-03-23 16:55 ` Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 09/51] ceph: add ability to set fscrypt_auth via setattr Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 10/51] ceph: implement -o test_dummy_encryption mount option Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 11/51] ceph: decode alternate_name in lease info Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 12/51] ceph: add fscrypt ioctls Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 13/51] ceph: make the ioctl cmd more readable in debug log Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 14/51] ceph: make ceph_msdc_build_path use ref-walk Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 15/51] ceph: add encrypted fname handling to ceph_mdsc_build_path Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 16/51] ceph: send altname in MClientRequest Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 17/51] ceph: encode encrypted name in dentry release Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 18/51] ceph: properly set DCACHE_NOKEY_NAME flag in lookup Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 19/51] ceph: make d_revalidate call fscrypt revalidator for encrypted dentries Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 20/51] ceph: add helpers for converting names for userland presentation Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 21/51] ceph: fix base64 encoded name's length check in ceph_fname_to_usr() Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 22/51] ceph: add fscrypt support to ceph_fill_trace Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 23/51] ceph: pass the request to parse_reply_info_readdir() Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 24/51] ceph: add ceph_encode_encrypted_dname() helper Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 25/51] ceph: add support to readdir for encrypted filenames Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 26/51] ceph: create symlinks with encrypted and base64-encoded targets Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 27/51] ceph: make ceph_get_name decrypt filenames Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 28/51] ceph: add a new ceph.fscrypt.auth vxattr Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 29/51] ceph: add some fscrypt guardrails Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 30/51] ceph: don't allow changing layout on encrypted files/directories Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 31/51] libceph: add CEPH_OSD_OP_ASSERT_VER support Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 32/51] ceph: size handling for encrypted inodes in cap updates Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 33/51] ceph: fscrypt_file field handling in MClientRequest messages Jeff Layton
2022-03-22 14:12 ` [RFC PATCH v11 34/51] ceph: get file size from fscrypt_file when present in inode traces Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 35/51] ceph: handle fscrypt fields in cap messages from MDS Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 36/51] ceph: add __ceph_get_caps helper support Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 37/51] ceph: add __ceph_sync_read " Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 38/51] ceph: add object version support for sync read Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 39/51] ceph: add infrastructure for file encryption and decryption Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 40/51] ceph: add truncate size handling support for fscrypt Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 41/51] libceph: allow ceph_osdc_new_request to accept a multi-op read Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 42/51] ceph: disable fallocate for encrypted inodes Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 43/51] ceph: disable copy offload on " Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 44/51] ceph: don't use special DIO path for " Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 45/51] ceph: align data in pages in ceph_sync_write Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 46/51] ceph: add read/modify/write to ceph_sync_write Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 47/51] ceph: plumb in decryption during sync reads Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 48/51] ceph: add fscrypt decryption support to ceph_netfs_issue_op Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 49/51] ceph: set i_blkbits to crypto block size for encrypted inodes Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 50/51] ceph: add encryption support to writepage Jeff Layton
2022-03-22 14:13 ` [RFC PATCH v11 51/51] ceph: fscrypt support for writepages Jeff Layton
2022-03-22 14:17 ` [RFC PATCH v11 00/51] ceph+fscrypt : full support Jeff Layton
2022-03-25 9:57 ` Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87sfr6nyj7.fsf@brahms.olymp \
--to=lhenriques@suse.de \
--cc=ceph-devel@vger.kernel.org \
--cc=ebiggers@kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiubli@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox