fs/smb/server/mgmt/user_session.c
Source file repositories/reference/linux-study-clean/fs/smb/server/mgmt/user_session.c
File Facts
- System
- Linux kernel
- Corpus path
fs/smb/server/mgmt/user_session.c- Extension
.c- Size
- 17658 bytes
- Lines
- 728
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hlinux/slab.hlinux/rwsem.hlinux/xarray.hksmbd_ida.huser_session.huser_config.htree_connect.hshare_config.h../transport_ipc.h../connection.h../vfs_cache.h../misc.h../stats.h
Detected Declarations
struct ksmbd_session_rpcfunction show_proc_sessionfunction ksmbd_proc_show_flag_namesfunction ksmbd_proc_show_const_namefunction create_proc_sessionfunction delete_proc_sessionfunction show_proc_sessionsfunction xa_for_eachfunction create_proc_sessionsfunction create_proc_sessionsfunction create_proc_sessionfunction delete_proc_sessionfunction __session_rpc_closefunction ksmbd_session_rpc_clear_listfunction __rpc_methodfunction ksmbd_session_rpc_openfunction ksmbd_session_rpc_closefunction ksmbd_session_rpc_methodfunction ksmbd_session_destroyfunction hash_for_each_possiblefunction ksmbd_expire_sessionfunction ksmbd_session_registerfunction ksmbd_chann_delfunction ksmbd_sessions_deregisterfunction hash_for_each_safefunction xa_for_eachfunction is_ksmbd_session_in_connectionfunction ksmbd_user_session_getfunction ksmbd_user_session_putfunction destroy_previous_sessionfunction ksmbd_preauth_session_id_matchfunction list_for_each_entryfunction __init_smb2_sessionfunction ksmbd_acquire_tree_conn_idfunction ksmbd_release_tree_conn_id
Annotated Snippet
struct ksmbd_session_rpc {
int id;
unsigned int method;
};
#ifdef CONFIG_PROC_FS
static const struct ksmbd_const_name ksmbd_sess_cap_const_names[] = {
{SMB2_GLOBAL_CAP_DFS, "dfs"},
{SMB2_GLOBAL_CAP_LEASING, "lease"},
{SMB2_GLOBAL_CAP_LARGE_MTU, "large-mtu"},
{SMB2_GLOBAL_CAP_MULTI_CHANNEL, "multi-channel"},
{SMB2_GLOBAL_CAP_PERSISTENT_HANDLES, "persistent-handles"},
{SMB2_GLOBAL_CAP_DIRECTORY_LEASING, "dir-lease"},
{SMB2_GLOBAL_CAP_ENCRYPTION, "encryption"}
};
static const struct ksmbd_const_name ksmbd_cipher_const_names[] = {
{le16_to_cpu(SMB2_ENCRYPTION_AES128_CCM), "aes128-ccm"},
{le16_to_cpu(SMB2_ENCRYPTION_AES128_GCM), "aes128-gcm"},
{le16_to_cpu(SMB2_ENCRYPTION_AES256_CCM), "aes256-ccm"},
{le16_to_cpu(SMB2_ENCRYPTION_AES256_GCM), "aes256-gcm"},
};
static const struct ksmbd_const_name ksmbd_signing_const_names[] = {
{SIGNING_ALG_HMAC_SHA256, "hmac-sha256"},
{SIGNING_ALG_AES_CMAC, "aes-cmac"},
{SIGNING_ALG_AES_GMAC, "aes-gmac"},
};
static const char *session_state_string(struct ksmbd_session *session)
{
switch (session->state) {
case SMB2_SESSION_VALID:
return "valid";
case SMB2_SESSION_IN_PROGRESS:
return "progress";
case SMB2_SESSION_EXPIRED:
return "expired";
default:
return "";
}
}
static const char *session_user_name(struct ksmbd_session *session)
{
if (user_guest(session->user))
return "(Guest)";
else if (ksmbd_anonymous_user(session->user))
return "(Anonymous)";
return session->user->name;
}
static int show_proc_session(struct seq_file *m, void *v)
{
struct ksmbd_session *sess;
struct ksmbd_tree_connect *tree_conn;
struct ksmbd_share_config *share_conf;
struct channel *chan;
unsigned long id;
int i = 0;
sess = (struct ksmbd_session *)m->private;
ksmbd_user_session_get(sess);
i = 0;
down_read(&sess->chann_lock);
xa_for_each(&sess->ksmbd_chann_list, id, chan) {
#if IS_ENABLED(CONFIG_IPV6)
if (chan->conn->inet_addr)
seq_printf(m, "%-20s\t%pI4\n", "client",
&chan->conn->inet_addr);
else
seq_printf(m, "%-20s\t%pI6c\n", "client",
&chan->conn->inet6_addr);
#else
seq_printf(m, "%-20s\t%pI4\n", "client",
&chan->conn->inet_addr);
#endif
seq_printf(m, "%-20s\t%s\n", "user", session_user_name(sess));
seq_printf(m, "%-20s\t%llu\n", "id", sess->id);
seq_printf(m, "%-20s\t%s\n", "state",
session_state_string(sess));
seq_printf(m, "%-20s\t", "capabilities");
ksmbd_proc_show_flag_names(m,
ksmbd_sess_cap_const_names,
ARRAY_SIZE(ksmbd_sess_cap_const_names),
chan->conn->vals->req_capabilities);
Annotation
- Immediate include surface: `linux/list.h`, `linux/slab.h`, `linux/rwsem.h`, `linux/xarray.h`, `ksmbd_ida.h`, `user_session.h`, `user_config.h`, `tree_connect.h`.
- Detected declarations: `struct ksmbd_session_rpc`, `function show_proc_session`, `function ksmbd_proc_show_flag_names`, `function ksmbd_proc_show_const_name`, `function create_proc_session`, `function delete_proc_session`, `function show_proc_sessions`, `function xa_for_each`, `function create_proc_sessions`, `function create_proc_sessions`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.