Skip to content

Commit f268964

Browse files
committed
Merge tag 'v7.0-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French: - Three use after free fixes (in close, in compounded ops, and in tree disconnect) - Multichannel fix - return proper volume identifier (superblock uuid if available) in FS_OBJECT_ID queries * tag 'v7.0-rc4-ksmbd-server-fixes' of git://git.samba.org/ksmbd: ksmbd: fix use-after-free in durable v2 replay of active file handles ksmbd: fix use-after-free of share_conf in compound request ksmbd: use volume UUID in FS_OBJECT_ID_INFORMATION ksmbd: unset conn->binding on failed binding request ksmbd: fix share_conf UAF in tree_conn disconnect
2 parents 0e4f8f1 + b425e4d commit f268964

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

fs/smb/server/mgmt/tree_connect.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ ksmbd_tree_conn_connect(struct ksmbd_work *work, const char *share_name)
102102

103103
void ksmbd_tree_connect_put(struct ksmbd_tree_connect *tcon)
104104
{
105-
if (atomic_dec_and_test(&tcon->refcount))
105+
if (atomic_dec_and_test(&tcon->refcount)) {
106+
ksmbd_share_config_put(tcon->share_conf);
106107
kfree(tcon);
108+
}
107109
}
108110

109111
static int __ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
@@ -113,10 +115,11 @@ static int __ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
113115

114116
ret = ksmbd_ipc_tree_disconnect_request(sess->id, tree_conn->id);
115117
ksmbd_release_tree_conn_id(sess, tree_conn->id);
116-
ksmbd_share_config_put(tree_conn->share_conf);
117118
ksmbd_counter_dec(KSMBD_COUNTER_TREE_CONNS);
118-
if (atomic_dec_and_test(&tree_conn->refcount))
119+
if (atomic_dec_and_test(&tree_conn->refcount)) {
120+
ksmbd_share_config_put(tree_conn->share_conf);
119121
kfree(tree_conn);
122+
}
120123
return ret;
121124
}
122125

fs/smb/server/smb2pdu.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
126126
pr_err("The first operation in the compound does not have tcon\n");
127127
return -EINVAL;
128128
}
129+
if (work->tcon->t_state != TREE_CONNECTED)
130+
return -ENOENT;
129131
if (tree_id != UINT_MAX && work->tcon->id != tree_id) {
130132
pr_err("tree id(%u) is different with id(%u) in first operation\n",
131133
tree_id, work->tcon->id);
@@ -1948,6 +1950,7 @@ int smb2_sess_setup(struct ksmbd_work *work)
19481950
}
19491951
}
19501952
smb2_set_err_rsp(work);
1953+
conn->binding = false;
19511954
} else {
19521955
unsigned int iov_len;
19531956

@@ -2828,7 +2831,11 @@ static int parse_durable_handle_context(struct ksmbd_work *work,
28282831
goto out;
28292832
}
28302833

2831-
dh_info->fp->conn = conn;
2834+
if (dh_info->fp->conn) {
2835+
ksmbd_put_durable_fd(dh_info->fp);
2836+
err = -EBADF;
2837+
goto out;
2838+
}
28322839
dh_info->reconnected = true;
28332840
goto out;
28342841
}
@@ -5452,7 +5459,6 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
54525459
struct smb2_query_info_req *req,
54535460
struct smb2_query_info_rsp *rsp)
54545461
{
5455-
struct ksmbd_session *sess = work->sess;
54565462
struct ksmbd_conn *conn = work->conn;
54575463
struct ksmbd_share_config *share = work->tcon->share_conf;
54585464
int fsinfoclass = 0;
@@ -5589,10 +5595,11 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
55895595

55905596
info = (struct object_id_info *)(rsp->Buffer);
55915597

5592-
if (!user_guest(sess->user))
5593-
memcpy(info->objid, user_passkey(sess->user), 16);
5598+
if (path.mnt->mnt_sb->s_uuid_len == 16)
5599+
memcpy(info->objid, path.mnt->mnt_sb->s_uuid.b,
5600+
path.mnt->mnt_sb->s_uuid_len);
55945601
else
5595-
memset(info->objid, 0, 16);
5602+
memcpy(info->objid, &stfs.f_fsid, sizeof(stfs.f_fsid));
55965603

55975604
info->extended_info.magic = cpu_to_le32(EXTENDED_INFO_MAGIC);
55985605
info->extended_info.version = cpu_to_le32(1);

0 commit comments

Comments
 (0)