Skip to content

Commit 2144da2

Browse files
committed
Merge tag '6.13-rc6-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: "Four ksmbd server fixes, most also for stable: - fix for reporting special file type more accurately when POSIX extensions negotiated - minor cleanup - fix possible incorrect creation path when dirname is not present. In some cases, Windows apps create files without checking if they exist. - fix potential NULL pointer dereference sending interim response" * tag '6.13-rc6-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: Implement new SMB3 POSIX type ksmbd: fix unexpectedly changed path in ksmbd_vfs_kern_path_locked ksmbd: Remove unneeded if check in ksmbd_rdma_capable_netdev() ksmbd: fix a missing return value check bug
2 parents c77cd47 + e8580b4 commit 2144da2

File tree

4 files changed

+56
-3
lines changed

4 files changed

+56
-3
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,9 @@ void smb2_send_interim_resp(struct ksmbd_work *work, __le32 status)
695695
struct smb2_hdr *rsp_hdr;
696696
struct ksmbd_work *in_work = ksmbd_alloc_work_struct();
697697

698+
if (!in_work)
699+
return;
700+
698701
if (allocate_interim_rsp_buf(in_work)) {
699702
pr_err("smb_allocate_rsp_buf failed!\n");
700703
ksmbd_free_work_struct(in_work);
@@ -3991,6 +3994,26 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
39913994
posix_info->DeviceId = cpu_to_le32(ksmbd_kstat->kstat->rdev);
39923995
posix_info->HardLinks = cpu_to_le32(ksmbd_kstat->kstat->nlink);
39933996
posix_info->Mode = cpu_to_le32(ksmbd_kstat->kstat->mode & 0777);
3997+
switch (ksmbd_kstat->kstat->mode & S_IFMT) {
3998+
case S_IFDIR:
3999+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
4000+
break;
4001+
case S_IFLNK:
4002+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
4003+
break;
4004+
case S_IFCHR:
4005+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
4006+
break;
4007+
case S_IFBLK:
4008+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
4009+
break;
4010+
case S_IFIFO:
4011+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
4012+
break;
4013+
case S_IFSOCK:
4014+
posix_info->Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
4015+
}
4016+
39944017
posix_info->Inode = cpu_to_le64(ksmbd_kstat->kstat->ino);
39954018
posix_info->DosAttributes =
39964019
S_ISDIR(ksmbd_kstat->kstat->mode) ?
@@ -5181,6 +5204,26 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
51815204
file_info->AllocationSize = cpu_to_le64(stat.blocks << 9);
51825205
file_info->HardLinks = cpu_to_le32(stat.nlink);
51835206
file_info->Mode = cpu_to_le32(stat.mode & 0777);
5207+
switch (stat.mode & S_IFMT) {
5208+
case S_IFDIR:
5209+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_DIR << POSIX_FILETYPE_SHIFT);
5210+
break;
5211+
case S_IFLNK:
5212+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_SYMLINK << POSIX_FILETYPE_SHIFT);
5213+
break;
5214+
case S_IFCHR:
5215+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_CHARDEV << POSIX_FILETYPE_SHIFT);
5216+
break;
5217+
case S_IFBLK:
5218+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_BLKDEV << POSIX_FILETYPE_SHIFT);
5219+
break;
5220+
case S_IFIFO:
5221+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_FIFO << POSIX_FILETYPE_SHIFT);
5222+
break;
5223+
case S_IFSOCK:
5224+
file_info->Mode |= cpu_to_le32(POSIX_TYPE_SOCKET << POSIX_FILETYPE_SHIFT);
5225+
}
5226+
51845227
file_info->DeviceId = cpu_to_le32(stat.rdev);
51855228

51865229
/*

fs/smb/server/smb2pdu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,4 +502,14 @@ static inline void *smb2_get_msg(void *buf)
502502
return buf + 4;
503503
}
504504

505+
#define POSIX_TYPE_FILE 0
506+
#define POSIX_TYPE_DIR 1
507+
#define POSIX_TYPE_SYMLINK 2
508+
#define POSIX_TYPE_CHARDEV 3
509+
#define POSIX_TYPE_BLKDEV 4
510+
#define POSIX_TYPE_FIFO 5
511+
#define POSIX_TYPE_SOCKET 6
512+
513+
#define POSIX_FILETYPE_SHIFT 12
514+
505515
#endif /* _SMB2PDU_H */

fs/smb/server/transport_rdma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,8 +2283,7 @@ bool ksmbd_rdma_capable_netdev(struct net_device *netdev)
22832283

22842284
ibdev = ib_device_get_by_netdev(netdev, RDMA_DRIVER_UNKNOWN);
22852285
if (ibdev) {
2286-
if (rdma_frwr_is_supported(&ibdev->attrs))
2287-
rdma_capable = true;
2286+
rdma_capable = rdma_frwr_is_supported(&ibdev->attrs);
22882287
ib_device_put(ibdev);
22892288
}
22902289
}

fs/smb/server/vfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,14 +1264,15 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
12641264
filepath,
12651265
flags,
12661266
path);
1267+
if (!is_last)
1268+
next[0] = '/';
12671269
if (err)
12681270
goto out2;
12691271
else if (is_last)
12701272
goto out1;
12711273
path_put(parent_path);
12721274
*parent_path = *path;
12731275

1274-
next[0] = '/';
12751276
remain_len -= filename_len + 1;
12761277
}
12771278

0 commit comments

Comments
 (0)