From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E97FC433E2 for ; Tue, 8 Sep 2020 04:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8E2021532 for ; Tue, 8 Sep 2020 03:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599537599; bh=vutJn3bXaUslL3kDw+93DPKmxLKkVjVONv+fNmUNOgc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=aE1JEh7AzZdxdHMZ5C4mNGOqU9hKHkbtdFJUT5tXsUVx66gSat2Cu5b5GLQkFCqVE tj2z18kXYSkEvevgL2vASXp/0l+znrqhX8FrpdD0PxUSUkagE8+qnGu5chrtK/GhXM JO1YTcZt7Vji4J2OSu5J9wiTX3jrpnmaExkCajT4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728561AbgIHD77 (ORCPT ); Mon, 7 Sep 2020 23:59:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:44932 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728327AbgIHD76 (ORCPT ); Mon, 7 Sep 2020 23:59:58 -0400 Received: from sol.localdomain (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2312921532; Tue, 8 Sep 2020 03:59:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599537598; bh=vutJn3bXaUslL3kDw+93DPKmxLKkVjVONv+fNmUNOgc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OfPir04GCJBxwFVTIlizrKIE14UBLwFUQvhV8BAIsX9ww146J2Tmbm52GqxiUQANk 3jV1UdsOzPS5BUSX1sLRCmp0m0y7SxxPbQR2LVCCpSHLe9hScCQz53LrvKxrv6M2Og 7Qst4SPnQtWYI4R/FydLrp/pAydZ8Pt35E9uhW1s= Date: Mon, 7 Sep 2020 20:59:56 -0700 From: Eric Biggers To: Jeff Layton Cc: ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-fscrypt@vger.kernel.org Subject: Re: [RFC PATCH v2 07/18] lib: lift fscrypt base64 conversion into lib/ Message-ID: <20200908035956.GH68127@sol.localdomain> References: <20200904160537.76663-1-jlayton@kernel.org> <20200904160537.76663-8-jlayton@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200904160537.76663-8-jlayton@kernel.org> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org On Fri, Sep 04, 2020 at 12:05:26PM -0400, Jeff Layton wrote: > Once we allow encrypted filenames on ceph we'll end up with names that > may have illegal characters in them (embedded '\0' or '/'), or > characters that aren't printable. > > It will be safer to use strings that are printable. It turns out that the > MDS doesn't really care about the length of filenames, so we can just > base64 encode and decode filenames before writing and reading them. > > Lift the base64 implementation that's in fscrypt into lib/. Make fscrypt > select it when it's enabled. > > Signed-off-by: Jeff Layton > --- > fs/crypto/Kconfig | 1 + > fs/crypto/fname.c | 64 ++------------------------------ > include/linux/base64_fname.h | 11 ++++++ > lib/Kconfig | 3 ++ > lib/Makefile | 1 + > lib/base64_fname.c | 71 ++++++++++++++++++++++++++++++++++++ > 6 files changed, 90 insertions(+), 61 deletions(-) > create mode 100644 include/linux/base64_fname.h > create mode 100644 lib/base64_fname.c > I'm still concerned that this functionality is too specific to belong in lib/ at the moment, given that it's not the most commonly used variant of base64. How about keeping these functions in fs/crypto/ for now? You can call them fscrypt_base64_encode() and fscrypt_base64_decode() and export them for ceph to use. > diff --git a/lib/base64_fname.c b/lib/base64_fname.c > new file mode 100644 > index 000000000000..7638c45e4035 > --- /dev/null > +++ b/lib/base64_fname.c > @@ -0,0 +1,71 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Modified base64 encode/decode functions, suitable for use as filename components. > + * > + * Originally lifted from fs/crypto/fname.c > + * > + * Copyright (C) 2015, Jaegeuk Kim > + * Copyright (C) 2015, Eric Biggers > + */ Please don't change the copyright statements. The original file had: * Copyright (C) 2015, Google, Inc. * Copyright (C) 2015, Motorola Mobility - Eric