Skip to content

Commit ecdba23

Browse files
smfrenchgregkh
authored andcommitted
smb3: check xattr value length earlier
[ Upstream commit 5fa2cff ] 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: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 3c20113 commit ecdba23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/cifs/smb2ops.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,9 +1105,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
11051105
size_t name_len, value_len, user_name_len;
11061106

11071107
while (src_size > 0) {
1108-
name = &src->ea_data[0];
11091108
name_len = (size_t)src->ea_name_length;
1110-
value = &src->ea_data[src->ea_name_length + 1];
11111109
value_len = (size_t)le16_to_cpu(src->ea_value_length);
11121110

11131111
if (name_len == 0)
@@ -1119,6 +1117,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
11191117
goto out;
11201118
}
11211119

1120+
name = &src->ea_data[0];
1121+
value = &src->ea_data[src->ea_name_length + 1];
1122+
11221123
if (ea_name) {
11231124
if (ea_name_len == name_len &&
11241125
memcmp(ea_name, name, name_len) == 0) {

0 commit comments

Comments
 (0)