From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C9D2218EBA; Thu, 20 Aug 2026 17:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787247053; cv=none; b=XxyhPmcdgnmsrBZ9P4FYshx9pwJLqcVw6yLmNNuSMh0S+SlYMyuQpb3lN7aD95QGF4gdIW3UI5wwUsKNWiQiGV0YfV/BfMPZoOHeeFFvhyVsU0rUafosvnFB0PXeQOET3/w1THDebacIUZlSJ26zEowVfAEMXoJxQXFYCGc8f2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787247053; c=relaxed/simple; bh=Z6sgaFLxkB36IxYwzW0kO+Ss7EJ6c5Mo2ELdNzs5LXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UA3/rZCHPzze7pTmSgXhnd4bBh3CyIryT54lvtRoS9+ZHbi0KOfsf8qY7EkqN7eeon+/xbCeiJm0zE+m5JyHDirWV5Tz2uDg2GheBacLA+LTnAKhfvenoLGGM7WFlwepyQS+ho8YjsK8SKXlpG9KdGOueiYMDsRQOG7qEGcH8PA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fDpZ3i6N; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fDpZ3i6N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A80561F00A3A; Thu, 20 Aug 2026 17:30:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1787247052; bh=mwO5wjYzXnY4r/7tMnBtAC6zvF4EXwhkq4V+Gj8FB2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fDpZ3i6NIrpxvR38Q6O9FbUZq4LU90HettsY6wBO+DnKZL//Vf9r3iq8bNSawJQU1 yMvqhqjCl5bT/pzvpR/HJDx2o9I7ol/UDS3vm5hRuvmpHPJBJih5jXR82//qnsTTqc IG2AC4PuUbT03Kp2Uxc2h7jz4Ykar8YXzaopol04= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ChenXiaoSong , ZhangGuoDong , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.12 131/220] smb: move get_rfc1002_len() to common/smbglob.h Date: Thu, 20 Aug 2026 16:55:21 +0200 Message-ID: <20260820145227.404537719@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260820145223.480031205@linuxfoundation.org> References: <20260820145223.480031205@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: ZhangGuoDong [ Upstream commit 36c31540cf5279262bfd148d8537cd04866499f2 ] Rename get_rfc1002_length() to get_rfc1002_len(), then move duplicate definitions to common header file. Co-developed-by: ChenXiaoSong Signed-off-by: ChenXiaoSong Signed-off-by: ZhangGuoDong Acked-by: Namjae Jeon Signed-off-by: Steve French Stable-dep-of: cfc0b8e5080a ("ksmbd: validate minimum PDU size for transform requests") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/cifsglob.h | 6 ------ fs/smb/client/cifssmb.c | 6 +++--- fs/smb/client/connect.c | 2 +- fs/smb/client/transport.c | 8 ++++---- fs/smb/common/cifsglob.h | 5 +++++ fs/smb/server/smb_common.h | 5 ----- 6 files changed, 13 insertions(+), 19 deletions(-) --- a/fs/smb/client/cifsglob.h +++ b/fs/smb/client/cifsglob.h @@ -643,12 +643,6 @@ struct cifs_mnt_data { int flags; }; -static inline unsigned int -get_rfc1002_length(void *buf) -{ - return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; -} - struct TCP_Server_Info { struct list_head tcp_ses_list; struct list_head smb_ses_list; --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -597,7 +597,7 @@ CIFSSMBEcho(struct TCP_Server_Info *serv iov[0].iov_len = 4; iov[0].iov_base = smb; - iov[1].iov_len = get_rfc1002_length(smb); + iov[1].iov_len = get_rfc1002_len(smb); iov[1].iov_base = (char *)smb + 4; rc = cifs_call_async(server, &rqst, NULL, cifs_echo_callback, NULL, @@ -1387,7 +1387,7 @@ cifs_async_readv(struct cifs_io_subreque rdata->iov[0].iov_base = smb; rdata->iov[0].iov_len = 4; rdata->iov[1].iov_base = (char *)smb + 4; - rdata->iov[1].iov_len = get_rfc1002_length(smb); + rdata->iov[1].iov_len = get_rfc1002_len(smb); rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive, cifs_readv_callback, NULL, rdata, 0, NULL); @@ -1743,7 +1743,7 @@ cifs_async_writev(struct cifs_io_subrequ /* 4 for RFC1001 length + 1 for BCC */ iov[0].iov_len = 4; iov[0].iov_base = smb; - iov[1].iov_len = get_rfc1002_length(smb) + 1; + iov[1].iov_len = get_rfc1002_len(smb) + 1; iov[1].iov_base = (char *)smb + 4; rqst.rq_iov = iov; --- a/fs/smb/client/connect.c +++ b/fs/smb/client/connect.c @@ -1213,7 +1213,7 @@ cifs_demultiplex_thread(void *p) * The right amount was read from socket - 4 bytes, * so we can now interpret the length field. */ - pdu_length = get_rfc1002_length(buf); + pdu_length = get_rfc1002_len(buf); cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length); if (!is_smb_response(server, buf[0])) --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -886,7 +886,7 @@ SendReceiveNoRsp(const unsigned int xid, int resp_buf_type; iov[0].iov_base = in_buf; - iov[0].iov_len = get_rfc1002_length(in_buf) + 4; + iov[0].iov_len = get_rfc1002_len(in_buf) + 4; flags |= CIFS_NO_RSP_BUF; rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov); cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc); @@ -946,7 +946,7 @@ int cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, bool log_error) { - unsigned int len = get_rfc1002_length(mid->resp_buf) + 4; + unsigned int len = get_rfc1002_len(mid->resp_buf) + 4; dump_smb(mid->resp_buf, min_t(u32, 92, len)); @@ -1466,7 +1466,7 @@ SendReceive(const unsigned int xid, stru goto out; } - *pbytes_returned = get_rfc1002_length(midQ->resp_buf); + *pbytes_returned = get_rfc1002_len(midQ->resp_buf); memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); rc = cifs_check_receive(midQ, server, 0); out: @@ -1651,7 +1651,7 @@ SendReceiveBlockingLock(const unsigned i goto out; } - *pbytes_returned = get_rfc1002_length(midQ->resp_buf); + *pbytes_returned = get_rfc1002_len(midQ->resp_buf); memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4); rc = cifs_check_receive(midQ, server, 0); out: --- a/fs/smb/common/cifsglob.h +++ b/fs/smb/common/cifsglob.h @@ -40,6 +40,11 @@ struct smb_version_values { size_t create_posix_size; }; +static inline unsigned int get_rfc1002_len(void *buf) +{ + return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; +} + static inline void inc_rfc1001_len(void *buf, int count) { be32_add_cpu((__be32 *)buf, count); --- a/fs/smb/server/smb_common.h +++ b/fs/smb/server/smb_common.h @@ -421,9 +421,4 @@ unsigned int ksmbd_server_side_copy_max_ unsigned int ksmbd_server_side_copy_max_total_size(void); bool is_asterisk(char *p); __le32 smb_map_generic_desired_access(__le32 daccess); - -static inline unsigned int get_rfc1002_len(void *buf) -{ - return be32_to_cpu(*((__be32 *)buf)) & 0xffffff; -} #endif /* __SMB_COMMON_H__ */