提交 ee4f330b 编写于 作者: S Steve French 提交者: Zheng Zengkai

smb3: check xattr value length earlier

stable inclusion
from stable-v5.10.138
commit 52a408548ab3bd76315f4dc1427430ba0923bf22
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I60QFD

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=52a408548ab3bd76315f4dc1427430ba0923bf22

--------------------------------

[ Upstream commit 5fa2cffb ]

Coverity complains about assigning a pointer based on
value length before checking that value length goes
beyond the end of the SMB.  Although this is even more
unlikely as value length is a single byte, and the
pointer is not dereferenced until laterm, it is clearer
to check the lengths first.

Addresses-Coverity: 1467704 ("Speculative execution data leak")
Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 30a9579f
...@@ -1000,9 +1000,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, ...@@ -1000,9 +1000,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
size_t name_len, value_len, user_name_len; size_t name_len, value_len, user_name_len;
while (src_size > 0) { while (src_size > 0) {
name = &src->ea_data[0];
name_len = (size_t)src->ea_name_length; name_len = (size_t)src->ea_name_length;
value = &src->ea_data[src->ea_name_length + 1];
value_len = (size_t)le16_to_cpu(src->ea_value_length); value_len = (size_t)le16_to_cpu(src->ea_value_length);
if (name_len == 0) if (name_len == 0)
...@@ -1014,6 +1012,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size, ...@@ -1014,6 +1012,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
goto out; goto out;
} }
name = &src->ea_data[0];
value = &src->ea_data[src->ea_name_length + 1];
if (ea_name) { if (ea_name) {
if (ea_name_len == name_len && if (ea_name_len == name_len &&
memcmp(ea_name, name, name_len) == 0) { memcmp(ea_name, name, name_len) == 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册