mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-25 08:33:21 -04:00
ksmbd: use connection ClientGUID for lease lookup
MS-SMB2 defines the lease table lookup key as Connection.ClientGuid. Use the connection ClientGUID consistently when checking for same-client leases and duplicate lease keys. Also preserve directory and parent lease metadata when copying an existing lease state to a new open. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
committed by
Steve French
parent
b69be2c586
commit
fa111daae1
@@ -520,7 +520,7 @@ static inline int compare_guid_key(struct oplock_info *opinfo,
|
||||
* Return: oplock(lease) object on success, otherwise NULL
|
||||
*/
|
||||
static struct oplock_info *same_client_has_lease(struct ksmbd_inode *ci,
|
||||
char *client_guid,
|
||||
const char *client_guid,
|
||||
struct lease_ctx_info *lctx)
|
||||
{
|
||||
int ret;
|
||||
@@ -1012,7 +1012,7 @@ void destroy_lease_table(struct ksmbd_conn *conn)
|
||||
write_unlock(&lease_list_lock);
|
||||
}
|
||||
|
||||
int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
|
||||
int find_same_lease_key(struct ksmbd_conn *conn, struct ksmbd_inode *ci,
|
||||
struct lease_ctx_info *lctx)
|
||||
{
|
||||
struct oplock_info *opinfo;
|
||||
@@ -1029,7 +1029,7 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
|
||||
}
|
||||
|
||||
list_for_each_entry(lb, &lease_table_list, l_entry) {
|
||||
if (!memcmp(lb->client_guid, sess->ClientGUID,
|
||||
if (!memcmp(lb->client_guid, conn->ClientGUID,
|
||||
SMB2_CLIENT_GUID_SIZE))
|
||||
goto found;
|
||||
}
|
||||
@@ -1045,7 +1045,7 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
|
||||
rcu_read_unlock();
|
||||
if (opinfo->o_fp->f_ci == ci)
|
||||
goto op_next;
|
||||
err = compare_guid_key(opinfo, sess->ClientGUID,
|
||||
err = compare_guid_key(opinfo, conn->ClientGUID,
|
||||
lctx->lease_key);
|
||||
if (err) {
|
||||
err = -EINVAL;
|
||||
@@ -1078,6 +1078,9 @@ static void copy_lease(struct oplock_info *op1, struct oplock_info *op2)
|
||||
lease2->flags = lease1->flags;
|
||||
lease2->epoch = lease1->epoch;
|
||||
lease2->version = lease1->version;
|
||||
lease2->is_dir = lease1->is_dir;
|
||||
memcpy(lease2->parent_lease_key, lease1->parent_lease_key,
|
||||
SMB2_LEASE_KEY_SIZE);
|
||||
}
|
||||
|
||||
static void add_lease_global_list(struct oplock_info *opinfo,
|
||||
@@ -1216,7 +1219,6 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
|
||||
struct ksmbd_file *fp, __u16 tid,
|
||||
struct lease_ctx_info *lctx, int share_ret)
|
||||
{
|
||||
struct ksmbd_session *sess = work->sess;
|
||||
int err = 0;
|
||||
struct oplock_info *opinfo = NULL, *prev_opinfo = NULL;
|
||||
struct ksmbd_inode *ci = fp->f_ci;
|
||||
@@ -1259,12 +1261,12 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
|
||||
struct oplock_info *m_opinfo;
|
||||
|
||||
/* is lease already granted ? */
|
||||
m_opinfo = same_client_has_lease(ci, sess->ClientGUID,
|
||||
m_opinfo = same_client_has_lease(ci, work->conn->ClientGUID,
|
||||
lctx);
|
||||
if (m_opinfo) {
|
||||
copy_lease(m_opinfo, opinfo);
|
||||
if (atomic_read(&m_opinfo->breaking_cnt))
|
||||
opinfo->o_lease->flags =
|
||||
opinfo->o_lease->flags |=
|
||||
SMB2_LEASE_FLAG_BREAK_IN_PROGRESS_LE;
|
||||
opinfo_put(m_opinfo);
|
||||
goto out;
|
||||
|
||||
@@ -116,7 +116,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp);
|
||||
struct create_context *smb2_find_context_vals(void *open_req, const char *tag, int tag_len);
|
||||
struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,
|
||||
char *lease_key);
|
||||
int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
|
||||
int find_same_lease_key(struct ksmbd_conn *conn, struct ksmbd_inode *ci,
|
||||
struct lease_ctx_info *lctx);
|
||||
void destroy_lease_table(struct ksmbd_conn *conn);
|
||||
void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,
|
||||
|
||||
@@ -3637,7 +3637,7 @@ int smb2_open(struct ksmbd_work *work)
|
||||
ksmbd_debug(SMB,
|
||||
"lease req for(%s) req oplock state 0x%x, lease state 0x%x\n",
|
||||
name, req_op_level, lc->req_state);
|
||||
rc = find_same_lease_key(sess, fp->f_ci, lc);
|
||||
rc = find_same_lease_key(conn, fp->f_ci, lc);
|
||||
if (rc)
|
||||
goto err_out1;
|
||||
} else if (open_flags == O_RDONLY &&
|
||||
|
||||
Reference in New Issue
Block a user