2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 20:53:53 +08:00

cifs: protect against server returning invalid file system block size

For a network file system we generally prefer large i/o, but
if the server returns invalid file system block/sector sizes
in cifs (vers=1.0) QFSInfo then set block size to a default
of a reasonable minimum (4K).

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
This commit is contained in:
Steve French 2018-09-15 14:07:09 -05:00
parent 2c887635cd
commit 5a519bead4

View File

@ -5027,6 +5027,13 @@ oldQFSInfoRetry:
le16_to_cpu(response_data->BytesPerSector) * le16_to_cpu(response_data->BytesPerSector) *
le32_to_cpu(response_data-> le32_to_cpu(response_data->
SectorsPerAllocationUnit); SectorsPerAllocationUnit);
/*
* much prefer larger but if server doesn't report
* a valid size than 4K is a reasonable minimum
*/
if (FSData->f_bsize < 512)
FSData->f_bsize = 4096;
FSData->f_blocks = FSData->f_blocks =
le32_to_cpu(response_data->TotalAllocationUnits); le32_to_cpu(response_data->TotalAllocationUnits);
FSData->f_bfree = FSData->f_bavail = FSData->f_bfree = FSData->f_bavail =
@ -5107,6 +5114,13 @@ QFSInfoRetry:
le32_to_cpu(response_data->BytesPerSector) * le32_to_cpu(response_data->BytesPerSector) *
le32_to_cpu(response_data-> le32_to_cpu(response_data->
SectorsPerAllocationUnit); SectorsPerAllocationUnit);
/*
* much prefer larger but if server doesn't report
* a valid size than 4K is a reasonable minimum
*/
if (FSData->f_bsize < 512)
FSData->f_bsize = 4096;
FSData->f_blocks = FSData->f_blocks =
le64_to_cpu(response_data->TotalAllocationUnits); le64_to_cpu(response_data->TotalAllocationUnits);
FSData->f_bfree = FSData->f_bavail = FSData->f_bfree = FSData->f_bavail =
@ -5470,6 +5484,13 @@ QFSPosixRetry:
data_offset); data_offset);
FSData->f_bsize = FSData->f_bsize =
le32_to_cpu(response_data->BlockSize); le32_to_cpu(response_data->BlockSize);
/*
* much prefer larger but if server doesn't report
* a valid size than 4K is a reasonable minimum
*/
if (FSData->f_bsize < 512)
FSData->f_bsize = 4096;
FSData->f_blocks = FSData->f_blocks =
le64_to_cpu(response_data->TotalBlocks); le64_to_cpu(response_data->TotalBlocks);
FSData->f_bfree = FSData->f_bfree =