Skip to content

Commit cffe487

Browse files
Dan Carpentersmfrench
authored andcommitted
cifs: fix underflow in parse_server_interfaces()
In this loop, we step through the buffer and after each item we check if the size_left is greater than the minimum size we need. However, the problem is that "bytes_left" is type ssize_t while sizeof() is type size_t. That means that because of type promotion, the comparison is done as an unsigned and if we have negative bytes left the loop continues instead of ending. Fixes: fe856be ("CIFS: parse and store info on iface queries") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 841c351 commit cffe487

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/smb/client/smb2ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
619619
goto out;
620620
}
621621

622-
while (bytes_left >= sizeof(*p)) {
622+
while (bytes_left >= (ssize_t)sizeof(*p)) {
623623
memset(&tmp_iface, 0, sizeof(tmp_iface));
624624
tmp_iface.speed = le64_to_cpu(p->LinkSpeed);
625625
tmp_iface.rdma_capable = le32_to_cpu(p->Capability & RDMA_CAPABLE) ? 1 : 0;

0 commit comments

Comments
 (0)