Skip to contentSkip to conversation

ksmbd: implement error handling for STATUS_INFO_LENGTH_MISMATCH in smb server

PATCH Namjae Jeon 1 participant 1 message Nov 18, 2025 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Namjae Jeon

author maintainer Applied
#1 lore raw
Quoted 6 lines · Aaditya Kansal

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.

Quoted 6 lines

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.

Applied it to #ksmbd-for-next-next.
Please add cc linux-cifs mailing list next time.
Thanks!

Quoted 107 lines
---
 fs/smb/server/smb2pdu.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
fs/smb/server/smb2pdu.c +11 -11
index f901ae18e68a..d79a08378965 100644
@@ -6396,7 +6396,6 @@ static int set_file_mode_info(struct ksmbd_file *fp,
  * @share:     ksmbd_share_config pointer
  *
  * Return:     0 on success, otherwise error
- * TODO: need to implement an error handling for STATUS_INFO_LENGTH_MISMATCH
  */
 static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
                              struct smb2_set_info_req *req,
@@ -6409,14 +6408,14 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_BASIC_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_basic_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_file_basic_info(fp, (struct smb2_file_basic_info *)buffer, share);
        }
        case FILE_ALLOCATION_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_alloc_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_file_allocation_info(work, fp,
                                                (struct smb2_file_alloc_info *)buffer);
@@ -6424,7 +6423,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_END_OF_FILE_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_eof_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_end_of_file_info(work, fp,
                                            (struct smb2_file_eof_info *)buffer);
@@ -6432,7 +6431,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_RENAME_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_rename_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_rename_info(work, fp,
                                       (struct smb2_file_rename_info *)buffer,
@@ -6441,7 +6440,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_LINK_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_link_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return smb2_create_link(work, work->tcon->share_conf,
                                        (struct smb2_file_link_info *)buffer,
@@ -6451,7 +6450,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_DISPOSITION_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_disposition_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_file_disposition_info(fp,
                                                 (struct smb2_file_disposition_info *)buffer);
@@ -6465,7 +6464,7 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
                }
 
                if (buf_len < sizeof(struct smb2_ea_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return smb2_set_ea((struct smb2_ea_info *)buffer,
                                   buf_len, &fp->filp->f_path, true);
@@ -6473,14 +6472,14 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
        case FILE_POSITION_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_pos_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_file_position_info(fp, (struct smb2_file_pos_info *)buffer);
        }
        case FILE_MODE_INFORMATION:
        {
                if (buf_len < sizeof(struct smb2_file_mode_info))
-                       return -EINVAL;
+                       return -EMSGSIZE;
 
                return set_file_mode_info(fp, (struct smb2_file_mode_info *)buffer);
        }
@@ -6587,6 +6586,8 @@ int smb2_set_info(struct ksmbd_work *work)
                rsp->hdr.Status = STATUS_ACCESS_DENIED;
        else if (rc == -EINVAL)
                rsp->hdr.Status = STATUS_INVALID_PARAMETER;
+       else if (rc == -EMSGSIZE)
+               rsp->hdr.Status = STATUS_INFO_LENGTH_MISMATCH;
        else if (rc == -ESHARE)
                rsp->hdr.Status = STATUS_SHARING_VIOLATION;
        else if (rc == -ENOENT)
--

2.51.1