From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D10A345729 for ; Sat, 30 May 2026 03:07:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780110426; cv=none; b=WqyCvOVKszoSWE998WKgZT38fNRZ88gw5NPyUpe/kXW4LANhCGjgh6Mx7dgsHRvDMyWk3G5xc4qLsz2RxWueBDkL/M+zYYG40AD0kx9cY+Bzwsmx2DEZeh6F3SQ6f8DbDXkljhr1OmA2ZcocNs2tlLqUhvGSmsR/w93v57Q4AbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780110426; c=relaxed/simple; bh=Gl+oNEFXUYg1MXuvkfTeuMhC0a+ImFlx8zDMo2wS+O8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AqncEC5xI/JkUksXQytPiO2coZCfnXRmY2ZVNTPL0SAXsXTio1IvSEfwQyDPsErCKebPAF5zd1yOZf/V5jetdG8Ck3ggtIGoLjMzui/XgKydr76nKsH2VwaVhshv3YY/Fbb7iczbxmEGPpUDAY/uNkbCbGa70dmZpMq5UX2Kju8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AExovxBo; arc=none smtp.client-ip=209.85.161.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AExovxBo" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-6949192b840so4120816eaf.3 for ; Fri, 29 May 2026 20:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780110424; x=1780715224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A5nVQSaa/q2GpmFlwFp6psfjVa3qOQkwnv2EF2O6PJg=; b=AExovxBoNPBzcVs3NHD25Ng9o0Cseqmq850y1lTlQDUVo5jFmr4U/JCvGWl9yCe0x6 7gPq7q/Yq8CdxdxhhpOLykCAJP2tEmv/D6GD2voSY/AfTZ0mXQidRTA90R0HtQvRW0LQ jdBlh6xoXQGR7ezzU+grOip22XBeNXR7V9ytjvHD9Z140ZJeBv0XAdGJ/sm6Qn5W0PyH qR0CPpl59DWesGqGsn+/+mR8hk4q9nAIOslpdeayUvPGpfx9aHg9HZgGiU/8wv9XQxAu ydS+e18f2lfEPrLT+fld10eC/rxoiBr7qO0WiPMow433nVGB2HjJxmhwYWjIoG1SRZ/E iZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780110424; x=1780715224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A5nVQSaa/q2GpmFlwFp6psfjVa3qOQkwnv2EF2O6PJg=; b=rsZ+mfQuKYl8tnMiPDS3YoLeX1PiEc6ZJq2iux6N3Rw/lRKI4aMLw6KVjAzvUNQzlV EcBvI77WTHe8RBUeG2wV6ti5sifn/O9VRTZo9UeV4x0zLEDIsg+bgPWDcf72acs7X9Aq cG0WlzWjhiYVtN4sSxwi5hPCsXYYGVHjxNQTLXxWSDK1ghZ1YSO3gq6sUPTXn4+iz4k7 zJRhukbry7ZtMqDKCzLFtXRiyUbjGNBM8GWagLVD9V+K3nwdhjCxlmLBOVadL/ZuywoI C26wYIwr49SwqZpGfEXHYORJ28PqulMa7mRs8/pAMxKL48CA2hxnDoUmSJQTuvX893gg rc3A== X-Forwarded-Encrypted: i=1; AFNElJ+jpL0I8PtuJZWEN1F/HTOaqXWo0v8kFGwH8IYJo5sD3Uhm9/xg8/dp0zOUfAHo4830gPMJ4av1UBqySBM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywh7pbRHlEv/D/GnZIM3WqLmIknN9R6b9jSV1rB/Qe7ID5j309O 7QuTjKbzCjhJ2Zyq5uIKPFTi3pyx2OyIHw5H2Itszsx/lC2p0d6QVwaz X-Gm-Gg: Acq92OEvoGiIQEyzvW/Wi3ozq1+r7sPWGk6hdFCOx0iq3tTahtAEU0CLOg3l+iyNzUa irqsZjZulumuWNbrkp9BnFU9TzBqZ0Ng/3LqBmbNXtZnAlvoa1GGdUIi33VWE3w1rtrqDoWSQnO SyW7v0Qv4Tk6PNnz4KITmNpBJGymSygxZMkYAMSMcyzwTmUIkG5EHSgpOxwmO6+i5T6hrFvmagK YfdqUtZO3Qb+EeQ+j95x7/3/EWd+tL7Q1aS8iOmr0i8c9LL03ciWIVfGsughZONXNZZ4peto6uL hIucSScq4+mu/rmHMwjUA6hHmhQQnojHoaCwT0a6QaMfbih2WxJIZHOcfstONzvYkc2uoCh5IeU mWGkmzeaysQgPt5iX+gIRENZqAaS02TAcVZZgW2gZB7j0qEPWvPprN6ECNyinq8nfB9ULQbuOBp 4PK11aq56DwI3KbD9mqIzD5iuoArsTr4UrvqWDKcm5trM50Z31ZHpTA3QC9DrXd4/WzF3oHQ== X-Received: by 2002:a05:6820:4c8a:b0:699:a7d1:5fd5 with SMTP id 006d021491bc7-69e103c26b0mr948441eaf.39.1780110424430; Fri, 29 May 2026 20:07:04 -0700 (PDT) Received: from localhost (static-23-234-115-121.cust.tzulo.com. [23.234.115.121]) by smtp.gmail.com with UTF8SMTPSA id 006d021491bc7-69e06854390sm2374443eaf.8.2026.05.29.20.07.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 May 2026 20:07:04 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Ilya Dryomov , Alex Markuze , Viacheslav Dubeyko Cc: Jeff Layton , Xiubo Li , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH v2 1/2] ceph: pass fscrypt `tname` buffers directly Date: Fri, 29 May 2026 20:06:45 -0700 Message-ID: <20260530030646.85589-2-CFSworks@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530030646.85589-1-CFSworks@gmail.com> References: <20260530030646.85589-1-CFSworks@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ceph_fname_to_usr() needs a temporary buffer for some operations (currently only base64-decoding ciphertext) and it is convenient to allow the caller to specify this buffer to avoid a heap allocation, so it has a (nullable) `tname` argument. Until now, this argument was a `struct fscrypt_str`; however, this is unnecessary for two reasons: 1. `tname->len` isn't used anywhere: ceph_fname_to_usr() assumes a buffer large enough to hold the ciphertext, and parse_reply_info_readdir() -- the only caller to use tname -- doesn't set it. 2. While the `tname` parameter is documented "may be NULL," parse_reply_info_readdir() always passes it but with `tname->name` sometimes NULL in violation of the contract, indicating that the unnecessary container creates actual confusion. Therefore, change the type to `unsigned char *` and pass the buffer directly. Signed-off-by: Sam Edwards --- fs/ceph/crypto.c | 9 ++++----- fs/ceph/crypto.h | 4 ++-- fs/ceph/mds_client.c | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index 64d240759277..7493a3acd7d0 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -300,7 +300,7 @@ int ceph_encode_encrypted_dname(struct inode *parent, char *buf, int elen) * * Returns 0 on success or negative error code on error. */ -int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, +int ceph_fname_to_usr(const struct ceph_fname *fname, unsigned char *tname, struct fscrypt_str *oname, bool *is_nokey) { struct inode *dir = fname->dir; @@ -357,16 +357,15 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, ret = fscrypt_fname_alloc_buffer(NAME_MAX, &_tname); if (ret) goto out_inode; - tname = &_tname; + tname = _tname.name; } - declen = base64_decode(name, name_len, - tname->name, false, BASE64_IMAP); + declen = base64_decode(name, name_len, tname, false, BASE64_IMAP); if (declen <= 0) { ret = -EIO; goto out; } - iname.name = tname->name; + iname.name = tname; iname.len = declen; } else { iname.name = fname->ctext; diff --git a/fs/ceph/crypto.h b/fs/ceph/crypto.h index b748e2060bc9..79cb563fd887 100644 --- a/fs/ceph/crypto.h +++ b/fs/ceph/crypto.h @@ -115,7 +115,7 @@ static inline void ceph_fname_free_buffer(struct inode *parent, fscrypt_fname_free_buffer(fname); } -int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, +int ceph_fname_to_usr(const struct ceph_fname *fname, unsigned char *tname, struct fscrypt_str *oname, bool *is_nokey); int ceph_fscrypt_prepare_readdir(struct inode *dir); @@ -204,7 +204,7 @@ static inline void ceph_fname_free_buffer(struct inode *parent, } static inline int ceph_fname_to_usr(const struct ceph_fname *fname, - struct fscrypt_str *tname, + unsigned char *tname, struct fscrypt_str *oname, bool *is_nokey) { oname->name = fname->name; diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index ed17e0023705..aa6730b48e97 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -488,11 +488,11 @@ static int parse_reply_info_readdir(void **p, void *end, struct inode *inode = d_inode(req->r_dentry); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_mds_reply_dir_entry *rde = info->dir_entries + i; - struct fscrypt_str tname = FSTR_INIT(NULL, 0); struct fscrypt_str oname = FSTR_INIT(NULL, 0); struct ceph_fname fname; u32 altname_len, _name_len; u8 *altname, *_name; + u8 *tname = NULL; /* dentry */ ceph_decode_32_safe(p, end, _name_len, bad); @@ -540,7 +540,7 @@ static int parse_reply_info_readdir(void **p, void *end, * always be shorter, which is 3/4 of origin * string. */ - tname.name = _name; + tname = _name; /* * Set oname to _name too, and this will be @@ -557,7 +557,7 @@ static int parse_reply_info_readdir(void **p, void *end, oname.len = altname_len; } rde->is_nokey = false; - err = ceph_fname_to_usr(&fname, &tname, &oname, &rde->is_nokey); + err = ceph_fname_to_usr(&fname, tname, &oname, &rde->is_nokey); if (err) { pr_err_client(cl, "unable to decode %.*s, got %d\n", _name_len, _name, err); -- 2.53.0