Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *   fs/cifs_debug.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *   Copyright (C) International Business Machines  Corp., 2000,2005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *   Modified by Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include "cifspdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include "cifsglob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) #include "cifsproto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include "cifs_debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include "cifsfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include "dfs_cache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include "smbdirect.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) cifs_dump_mem(char *label, void *data, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) 	pr_debug("%s: dump of %d bytes of data at 0x%p\n", label, length, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) 	print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 		       data, length, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) void cifs_dump_detail(void *buf, struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) 	struct smb_hdr *smb = (struct smb_hdr *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 		 smb->Command, smb->Status.CifsError,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) 		 smb->Flags, smb->Flags2, smb->Mid, smb->Pid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) 	cifs_dbg(VFS, "smb buf %p len %u\n", smb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) 		 server->ops->calc_smb_size(smb, server));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) #endif /* CONFIG_CIFS_DEBUG2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) void cifs_dump_mids(struct TCP_Server_Info *server)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) 	struct list_head *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) 	struct mid_q_entry *mid_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 	if (server == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) 	cifs_dbg(VFS, "Dump pending requests:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 	spin_lock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	list_for_each(tmp, &server->pending_mid_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 		cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) 			 mid_entry->mid_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 			 le16_to_cpu(mid_entry->command),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) 			 mid_entry->pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) 			 mid_entry->callback_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) 			 mid_entry->mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) 		cifs_dbg(VFS, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 			 mid_entry->large_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) 			 mid_entry->resp_buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) 			 mid_entry->when_received,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 			 jiffies);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) #endif /* STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 		cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 			 mid_entry->multiRsp, mid_entry->multiEnd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 		if (mid_entry->resp_buf) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) 			cifs_dump_detail(mid_entry->resp_buf, server);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 			cifs_dump_mem("existing buf: ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) 				mid_entry->resp_buf, 62);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) 	spin_unlock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) #endif /* CONFIG_CIFS_DEBUG2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) #ifdef CONFIG_PROC_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) 	__u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) 	seq_printf(m, "%s Mounts: %d ", tcon->treeName, tcon->tc_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) 	if (tcon->nativeFileSystem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 		seq_printf(m, "Type: %s ", tcon->nativeFileSystem);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 	seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 		   le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 		   le32_to_cpu(tcon->fsAttrInfo.Attributes),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 		   le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 		   tcon->tidStatus);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 	if (dev_type == FILE_DEVICE_DISK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 		seq_puts(m, " type: DISK ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) 	else if (dev_type == FILE_DEVICE_CD_ROM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 		seq_puts(m, " type: CDROM ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) 		seq_printf(m, " type: %d ", dev_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	seq_printf(m, "Serial Number: 0x%x", tcon->vol_serial_number);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	if ((tcon->seal) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	    (tcon->ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	    (tcon->share_flags & SHI1005_FLAGS_ENCRYPT_DATA))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) 		seq_printf(m, " Encrypted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 	if (tcon->nocase)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) 		seq_printf(m, " nocase");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) 	if (tcon->unix_ext)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 		seq_printf(m, " POSIX Extensions");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	if (tcon->ses->server->ops->dump_share_caps)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		tcon->ses->server->ops->dump_share_caps(m, tcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) 	if (tcon->need_reconnect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 		seq_puts(m, "\tDISCONNECTED ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) cifs_dump_channel(struct seq_file *m, int i, struct cifs_chan *chan)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	struct TCP_Server_Info *server = chan->server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 	seq_printf(m, "\t\tChannel %d Number of credits: %d Dialect 0x%x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 		   "TCP status: %d Instance: %d Local Users To Server: %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) 		   "SecMode: 0x%x Req On Wire: %d In Send: %d "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 		   "In MaxReq Wait: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 		   i+1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 		   server->credits,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 		   server->dialect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) 		   server->tcpStatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 		   server->reconnect_instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		   server->srv_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 		   server->sec_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 		   in_flight(server),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 		   atomic_read(&server->in_send),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 		   atomic_read(&server->num_waiters));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  146) cifs_dump_iface(struct seq_file *m, struct cifs_server_iface *iface)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  148) 	struct sockaddr_in *ipv4 = (struct sockaddr_in *)&iface->sockaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&iface->sockaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	seq_printf(m, "\tSpeed: %zu bps\n", iface->speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	seq_puts(m, "\t\tCapabilities: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	if (iface->rdma_capable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 		seq_puts(m, "rdma ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	if (iface->rss_capable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 		seq_puts(m, "rss ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	if (iface->sockaddr.ss_family == AF_INET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 		seq_printf(m, "\t\tIPv4: %pI4\n", &ipv4->sin_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	else if (iface->sockaddr.ss_family == AF_INET6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 		seq_printf(m, "\t\tIPv6: %pI6\n", &ipv6->sin6_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) static int cifs_debug_files_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	struct list_head *stmp, *tmp, *tmp1, *tmp2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	struct cifs_ses *ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 	struct cifsFileInfo *cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172) 	seq_puts(m, "# Version:1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173) 	seq_puts(m, "# Format:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) 	seq_puts(m, "# <tree id> <persistent fid> <flags> <count> <pid> <uid>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) 	seq_printf(m, " <filename> <mid>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	seq_printf(m, " <filename>\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) #endif /* CIFS_DEBUG2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	spin_lock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 	list_for_each(stmp, &cifs_tcp_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 		server = list_entry(stmp, struct TCP_Server_Info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 				    tcp_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 		list_for_each(tmp, &server->smb_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 			ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 			list_for_each(tmp1, &ses->tcon_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 				tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 				spin_lock(&tcon->open_file_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 				list_for_each(tmp2, &tcon->openFileList) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 					cfile = list_entry(tmp2, struct cifsFileInfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 						     tlist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 					seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 						"0x%x 0x%llx 0x%x %d %d %d %s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 						tcon->tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 						cfile->fid.persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 						cfile->f_flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) 						cfile->count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 						cfile->pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) 						from_kuid(&init_user_ns, cfile->uid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200) 						cfile->dentry->d_name.name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) 					seq_printf(m, " 0x%llx\n", cfile->fid.mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 					seq_printf(m, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) #endif /* CIFS_DEBUG2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 				spin_unlock(&tcon->open_file_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 	struct list_head *tmp1, *tmp2, *tmp3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 	struct mid_q_entry *mid_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 	struct cifs_ses *ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 	int i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	seq_puts(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 		    "Display Internal CIFS Data Structures for Debugging\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) 		    "---------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 	seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) 	seq_printf(m, "Features:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) 	seq_printf(m, " DFS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) #ifdef CONFIG_CIFS_FSCACHE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 	seq_printf(m, ",FSCACHE");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 	seq_printf(m, ",SMB_DIRECT");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) 	seq_printf(m, ",STATS2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) 	seq_printf(m, ",STATS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244) #ifdef CONFIG_CIFS_DEBUG2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245) 	seq_printf(m, ",DEBUG2");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) #elif defined(CONFIG_CIFS_DEBUG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) 	seq_printf(m, ",DEBUG");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	seq_printf(m, ",ALLOW_INSECURE_LEGACY");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) #ifdef CONFIG_CIFS_WEAK_PW_HASH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	seq_printf(m, ",WEAK_PW_HASH");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) #ifdef CONFIG_CIFS_POSIX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 	seq_printf(m, ",CIFS_POSIX");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) #ifdef CONFIG_CIFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	seq_printf(m, ",UPCALL(SPNEGO)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) #ifdef CONFIG_CIFS_XATTR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) 	seq_printf(m, ",XATTR");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) 	seq_printf(m, ",ACL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) 	seq_printf(m, "CIFSMaxBufSize: %d\n", CIFSMaxBufSize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) 	seq_printf(m, "Servers:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) 	i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) 	spin_lock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) 	list_for_each(tmp1, &cifs_tcp_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 		server = list_entry(tmp1, struct TCP_Server_Info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) 				    tcp_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) 		if (!server->rdma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 			goto skip_rdma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 		if (!server->smbd_conn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) 			seq_printf(m, "\nSMBDirect transport not available");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 			goto skip_rdma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		seq_printf(m, "\nSMBDirect (in hex) protocol version: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) 			"transport status: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 			server->smbd_conn->protocol,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) 			server->smbd_conn->transport_status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) 		seq_printf(m, "\nConn receive_credit_max: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 			"send_credit_target: %x max_send_size: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) 			server->smbd_conn->receive_credit_max,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 			server->smbd_conn->send_credit_target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 			server->smbd_conn->max_send_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 		seq_printf(m, "\nConn max_fragmented_recv_size: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 			"max_fragmented_send_size: %x max_receive_size:%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) 			server->smbd_conn->max_fragmented_recv_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 			server->smbd_conn->max_fragmented_send_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) 			server->smbd_conn->max_receive_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 		seq_printf(m, "\nConn keep_alive_interval: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 			"max_readwrite_size: %x rdma_readwrite_threshold: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 			server->smbd_conn->keep_alive_interval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 			server->smbd_conn->max_readwrite_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 			server->smbd_conn->rdma_readwrite_threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 		seq_printf(m, "\nDebug count_get_receive_buffer: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 			"count_put_receive_buffer: %x count_send_empty: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 			server->smbd_conn->count_get_receive_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 			server->smbd_conn->count_put_receive_buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 			server->smbd_conn->count_send_empty);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 		seq_printf(m, "\nRead Queue count_reassembly_queue: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 			"count_enqueue_reassembly_queue: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 			"count_dequeue_reassembly_queue: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 			"fragment_reassembly_remaining: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 			"reassembly_data_length: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 			"reassembly_queue_length: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 			server->smbd_conn->count_reassembly_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 			server->smbd_conn->count_enqueue_reassembly_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 			server->smbd_conn->count_dequeue_reassembly_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 			server->smbd_conn->fragment_reassembly_remaining,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 			server->smbd_conn->reassembly_data_length,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 			server->smbd_conn->reassembly_queue_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 		seq_printf(m, "\nCurrent Credits send_credits: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 			"receive_credits: %x receive_credit_target: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 			atomic_read(&server->smbd_conn->send_credits),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 			atomic_read(&server->smbd_conn->receive_credits),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 			server->smbd_conn->receive_credit_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 		seq_printf(m, "\nPending send_pending: %x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 			atomic_read(&server->smbd_conn->send_pending));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 		seq_printf(m, "\nReceive buffers count_receive_queue: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 			"count_empty_packet_queue: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 			server->smbd_conn->count_receive_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 			server->smbd_conn->count_empty_packet_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 		seq_printf(m, "\nMR responder_resources: %x "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 			"max_frmr_depth: %x mr_type: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 			server->smbd_conn->responder_resources,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) 			server->smbd_conn->max_frmr_depth,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 			server->smbd_conn->mr_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) 		seq_printf(m, "\nMR mr_ready_count: %x mr_used_count: %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) 			atomic_read(&server->smbd_conn->mr_ready_count),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 			atomic_read(&server->smbd_conn->mr_used_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) skip_rdma:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 		seq_printf(m, "\nNumber of credits: %d Dialect 0x%x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 			server->credits,  server->dialect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 		if (server->compress_algorithm == SMB3_COMPRESS_LZNT1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 			seq_printf(m, " COMPRESS_LZNT1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 			seq_printf(m, " COMPRESS_LZ77");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 		else if (server->compress_algorithm == SMB3_COMPRESS_LZ77_HUFF)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 			seq_printf(m, " COMPRESS_LZ77_HUFF");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 		if (server->sign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 			seq_printf(m, " signed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 		if (server->posix_ext_supported)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 			seq_printf(m, " posix");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 		i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 		list_for_each(tmp2, &server->smb_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 			ses = list_entry(tmp2, struct cifs_ses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 					 smb_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 			if ((ses->serverDomain == NULL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 				(ses->serverOS == NULL) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 				(ses->serverNOS == NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 				seq_printf(m, "\n%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 					i, ses->serverName, ses->ses_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 					ses->capabilities, ses->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 				if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 					seq_printf(m, "Guest\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 				else if (ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 					seq_printf(m, "Anonymous\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 				seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 				    "\n%d) Name: %s  Domain: %s Uses: %d OS:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 				    " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 				    " session status: %d ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 				i, ses->serverName, ses->serverDomain,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 				ses->ses_count, ses->serverOS, ses->serverNOS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 				ses->capabilities, ses->status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 			seq_printf(m,"Security type: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 				get_security_type_str(server->ops->select_sectype(server, ses->sectype)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 			if (server->rdma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 				seq_printf(m, "RDMA\n\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 			seq_printf(m, "TCP status: %d Instance: %d\n\tLocal Users To "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 				   "Server: %d SecMode: 0x%x Req On Wire: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 				   server->tcpStatus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 				   server->reconnect_instance,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 				   server->srv_count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) 				   server->sec_mode, in_flight(server));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 			seq_printf(m, " In Send: %d In MaxReq Wait: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 				atomic_read(&server->in_send),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 				atomic_read(&server->num_waiters));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 			/* dump session id helpful for use with network trace */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 			seq_printf(m, " SessionId: 0x%llx", ses->Suid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 			if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 				seq_puts(m, " encrypted");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 			if (ses->sign)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 				seq_puts(m, " signed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) 			seq_printf(m, "\n\tUser: %d Cred User: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 				   from_kuid(&init_user_ns, ses->linux_uid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 				   from_kuid(&init_user_ns, ses->cred_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 			if (ses->chan_count > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 				seq_printf(m, "\n\n\tExtra Channels: %zu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 					   ses->chan_count-1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 				for (j = 1; j < ses->chan_count; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 					cifs_dump_channel(m, j, &ses->chans[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 			seq_puts(m, "\n\n\tShares:");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 			j = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 			seq_printf(m, "\n\t%d) IPC: ", j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 			if (ses->tcon_ipc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 				cifs_debug_tcon(m, ses->tcon_ipc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 				seq_puts(m, "none\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 			list_for_each(tmp3, &ses->tcon_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 				tcon = list_entry(tmp3, struct cifs_tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 						  tcon_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 				++j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 				seq_printf(m, "\n\t%d) ", j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 				cifs_debug_tcon(m, tcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 			seq_puts(m, "\n\tMIDs:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 			spin_lock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 			list_for_each(tmp3, &server->pending_mid_q) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 				mid_entry = list_entry(tmp3, struct mid_q_entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 					qhead);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 				seq_printf(m, "\tState: %d com: %d pid:"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 					      " %d cbdata: %p mid %llu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 					      mid_entry->mid_state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 					      le16_to_cpu(mid_entry->command),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 					      mid_entry->pid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 					      mid_entry->callback_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 					      mid_entry->mid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 			spin_unlock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			spin_lock(&ses->iface_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 			if (ses->iface_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 				seq_printf(m, "\n\tServer interfaces: %zu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 					   ses->iface_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 			for (j = 0; j < ses->iface_count; j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 				struct cifs_server_iface *iface;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 				iface = &ses->iface_list[j];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 				seq_printf(m, "\t%d)", j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 				cifs_dump_iface(m, iface);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 				if (is_ses_using_iface(ses, iface))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 					seq_puts(m, "\t\t[CONNECTED]\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 			spin_unlock(&ses->iface_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 	spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 	/* BB add code to dump additional info such as TCP session info now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) static ssize_t cifs_stats_proc_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 		const char __user *buffer, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 	bool bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 	struct list_head *tmp1, *tmp2, *tmp3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 	struct cifs_ses *ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 	rc = kstrtobool_from_user(buffer, count, &bv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	if (rc == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) 		int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) 		atomic_set(&totBufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485) 		atomic_set(&totSmBufAllocCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486) #endif /* CONFIG_CIFS_STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) 		atomic_set(&tcpSesReconnectCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) 		atomic_set(&tconInfoReconnectCount, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 		spin_lock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 		GlobalMaxActiveXid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 		GlobalCurrentXid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 		spin_unlock(&GlobalMid_Lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 		spin_lock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 		list_for_each(tmp1, &cifs_tcp_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 			server = list_entry(tmp1, struct TCP_Server_Info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 					    tcp_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 			server->max_in_flight = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 			for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 				atomic_set(&server->num_cmds[i], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 				atomic_set(&server->smb2slowcmd[i], 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 				server->time_per_cmd[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 				server->slowest_cmd[i] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 				server->fastest_cmd[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) #endif /* CONFIG_CIFS_STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 			list_for_each(tmp2, &server->smb_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 				ses = list_entry(tmp2, struct cifs_ses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 						 smb_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 				list_for_each(tmp3, &ses->tcon_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 					tcon = list_entry(tmp3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 							  struct cifs_tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 							  tcon_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 					atomic_set(&tcon->num_smbs_sent, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 					spin_lock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 					tcon->bytes_read = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 					tcon->bytes_written = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) 					spin_unlock(&tcon->stat_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 					if (server->ops->clear_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 						server->ops->clear_stats(tcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 		spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533) static int cifs_stats_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537) 	int j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538) #endif /* STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539) 	struct list_head *tmp1, *tmp2, *tmp3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540) 	struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541) 	struct cifs_ses *ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542) 	struct cifs_tcon *tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) 	seq_printf(m, "Resources in use\nCIFS Session: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 			sesInfoAllocCount.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) 	seq_printf(m, "Share (unique mount targets): %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) 			tconInfoAllocCount.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 			bufAllocCount.counter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 			cifs_min_rcv + tcpSesAllocCount.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 			smBufAllocCount.counter, cifs_min_small);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 	seq_printf(m, "Total Large %d Small %d Allocations\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 				atomic_read(&totBufAllocCount),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 				atomic_read(&totSmBufAllocCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) #endif /* CONFIG_CIFS_STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 	seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 		"\n%d session %d share reconnects\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 		tcpSesReconnectCount.counter, tconInfoReconnectCount.counter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 	seq_printf(m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 		"Total vfs operations: %d maximum at one time: %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 		GlobalCurrentXid, GlobalMaxActiveXid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 	spin_lock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	list_for_each(tmp1, &cifs_tcp_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		server = list_entry(tmp1, struct TCP_Server_Info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 				    tcp_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		seq_printf(m, "\nMax requests in flight: %d", server->max_in_flight);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) #ifdef CONFIG_CIFS_STATS2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) 		seq_puts(m, "\nTotal time spent processing by command. Time ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 		seq_printf(m, "units are jiffies (%d per second)\n", HZ);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 		seq_puts(m, "  SMB3 CMD\tNumber\tTotal Time\tFastest\tSlowest\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) 		seq_puts(m, "  --------\t------\t----------\t-------\t-------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 		for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 			seq_printf(m, "  %d\t\t%d\t%llu\t\t%u\t%u\n", j,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 				atomic_read(&server->num_cmds[j]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 				server->time_per_cmd[j],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 				server->fastest_cmd[j],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) 				server->slowest_cmd[j]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 		for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) 			if (atomic_read(&server->smb2slowcmd[j]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587) 				seq_printf(m, "  %d slow responses from %s for command %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588) 					atomic_read(&server->smb2slowcmd[j]),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589) 					server->hostname, j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590) #endif /* STATS2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591) 		list_for_each(tmp2, &server->smb_ses_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592) 			ses = list_entry(tmp2, struct cifs_ses,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) 					 smb_ses_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) 			list_for_each(tmp3, &ses->tcon_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 				tcon = list_entry(tmp3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 						  struct cifs_tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 						  tcon_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 				i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 				seq_printf(m, "\n%d) %s", i, tcon->treeName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 				if (tcon->need_reconnect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 					seq_puts(m, "\tDISCONNECTED ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 				seq_printf(m, "\nSMBs: %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 					   atomic_read(&tcon->num_smbs_sent));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 				if (server->ops->print_stats)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 					server->ops->print_stats(m, tcon);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	spin_unlock(&cifs_tcp_ses_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615) static int cifs_stats_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) 	return single_open(file, cifs_stats_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) static const struct proc_ops cifs_stats_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	.proc_open	= cifs_stats_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	.proc_write	= cifs_stats_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) #define PROC_FILE_DEFINE(name) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) static ssize_t name##_write(struct file *file, const char __user *buffer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	size_t count, loff_t *ppos) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 	int rc; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	rc = kstrtoint_from_user(buffer, count, 10, & name); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	if (rc) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		return rc; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	return count; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) static int name##_proc_show(struct seq_file *m, void *v) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 	seq_printf(m, "%d\n", name ); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	return 0; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) static int name##_open(struct inode *inode, struct file *file) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	return single_open(file, name##_proc_show, NULL); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) } \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) static const struct proc_ops cifs_##name##_proc_fops = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	.proc_open	= name##_open, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	.proc_read	= seq_read, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 	.proc_lseek	= seq_lseek, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 	.proc_release	= single_release, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 	.proc_write	= name##_write, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) PROC_FILE_DEFINE(rdma_readwrite_threshold);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) PROC_FILE_DEFINE(smbd_max_frmr_depth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) PROC_FILE_DEFINE(smbd_keep_alive_interval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) PROC_FILE_DEFINE(smbd_max_receive_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) PROC_FILE_DEFINE(smbd_max_fragmented_recv_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) PROC_FILE_DEFINE(smbd_max_send_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) PROC_FILE_DEFINE(smbd_send_credit_target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) PROC_FILE_DEFINE(smbd_receive_credit_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) static struct proc_dir_entry *proc_fs_cifs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) static const struct proc_ops cifsFYI_proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) static const struct proc_ops cifs_lookup_cache_proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) static const struct proc_ops traceSMB_proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) static const struct proc_ops cifs_security_flags_proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) static const struct proc_ops cifs_linux_ext_proc_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) cifs_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 	proc_fs_cifs = proc_mkdir("fs/cifs", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 	if (proc_fs_cifs == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 	proc_create_single("DebugData", 0, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 			cifs_debug_data_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 	proc_create_single("open_files", 0400, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 			cifs_debug_files_proc_show);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 	proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 	proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 	proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 	proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 		    &cifs_linux_ext_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 	proc_create("SecurityFlags", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 		    &cifs_security_flags_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) 	proc_create("LookupCacheEnabled", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 		    &cifs_lookup_cache_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 	proc_create("dfscache", 0644, proc_fs_cifs, &dfscache_proc_ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 	proc_create("rdma_readwrite_threshold", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 		&cifs_rdma_readwrite_threshold_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 	proc_create("smbd_max_frmr_depth", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 		&cifs_smbd_max_frmr_depth_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 	proc_create("smbd_keep_alive_interval", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 		&cifs_smbd_keep_alive_interval_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 	proc_create("smbd_max_receive_size", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 		&cifs_smbd_max_receive_size_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 	proc_create("smbd_max_fragmented_recv_size", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 		&cifs_smbd_max_fragmented_recv_size_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 	proc_create("smbd_max_send_size", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 		&cifs_smbd_max_send_size_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 	proc_create("smbd_send_credit_target", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 		&cifs_smbd_send_credit_target_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) 	proc_create("smbd_receive_credit_max", 0644, proc_fs_cifs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		&cifs_smbd_receive_credit_max_proc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) cifs_proc_clean(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 	if (proc_fs_cifs == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 	remove_proc_entry("DebugData", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 	remove_proc_entry("open_files", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 	remove_proc_entry("cifsFYI", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 	remove_proc_entry("traceSMB", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 	remove_proc_entry("Stats", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 	remove_proc_entry("SecurityFlags", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) #ifdef CONFIG_CIFS_DFS_UPCALL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	remove_proc_entry("dfscache", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) #ifdef CONFIG_CIFS_SMB_DIRECT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	remove_proc_entry("rdma_readwrite_threshold", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	remove_proc_entry("smbd_max_frmr_depth", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	remove_proc_entry("smbd_keep_alive_interval", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 	remove_proc_entry("smbd_max_receive_size", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) 	remove_proc_entry("smbd_max_fragmented_recv_size", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	remove_proc_entry("smbd_max_send_size", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	remove_proc_entry("smbd_send_credit_target", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 	remove_proc_entry("smbd_receive_credit_max", proc_fs_cifs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	remove_proc_entry("fs/cifs", NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) static int cifsFYI_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 	seq_printf(m, "%d\n", cifsFYI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) static int cifsFYI_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 	return single_open(file, cifsFYI_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 		size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 	char c[2] = { '\0' };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 	bool bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	rc = get_user(c[0], buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 	if (strtobool(c, &bv) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 		cifsFYI = bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	else if ((c[0] > '1') && (c[0] <= '9'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 		cifsFYI = (int) (c[0] - '0'); /* see cifs_debug.h for meanings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) static const struct proc_ops cifsFYI_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 	.proc_open	= cifsFYI_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	.proc_write	= cifsFYI_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) static int cifs_linux_ext_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	seq_printf(m, "%d\n", linuxExtEnabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	return single_open(file, cifs_linux_ext_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) static ssize_t cifs_linux_ext_proc_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 		const char __user *buffer, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	rc = kstrtobool_from_user(buffer, count, &linuxExtEnabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) static const struct proc_ops cifs_linux_ext_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 	.proc_open	= cifs_linux_ext_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) 	.proc_write	= cifs_linux_ext_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	seq_printf(m, "%d\n", lookupCacheEnabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 	return single_open(file, cifs_lookup_cache_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) static ssize_t cifs_lookup_cache_proc_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 		const char __user *buffer, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	rc = kstrtobool_from_user(buffer, count, &lookupCacheEnabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) static const struct proc_ops cifs_lookup_cache_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	.proc_open	= cifs_lookup_cache_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	.proc_write	= cifs_lookup_cache_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) static int traceSMB_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	seq_printf(m, "%d\n", traceSMB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) static int traceSMB_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	return single_open(file, traceSMB_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) 		size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 	rc = kstrtobool_from_user(buffer, count, &traceSMB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 	if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) static const struct proc_ops traceSMB_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	.proc_open	= traceSMB_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	.proc_write	= traceSMB_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) static int cifs_security_flags_proc_show(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	seq_printf(m, "0x%x\n", global_secflags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) static int cifs_security_flags_proc_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	return single_open(file, cifs_security_flags_proc_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896)  * Ensure that if someone sets a MUST flag, that we disable all other MAY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897)  * flags except for the ones corresponding to the given MUST flag. If there are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898)  * multiple MUST flags, then try to prefer more secure ones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) cifs_security_flags_handle_must_flags(unsigned int *flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 	unsigned int signflags = *flags & CIFSSEC_MUST_SIGN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	if ((*flags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 		*flags = CIFSSEC_MUST_KRB5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	else if ((*flags & CIFSSEC_MUST_NTLMSSP) == CIFSSEC_MUST_NTLMSSP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 		*flags = CIFSSEC_MUST_NTLMSSP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	else if ((*flags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 		*flags = CIFSSEC_MUST_NTLMV2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 	else if ((*flags & CIFSSEC_MUST_NTLM) == CIFSSEC_MUST_NTLM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 		*flags = CIFSSEC_MUST_NTLM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	else if (CIFSSEC_MUST_LANMAN &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 		 (*flags & CIFSSEC_MUST_LANMAN) == CIFSSEC_MUST_LANMAN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 		*flags = CIFSSEC_MUST_LANMAN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	else if (CIFSSEC_MUST_PLNTXT &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 		 (*flags & CIFSSEC_MUST_PLNTXT) == CIFSSEC_MUST_PLNTXT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 		*flags = CIFSSEC_MUST_PLNTXT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 	*flags |= signflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) static ssize_t cifs_security_flags_proc_write(struct file *file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 		const char __user *buffer, size_t count, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	unsigned int flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	char flags_string[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	bool bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	if ((count < 1) || (count > 11))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 	memset(flags_string, 0, 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 	if (copy_from_user(flags_string, buffer, count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 	if (count < 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 		/* single char or single char followed by null */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 		if (strtobool(flags_string, &bv) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 			global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 			return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 		} else if (!isdigit(flags_string[0])) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 			cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 					flags_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 	/* else we have a number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 	rc = kstrtouint(flags_string, 0, &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 		cifs_dbg(VFS, "Invalid SecurityFlags: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 				flags_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 	cifs_dbg(FYI, "sec flags 0x%x\n", flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 	if (flags == 0)  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", flags_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	if (flags & ~CIFSSEC_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		cifs_dbg(VFS, "Unsupported security flags: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 			 flags & ~CIFSSEC_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	cifs_security_flags_handle_must_flags(&flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 	/* flags look ok - update the global security flags for cifs module */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	global_secflags = flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	if (global_secflags & CIFSSEC_MUST_SIGN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 		/* requiring signing implies signing is allowed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		global_secflags |= CIFSSEC_MAY_SIGN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		cifs_dbg(FYI, "packet signing now required\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	} else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 		cifs_dbg(FYI, "packet signing disabled\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 	/* BB should we turn on MAY flags for other MUST options? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) static const struct proc_ops cifs_security_flags_proc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	.proc_open	= cifs_security_flags_proc_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) 	.proc_read	= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	.proc_lseek	= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	.proc_release	= single_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) 	.proc_write	= cifs_security_flags_proc_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) inline void cifs_proc_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) inline void cifs_proc_clean(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) #endif /* PROC_FS */