Skip to content

Commit a9f106c

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: fix wrong allocation size update in smb2_open()
When client send SMB2_CREATE_ALLOCATION_SIZE create context, ksmbd update old size to ->AllocationSize in smb2 create response. ksmbd_vfs_getattr() should be called after it to get updated stat result. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 658609d commit a9f106c

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,7 @@ static void smb2_new_xattrs(struct ksmbd_tree_connect *tcon, const struct path *
25162516
da.flags = XATTR_DOSINFO_ATTRIB | XATTR_DOSINFO_CREATE_TIME |
25172517
XATTR_DOSINFO_ITIME;
25182518

2519-
rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da, false);
2519+
rc = ksmbd_vfs_set_dos_attrib_xattr(mnt_idmap(path->mnt), path, &da, true);
25202520
if (rc)
25212521
ksmbd_debug(SMB, "failed to store file attribute into xattr\n");
25222522
}
@@ -3185,23 +3185,6 @@ int smb2_open(struct ksmbd_work *work)
31853185
goto err_out;
31863186
}
31873187

3188-
rc = ksmbd_vfs_getattr(&path, &stat);
3189-
if (rc)
3190-
goto err_out;
3191-
3192-
if (stat.result_mask & STATX_BTIME)
3193-
fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
3194-
else
3195-
fp->create_time = ksmbd_UnixTimeToNT(stat.ctime);
3196-
if (req->FileAttributes || fp->f_ci->m_fattr == 0)
3197-
fp->f_ci->m_fattr =
3198-
cpu_to_le32(smb2_get_dos_mode(&stat, le32_to_cpu(req->FileAttributes)));
3199-
3200-
if (!created)
3201-
smb2_update_xattrs(tcon, &path, fp);
3202-
else
3203-
smb2_new_xattrs(tcon, &path, fp);
3204-
32053188
if (file_present || created)
32063189
ksmbd_vfs_kern_path_unlock(&parent_path, &path);
32073190

@@ -3302,6 +3285,23 @@ int smb2_open(struct ksmbd_work *work)
33023285
}
33033286
}
33043287

3288+
rc = ksmbd_vfs_getattr(&path, &stat);
3289+
if (rc)
3290+
goto err_out1;
3291+
3292+
if (stat.result_mask & STATX_BTIME)
3293+
fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
3294+
else
3295+
fp->create_time = ksmbd_UnixTimeToNT(stat.ctime);
3296+
if (req->FileAttributes || fp->f_ci->m_fattr == 0)
3297+
fp->f_ci->m_fattr =
3298+
cpu_to_le32(smb2_get_dos_mode(&stat, le32_to_cpu(req->FileAttributes)));
3299+
3300+
if (!created)
3301+
smb2_update_xattrs(tcon, &path, fp);
3302+
else
3303+
smb2_new_xattrs(tcon, &path, fp);
3304+
33053305
memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
33063306

33073307
rsp->StructureSize = cpu_to_le16(89);

0 commit comments

Comments
 (0)