Re: [RFC PATCH v3 12/16] ceph: add encrypted fname handling to ceph_mdsc_build_path

Eric Biggers
2020-09-15T01:42:03Z

On Mon, Sep 14, 2020 at 03:17:03PM -0400, Jeff Layton wrote:
> + } else {
> + int err;
> + struct fscrypt_name fname = { };
> + int len;
> + char buf[FSCRYPT_BASE64_CHARS(NAME_MAX)];
> +
> + dget(parent);
> + spin_unlock(&cur->d_lock);
> +
> + err = fscrypt_setup_filename(d_inode(parent), &cur->d_name, 1, &fname);
> + if (err) {
> + dput(parent);
> + dput(cur);
> + return ERR_PTR(err);
> + }

It's still not clear how no-key names are handled here (or if they are even
possible here).

> +
> + /* base64 encode the encrypted name */
> + len = fscrypt_base64_encode(fname.disk_name.name, fname.disk_name.len, buf);
> + pos -= len;
> + if (pos < 0) {
> + dput(parent);
> + fscrypt_free_filename(&fname);
> + break;
> + }
> + memcpy(path + pos, buf, len);
> + dout("non-ciphertext name = %.*s\n", len, buf);
> + fscrypt_free_filename(&fname);

This says "non-ciphertext name", which suggest that it's a plaintext name. But
actually it's a base64-encoded ciphertext name.

- Eric