ksmbd: route v2 lease breaks on the client lease channel

v2 leases are scoped by ClientGuid.  When the same client uses multiple
connections, smbtorture expects lease break notifications to be sent on
the connection associated with the client lease table, not necessarily
on the connection that owns the individual open being broken.

Keep a referenced connection in the lease table and use it for v2 lease
break notifications while it is still active.  Fall back to the open's
connection if the table connection is being released.

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Namjae Jeon 2026-06-18 21:33:40 +09:00 committed by Steve French
parent 1f1083c36f
commit 2145945feb
2 changed files with 16 additions and 2 deletions

View File

@ -141,11 +141,21 @@ static struct lease_table *alloc_lease_table(struct oplock_info *opinfo)
memcpy(lb->client_guid, opinfo->conn->ClientGUID,
SMB2_CLIENT_GUID_SIZE);
lb->conn = ksmbd_conn_get(opinfo->conn);
INIT_LIST_HEAD(&lb->lease_list);
spin_lock_init(&lb->lb_lock);
return lb;
}
static void free_lease_table(struct lease_table *lb)
{
if (!lb)
return;
ksmbd_conn_put(lb->conn);
kfree(lb);
}
static struct lease *alloc_lease(struct lease_ctx_info *lctx,
struct ksmbd_inode *ci)
{
@ -942,6 +952,9 @@ static int smb2_lease_break_noti(struct oplock_info *opinfo, bool wait_ack,
struct lease *lease = opinfo->o_lease;
conn = READ_ONCE(opinfo->conn);
if (lease->version == 2 && lease->l_lb && lease->l_lb->conn &&
!ksmbd_conn_releasing(lease->l_lb->conn))
conn = lease->l_lb->conn;
if (!conn)
return 0;
@ -1134,7 +1147,7 @@ void destroy_lease_table(struct ksmbd_conn *conn)
list_for_each_entry_safe(lease, ltmp, &lb->lease_list, l_entry)
lease_del_table(lease);
list_del(&lb->l_entry);
kfree(lb);
free_lease_table(lb);
}
write_unlock(&lease_list_lock);
}
@ -1193,7 +1206,7 @@ static void add_lease_global_list(struct lease *lease, struct ksmbd_conn *conn,
SMB2_CLIENT_GUID_SIZE)) {
lease_add_table(lease, lb);
write_unlock(&lease_list_lock);
kfree(new_lb);
free_lease_table(new_lb);
return;
}
}

View File

@ -34,6 +34,7 @@ struct lease_ctx_info {
struct lease_table {
char client_guid[SMB2_CLIENT_GUID_SIZE];
struct ksmbd_conn *conn;
struct list_head lease_list;
struct list_head l_entry;
spinlock_t lb_lock;