ksmbd: fix partial normalized name responses
Subsystems (2)
Namjae Jeon
maintainerPATCH 2/3 ksmbd: fix partial normalized name responses
Windows may request FILE_NORMALIZED_NAME_INFORMATION with an output buffer that only fits the fixed portion of the variable-length response. Treat the fixed portion as FILE_ALTERNATE_NAME_INFORMATION_SIZE so ksmbd returns STATUS_BUFFER_OVERFLOW instead of STATUS_INFO_LENGTH_MISMATCH.
This avoids rejecting valid partial normalized-name responses.
--- fs/smb/server/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/server/smb2pdu.c +3 -0
@@ -7318,6 +7318,9 @@ static int smb2_get_info_file(struct ksmbd_work *work,case FILE_ALTERNATE_NAME_INFORMATION : fixed_len =FILE_ALTERNATE_NAME_INFORMATION_SIZE ;break ; +case FILE_NORMALIZED_NAME_INFORMATION : + fixed_len =FILE_ALTERNATE_NAME_INFORMATION_SIZE ; +break ;case FILE_STREAM_INFORMATION : fixed_len =FILE_STREAM_INFORMATION_SIZE ;break ;
Signature · 1 line
2.25.1
ChenXiaoSong
reviewerShould we define a new macro FILE_NORMALIZED_NAME_INFORMATION_SIZE?
Quoted 2 lines · Namjae Jeon
fs/smb/server/smb2pdu.c +2
-0+case FILE_NORMALIZED_NAME_INFORMATION : + fixed_len =FILE_ALTERNATE_NAME_INFORMATION_SIZE ;
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
Namjae Jeon
maintainerQuoted 2 lines · ChenXiaoSong
Should we define a new macro
FILE_NORMALIZED_NAME_INFORMATION_SIZE?
Okay, I will add it in v2 patch.
Thanks for the review.
ChenXiaoSong
reviewerHi Namjae,
According to MS-FSA 2.1.5.12.30: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/3d5c68f8-fbc5-4f94-a51d-3600a319fd45
Set AvailableNameLength to BlockAlignTruncate((OutputBufferSize -FieldOffset(FILE_NAME_INFORMATION.FileName)), 2).
It seems that the following changes are also needed:
```
smb2_get_info_file()
{
unsigned int req_output_len = le32_to_cpu(req->OutputBufferLength);
...
case FILE_NORMALIZED_NAME_INFORMATION:
fixed_len = FILE_NORMALIZED_NAME_INFORMATION_SIZE;
req_output_len = round_down(req_output_len, 2);
break;
...
rc = buffer_check_err(req_output_len, fixed_len, rsp);
}
```By the way, it seems that struct smb2_file_alt_name_info should be renamed to struct smb2_file_name_info, since both FILE_ALTERNATE_NAME_INFORMATION and FILE_NORMALIZED_NAME_INFORMATION use this structure. See:
- MS-FSA 2.1.5.12.4 FileAlternateNameInformation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/5051d021-8d06-4b7e-94e3-55b118193427
- MS-FSA 2.1.5.12.30 FileNormalizedNameInformation: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/3d5c68f8-fbc5-4f94-a51d-3600a319fd45
Quoted 28 lines · Namjae Jeon
Windows may request
FILE_NORMALIZED_NAME_INFORMATIONwith an output buffer that only fits the fixed portion of the variable-length response. Treat the fixed portion asFILE_ALTERNATE_NAME_INFORMATION_SIZEso ksmbd returnsSTATUS_BUFFER_OVERFLOWinstead ofSTATUS_INFO_LENGTH_MISMATCH.This avoids rejecting valid partial normalized-name responses.
Fixes 6b8b79226bc3 ("ksmbd: fix partial file information responses")Reported-by Mobin Aydinfar <[email protected]>Signed-off-by Namjae Jeon <[email protected]>--- fs/smb/server/smb2pdu.c | 3 +++ 1 file changed, 3 insertions(+)fs/smb/server/smb2pdu.c +3
-0@@ -7318,6 +7318,9 @@ static int smb2_get_info_file(struct ksmbd_work *work,case FILE_ALTERNATE_NAME_INFORMATION : fixed_len =FILE_ALTERNATE_NAME_INFORMATION_SIZE ;break ; +case FILE_NORMALIZED_NAME_INFORMATION : + fixed_len =FILE_ALTERNATE_NAME_INFORMATION_SIZE ; +break ;case FILE_STREAM_INFORMATION : fixed_len =FILE_STREAM_INFORMATION_SIZE ;break ;
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
ChenXiaoSong
reviewerIf needed, I would be happy to help send v2.
And it would be better to use FILE_NAME_INFORMATION_SIZE (should be changed to 8) instead of FILE_ALTERNATE_NAME_INFORMATION_SIZE.
```
smb2_get_info_file()
{
...
case FILE_ALTERNATE_NAME_INFORMATION:
case FILE_NORMALIZED_NAME_INFORMATION:
fixed_len = FILE_NAME_INFORMATION_SIZE; // 8
...
}
```Quoted 28 lines · ChenXiaoSong
Hi Namjae,
According to MS-FSA 2.1.5.12.30: https://learn.microsoft.com/en-us/ openspecs/windows_protocols/ms-fsa/3d5c68f8-fbc5-4f94-a51d-3600a319fd45
Set AvailableNameLength to BlockAlignTruncate((OutputBufferSize -
FieldOffset(FILE_NAME_INFORMATION.FileName)), 2).It seems that the following changes are also needed:
``` smb2_get_info_file() { unsigned int req_output_len = le32_to_cpu(req- >OutputBufferLength); ... case FILE_NORMALIZED_NAME_INFORMATION: fixed_len = FILE_NORMALIZED_NAME_INFORMATION_SIZE; req_output_len = round_down(req_output_len, 2); break; ... rc = buffer_check_err(req_output_len, fixed_len, rsp); } ```By the way, it seems that
struct smb2_file_alt_name_infoshould be renamed tostruct smb2_file_name_info, since bothFILE_ALTERNATE_NAME_INFORMATIONandFILE_NORMALIZED_NAME_INFORMATIONuse this structure. See:
- MS-FSA 2.1.5.12.4 FileAlternateNameInformation: https://
learn.microsoft.com/en-us/openspecs/windows_protocols/ms- fsa/5051d021-8d06-4b7e-94e3-55b118193427
- MS-FSA 2.1.5.12.30 FileNormalizedNameInformation: https://
learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/3d5c68f8- fbc5-4f94-a51d-3600a319fd45
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
Namjae Jeon
maintainerQuoted 24 lines · ChenXiaoSong
Hi Namjae,
According to MS-FSA 2.1.5.12.30:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/3d5c68f8-fbc5-4f94-a51d-3600a319fd45Set AvailableNameLength to BlockAlignTruncate((OutputBufferSize -
FieldOffset(FILE_NAME_INFORMATION.FileName)), 2).It seems that the following changes are also needed:
``` smb2_get_info_file() { unsigned int req_output_len = le32_to_cpu(req->OutputBufferLength); ... case FILE_NORMALIZED_NAME_INFORMATION: fixed_len = FILE_NORMALIZED_NAME_INFORMATION_SIZE; req_output_len = round_down(req_output_len, 2); break; ... rc = buffer_check_err(req_output_len, fixed_len, rsp); } ```
Quoted 8 lines
By the way, it seems that
struct smb2_file_alt_name_infoshould be renamed tostruct smb2_file_name_info, since bothFILE_ALTERNATE_NAME_INFORMATIONandFILE_NORMALIZED_NAME_INFORMATIONuse this structure. See:
- MS-FSA 2.1.5.12.4 FileAlternateNameInformation:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/5051d021-8d06-4b7e-94e3-55b118193427
- MS-FSA 2.1.5.12.30 FileNormalizedNameInformation:
https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fsa/3d5c68f8-fbc5-4f94-a51d-3600a319fd45
I think that both of them are changed in another patches.
ChenXiaoSong
reviewerIt seems that ksmbd-for-next has not been updated yet. Have you not pushed it yet?
Quoted 1 line · Namjae Jeon
I think that both of them are changed in another patches.
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en
Namjae Jeon
maintainerQuoted 3 lines · ChenXiaoSong
It seems that ksmbd-for-next has not been updated yet. Have you not pushed it yet?
Done it now.
Thanks!