[PATCH 3/3] smb: client: use unaligned read for POSIX info name length

Ren Wei <[email protected]>
Newsgroups org.kernel.vger.linux-cifs
Message-ID <d1893e4279c8c53777eeb1bbc018b0bdbb36f471.1782898568.git.xizh2024@lzu.edu.cn>
From: Zihan Xi <[email protected]>

posix_info_parse() reads the trailing name length via an aligned le32
cast at beg + total_len. Owner and group SID sizes are variable, so
that offset may be misaligned on strict-alignment architectures.

Fixes: 349e13ad30b4 ("cifs: add smb2 POSIX info level")
Cc: [email protected]
Signed-off-by: Zihan Xi <[email protected]>
Signed-off-by: Ren Wei <[email protected]>
---
 fs/smb/client/smb2pdu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index ed782d219d55..43d514ee555d 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -5450,7 +5450,7 @@ int posix_info_parse(const void *beg, const void *end,
 	/* check name len */
 	if (beg + total_len + 4 > end)
 		return -1;
-	name_len = le32_to_cpu(*(__le32 *)(beg + total_len));
+	name_len = get_unaligned_le32((u8 *)beg + total_len);
 	if (name_len < 1 || name_len > 0xFFFF)
 		return -1;
 	total_len += 4;
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.