Skip to content

Commit e4442b2

Browse files
Nightfire390smfrench
authored andcommitted
ksmbd: implement error handling for STATUS_INFO_LENGTH_MISMATCH in smb server
Add STATUS_INFO_LENGTH_MISMATCH mapping to EMSGSIZE. Currently, STATUS_INFO_LENGTH_MISMATCH has no mapping to any error code, making it difficult to distinguish between invalid parameters and length mismatch. Map STATUS_INFO_LENGTH_MISMATCH to EMSGSIZE while keeping the EINVAL for invalid parameters. Although the buf_len check only checks for buf_size being less than required, there was no error code for lower buf_size. Hence, EMSGSIZE is used. Signed-off-by: Aaditya Kansal <aadityakansal390@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent b39a183 commit e4442b2

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6383,7 +6383,6 @@ static int set_file_mode_info(struct ksmbd_file *fp,
63836383
* @share: ksmbd_share_config pointer
63846384
*
63856385
* Return: 0 on success, otherwise error
6386-
* TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH
63876386
*/
63886387
static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
63896388
struct smb2_set_info_req *req,
@@ -6396,30 +6395,30 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
63966395
case FILE_BASIC_INFORMATION:
63976396
{
63986397
if (buf_len < sizeof(struct smb2_file_basic_info))
6399-
return -EINVAL;
6398+
return -EMSGSIZE;
64006399

64016400
return set_file_basic_info(fp, (struct smb2_file_basic_info *)buffer, share);
64026401
}
64036402
case FILE_ALLOCATION_INFORMATION:
64046403
{
64056404
if (buf_len < sizeof(struct smb2_file_alloc_info))
6406-
return -EINVAL;
6405+
return -EMSGSIZE;
64076406

64086407
return set_file_allocation_info(work, fp,
64096408
(struct smb2_file_alloc_info *)buffer);
64106409
}
64116410
case FILE_END_OF_FILE_INFORMATION:
64126411
{
64136412
if (buf_len < sizeof(struct smb2_file_eof_info))
6414-
return -EINVAL;
6413+
return -EMSGSIZE;
64156414

64166415
return set_end_of_file_info(work, fp,
64176416
(struct smb2_file_eof_info *)buffer);
64186417
}
64196418
case FILE_RENAME_INFORMATION:
64206419
{
64216420
if (buf_len < sizeof(struct smb2_file_rename_info))
6422-
return -EINVAL;
6421+
return -EMSGSIZE;
64236422

64246423
return set_rename_info(work, fp,
64256424
(struct smb2_file_rename_info *)buffer,
@@ -6428,7 +6427,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
64286427
case FILE_LINK_INFORMATION:
64296428
{
64306429
if (buf_len < sizeof(struct smb2_file_link_info))
6431-
return -EINVAL;
6430+
return -EMSGSIZE;
64326431

64336432
return smb2_create_link(work, work->tcon->share_conf,
64346433
(struct smb2_file_link_info *)buffer,
@@ -6438,7 +6437,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
64386437
case FILE_DISPOSITION_INFORMATION:
64396438
{
64406439
if (buf_len < sizeof(struct smb2_file_disposition_info))
6441-
return -EINVAL;
6440+
return -EMSGSIZE;
64426441

64436442
return set_file_disposition_info(fp,
64446443
(struct smb2_file_disposition_info *)buffer);
@@ -6452,22 +6451,22 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
64526451
}
64536452

64546453
if (buf_len < sizeof(struct smb2_ea_info))
6455-
return -EINVAL;
6454+
return -EMSGSIZE;
64566455

64576456
return smb2_set_ea((struct smb2_ea_info *)buffer,
64586457
buf_len, &fp->filp->f_path, true);
64596458
}
64606459
case FILE_POSITION_INFORMATION:
64616460
{
64626461
if (buf_len < sizeof(struct smb2_file_pos_info))
6463-
return -EINVAL;
6462+
return -EMSGSIZE;
64646463

64656464
return set_file_position_info(fp, (struct smb2_file_pos_info *)buffer);
64666465
}
64676466
case FILE_MODE_INFORMATION:
64686467
{
64696468
if (buf_len < sizeof(struct smb2_file_mode_info))
6470-
return -EINVAL;
6469+
return -EMSGSIZE;
64716470

64726471
return set_file_mode_info(fp, (struct smb2_file_mode_info *)buffer);
64736472
}
@@ -6574,6 +6573,8 @@ int smb2_set_info(struct ksmbd_work *work)
65746573
rsp->hdr.Status = STATUS_ACCESS_DENIED;
65756574
else if (rc == -EINVAL)
65766575
rsp->hdr.Status = STATUS_INVALID_PARAMETER;
6576+
else if (rc == -EMSGSIZE)
6577+
rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH;
65776578
else if (rc == -ESHARE)
65786579
rsp->hdr.Status = STATUS_SHARING_VIOLATION;
65796580
else if (rc == -ENOENT)

0 commit comments

Comments
 (0)