In the Linux kernel, the following vulnerability has been resolved: smb: client: reject FIND data areas that run past the received response CIFSFindFirst() and CIFSFindNext() take the directory entries of a TRANS2_FIND_FIRST2 or TRANS2_FIND_NEXT2 response from DataOffset for DataCount bytes. validate_t2() bounds DataOffset at 1024 and ParameterCount + DataCount by the byte count, and nothing compares DataOffset + DataCount with the number of bytes SendReceive() copied into the buffer. smb_init() places the request and the response in the same cifs_request allocation and cifs_buf_get() clears only the start of it, so a short response whose data area extends past its end has srch_entries_start point at bytes of the request that was just sent, or at whatever the allocation held before, and those bytes are parsed as directory entries. cifs_readdir() and find_cifs_entry() walk the entries with nxt_dir_entry(), which checks every entry but the first of a response against the end of the SMB; cifs_query_path_info() and cifs_backup_query_path_info() read the first entry with no check at all. Те, кто читает, остаются внутри распределения, но то, что они возвращают, не является частью ответа. Последняя запись, которую LastNameOffset находит относительно области данных, ограничена полученным ответом более раннего патча этой серии, как и каждая запись, которую cifs_fill_dirent() анализирует; сам шаг и две функции запроса не являются.
SMB1 не согласован по умолчанию; достижение этого кода требует явного крепления vers1.0. Отклонить ответ, область данных которого выходит за пределы полученной длины, с -EINVAL, который validate_t2() возвращает для других искаженных ответов транзакций. cifs_query_path_info() и cifs_backup_query_path_info() по-прежнему считывают всю запись из области данных, которая может быть меньше единицы; это не изменяется здесь. Соответствующий сервер не затрагивается.
Блок данных ответа транзакции является частью SMB, поэтому DataOffset + DataCount не может превышать байты smbCalcSize(), которые копирует SendReceive(); coalesce_t2() добавляет каждый вторичный ответ в область данных и добавляет его длину как к DataCount, так и к количеству байтов, которое сохраняет это отношение.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: smb: client: reject FIND data areas that run past the received response CIFSFindFirst() and CIFSFindNext() take the directory entries of a TRANS2_FIND_FIRST2 or TRANS2_FIND_NEXT2 response from DataOffset for DataCount bytes. validate_t2() bounds DataOffset at 1024 and ParameterCount + DataCount by the byte count, and nothing compares DataOffset + DataCount with the number of bytes SendReceive() copied into the buffer. smb_init() places the request and the response in the same cifs_request allocation and cifs_buf_get() clears only the start of it, so a short response whose data area extends past its end has srch_entries_start point at bytes of the request that was just sent, or at whatever the allocation held before, and those bytes are parsed as directory entries. cifs_readdir() and find_cifs_entry() walk the entries with nxt_dir_entry(), which checks every entry but the first of a response against the end of the SMB; cifs_query_path_info() and cifs_backup_query_path_info() read the first entry with no check at all. Those reads stay inside the allocation, but what they return is not part of the response. The last entry, which LastNameOffset locates relative to the data area, is bounded against the received response by an earlier patch of this series, as is every entry that cifs_fill_dirent() parses; the walk itself and the two query functions are not. SMB1 is not negotiated by default; reaching this code requires an explicit vers=1.0 mount. Reject a response whose data area extends past the received length, with the -EINVAL that validate_t2() returns for the other malformed transaction responses. cifs_query_path_info() and cifs_backup_query_path_info() still read a whole entry from a data area that may be smaller than one; that is not changed here. A conforming server is not affected. The data block of a transaction response is part of the SMB, so DataOffset + DataCount cannot exceed the smbCalcSize() bytes that SendReceive() copies; coalesce_t2() appends each secondary response to the data area and adds its length to both DataCount and the byte count, which keeps that relation.