Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs_debug.c |
| 3 | * |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 4 | * Copyright (C) International Business Machines Corp., 2000,2005 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
| 6 | * Modified by Steve French (sfrench@us.ibm.com) |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 10 | * the Free Software Foundation; either version 2 of the License, or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * (at your option) any later version. |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 12 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 16 | * the GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 19 | * along with this program; if not, write to the Free Software |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | */ |
| 22 | #include <linux/fs.h> |
| 23 | #include <linux/string.h> |
| 24 | #include <linux/ctype.h> |
| 25 | #include <linux/module.h> |
| 26 | #include <linux/proc_fs.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 27 | #include <linux/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #include "cifspdu.h" |
| 29 | #include "cifsglob.h" |
| 30 | #include "cifsproto.h" |
| 31 | #include "cifs_debug.h" |
Steve French | 6c91d36 | 2005-04-28 22:41:06 -0700 | [diff] [blame] | 32 | #include "cifsfs.h" |
Long Li | d8ec913 | 2017-11-07 01:54:58 -0700 | [diff] [blame] | 33 | #ifdef CONFIG_CIFS_SMB_DIRECT |
| 34 | #include "smbdirect.h" |
| 35 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | void |
| 38 | cifs_dump_mem(char *label, void *data, int length) |
| 39 | { |
Andy Shevchenko | 0b456f0 | 2014-08-27 16:49:44 +0300 | [diff] [blame] | 40 | pr_debug("%s: dump of %d bytes of data at 0x%p\n", label, length, data); |
Andy Shevchenko | 55d83e0 | 2014-08-27 16:49:43 +0300 | [diff] [blame] | 41 | print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4, |
| 42 | data, length, true); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | } |
| 44 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 45 | #ifdef CONFIG_CIFS_DEBUG |
| 46 | void cifs_vfs_err(const char *fmt, ...) |
| 47 | { |
| 48 | struct va_format vaf; |
| 49 | va_list args; |
| 50 | |
| 51 | va_start(args, fmt); |
| 52 | |
| 53 | vaf.fmt = fmt; |
| 54 | vaf.va = &args; |
| 55 | |
Jamie Bainbridge | ec7147a | 2015-11-07 22:13:49 +1000 | [diff] [blame] | 56 | pr_err_ratelimited("CIFS VFS: %pV", &vaf); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 57 | |
| 58 | va_end(args); |
| 59 | } |
| 60 | #endif |
| 61 | |
Pavel Shilovsky | d4e4854 | 2012-03-23 14:28:02 -0400 | [diff] [blame] | 62 | void cifs_dump_detail(void *buf) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 63 | { |
Pavel Shilovsky | 8aa26f3 | 2012-05-17 13:25:35 +0400 | [diff] [blame] | 64 | #ifdef CONFIG_CIFS_DEBUG2 |
Pavel Shilovsky | d4e4854 | 2012-03-23 14:28:02 -0400 | [diff] [blame] | 65 | struct smb_hdr *smb = (struct smb_hdr *)buf; |
| 66 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 67 | cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d\n", |
| 68 | smb->Command, smb->Status.CifsError, |
| 69 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid); |
| 70 | cifs_dbg(VFS, "smb buf %p len %u\n", smb, smbCalcSize(smb)); |
Pavel Shilovsky | 8aa26f3 | 2012-05-17 13:25:35 +0400 | [diff] [blame] | 71 | #endif /* CONFIG_CIFS_DEBUG2 */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 74 | void cifs_dump_mids(struct TCP_Server_Info *server) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 75 | { |
Pavel Shilovsky | 8aa26f3 | 2012-05-17 13:25:35 +0400 | [diff] [blame] | 76 | #ifdef CONFIG_CIFS_DEBUG2 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 77 | struct list_head *tmp; |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 78 | struct mid_q_entry *mid_entry; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 79 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 80 | if (server == NULL) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 81 | return; |
| 82 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 83 | cifs_dbg(VFS, "Dump pending requests:\n"); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 84 | spin_lock(&GlobalMid_Lock); |
| 85 | list_for_each(tmp, &server->pending_mid_q) { |
| 86 | mid_entry = list_entry(tmp, struct mid_q_entry, qhead); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 87 | cifs_dbg(VFS, "State: %d Cmd: %d Pid: %d Cbdata: %p Mid %llu\n", |
| 88 | mid_entry->mid_state, |
| 89 | le16_to_cpu(mid_entry->command), |
| 90 | mid_entry->pid, |
| 91 | mid_entry->callback_data, |
| 92 | mid_entry->mid); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 93 | #ifdef CONFIG_CIFS_STATS2 |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 94 | cifs_dbg(VFS, "IsLarge: %d buf: %p time rcv: %ld now: %ld\n", |
| 95 | mid_entry->large_buf, |
| 96 | mid_entry->resp_buf, |
| 97 | mid_entry->when_received, |
| 98 | jiffies); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 99 | #endif /* STATS2 */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 100 | cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n", |
| 101 | mid_entry->multiRsp, mid_entry->multiEnd); |
Steve French | ad8b15f | 2008-08-08 21:10:16 +0000 | [diff] [blame] | 102 | if (mid_entry->resp_buf) { |
| 103 | cifs_dump_detail(mid_entry->resp_buf); |
| 104 | cifs_dump_mem("existing buf: ", |
| 105 | mid_entry->resp_buf, 62); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | spin_unlock(&GlobalMid_Lock); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 109 | #endif /* CONFIG_CIFS_DEBUG2 */ |
Pavel Shilovsky | 8aa26f3 | 2012-05-17 13:25:35 +0400 | [diff] [blame] | 110 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #ifdef CONFIG_PROC_FS |
Aurelien Aptel | 02cf590 | 2018-01-24 13:46:12 +0100 | [diff] [blame] | 113 | static void cifs_debug_tcon(struct seq_file *m, struct cifs_tcon *tcon) |
| 114 | { |
| 115 | __u32 dev_type = le32_to_cpu(tcon->fsDevInfo.DeviceType); |
| 116 | |
| 117 | seq_printf(m, "%s Mounts: %d ", tcon->treeName, tcon->tc_count); |
| 118 | if (tcon->nativeFileSystem) |
| 119 | seq_printf(m, "Type: %s ", tcon->nativeFileSystem); |
| 120 | seq_printf(m, "DevInfo: 0x%x Attributes: 0x%x\n\tPathComponentMax: %d Status: %d", |
| 121 | le32_to_cpu(tcon->fsDevInfo.DeviceCharacteristics), |
| 122 | le32_to_cpu(tcon->fsAttrInfo.Attributes), |
| 123 | le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength), |
| 124 | tcon->tidStatus); |
| 125 | if (dev_type == FILE_DEVICE_DISK) |
| 126 | seq_puts(m, " type: DISK "); |
| 127 | else if (dev_type == FILE_DEVICE_CD_ROM) |
| 128 | seq_puts(m, " type: CDROM "); |
| 129 | else |
| 130 | seq_printf(m, " type: %d ", dev_type); |
Steve French | ede2e52 | 2018-01-31 14:34:37 -0600 | [diff] [blame] | 131 | if (tcon->seal) |
| 132 | seq_printf(m, " Encrypted"); |
| 133 | if (tcon->unix_ext) |
| 134 | seq_printf(m, " POSIX Extensions"); |
Aurelien Aptel | 02cf590 | 2018-01-24 13:46:12 +0100 | [diff] [blame] | 135 | if (tcon->ses->server->ops->dump_share_caps) |
| 136 | tcon->ses->server->ops->dump_share_caps(m, tcon); |
| 137 | |
| 138 | if (tcon->need_reconnect) |
| 139 | seq_puts(m, "\tDISCONNECTED "); |
| 140 | seq_putc(m, '\n'); |
| 141 | } |
| 142 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 143 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | { |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 145 | struct list_head *tmp1, *tmp2, *tmp3; |
Steve French | ffdd6e4 | 2007-06-24 21:15:44 +0000 | [diff] [blame] | 146 | struct mid_q_entry *mid_entry; |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 147 | struct TCP_Server_Info *server; |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 148 | struct cifs_ses *ses; |
| 149 | struct cifs_tcon *tcon; |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 150 | int i, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 152 | seq_puts(m, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | "Display Internal CIFS Data Structures for Debugging\n" |
| 154 | "---------------------------------------------------\n"); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 155 | seq_printf(m, "CIFS Version %s\n", CIFS_VERSION); |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 156 | seq_printf(m, "Features:"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 157 | #ifdef CONFIG_CIFS_DFS_UPCALL |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 158 | seq_printf(m, " dfs"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 159 | #endif |
| 160 | #ifdef CONFIG_CIFS_FSCACHE |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 161 | seq_printf(m, " fscache"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 162 | #endif |
| 163 | #ifdef CONFIG_CIFS_WEAK_PW_HASH |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 164 | seq_printf(m, " lanman"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 165 | #endif |
| 166 | #ifdef CONFIG_CIFS_POSIX |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 167 | seq_printf(m, " posix"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 168 | #endif |
| 169 | #ifdef CONFIG_CIFS_UPCALL |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 170 | seq_printf(m, " spnego"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 171 | #endif |
| 172 | #ifdef CONFIG_CIFS_XATTR |
Jeff Layton | ca40b71 | 2011-01-07 11:30:29 -0500 | [diff] [blame] | 173 | seq_printf(m, " xattr"); |
| 174 | #endif |
| 175 | #ifdef CONFIG_CIFS_ACL |
| 176 | seq_printf(m, " acl"); |
Suresh Jayaraman | f579903 | 2010-07-30 18:25:56 +0530 | [diff] [blame] | 177 | #endif |
| 178 | seq_putc(m, '\n'); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 179 | seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid); |
| 180 | seq_printf(m, "Servers:"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | i = 0; |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 183 | spin_lock(&cifs_tcp_ses_lock); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 184 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
| 185 | server = list_entry(tmp1, struct TCP_Server_Info, |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 186 | tcp_ses_list); |
Long Li | 08a3b96 | 2017-11-22 17:38:48 -0700 | [diff] [blame] | 187 | |
| 188 | #ifdef CONFIG_CIFS_SMB_DIRECT |
| 189 | if (!server->rdma) |
| 190 | goto skip_rdma; |
| 191 | |
| 192 | seq_printf(m, "\nSMBDirect (in hex) protocol version: %x " |
| 193 | "transport status: %x", |
| 194 | server->smbd_conn->protocol, |
| 195 | server->smbd_conn->transport_status); |
| 196 | seq_printf(m, "\nConn receive_credit_max: %x " |
| 197 | "send_credit_target: %x max_send_size: %x", |
| 198 | server->smbd_conn->receive_credit_max, |
| 199 | server->smbd_conn->send_credit_target, |
| 200 | server->smbd_conn->max_send_size); |
| 201 | seq_printf(m, "\nConn max_fragmented_recv_size: %x " |
| 202 | "max_fragmented_send_size: %x max_receive_size:%x", |
| 203 | server->smbd_conn->max_fragmented_recv_size, |
| 204 | server->smbd_conn->max_fragmented_send_size, |
| 205 | server->smbd_conn->max_receive_size); |
| 206 | seq_printf(m, "\nConn keep_alive_interval: %x " |
| 207 | "max_readwrite_size: %x rdma_readwrite_threshold: %x", |
| 208 | server->smbd_conn->keep_alive_interval, |
| 209 | server->smbd_conn->max_readwrite_size, |
| 210 | server->smbd_conn->rdma_readwrite_threshold); |
| 211 | seq_printf(m, "\nDebug count_get_receive_buffer: %x " |
| 212 | "count_put_receive_buffer: %x count_send_empty: %x", |
| 213 | server->smbd_conn->count_get_receive_buffer, |
| 214 | server->smbd_conn->count_put_receive_buffer, |
| 215 | server->smbd_conn->count_send_empty); |
| 216 | seq_printf(m, "\nRead Queue count_reassembly_queue: %x " |
| 217 | "count_enqueue_reassembly_queue: %x " |
| 218 | "count_dequeue_reassembly_queue: %x " |
| 219 | "fragment_reassembly_remaining: %x " |
| 220 | "reassembly_data_length: %x " |
| 221 | "reassembly_queue_length: %x", |
| 222 | server->smbd_conn->count_reassembly_queue, |
| 223 | server->smbd_conn->count_enqueue_reassembly_queue, |
| 224 | server->smbd_conn->count_dequeue_reassembly_queue, |
| 225 | server->smbd_conn->fragment_reassembly_remaining, |
| 226 | server->smbd_conn->reassembly_data_length, |
| 227 | server->smbd_conn->reassembly_queue_length); |
| 228 | seq_printf(m, "\nCurrent Credits send_credits: %x " |
| 229 | "receive_credits: %x receive_credit_target: %x", |
| 230 | atomic_read(&server->smbd_conn->send_credits), |
| 231 | atomic_read(&server->smbd_conn->receive_credits), |
| 232 | server->smbd_conn->receive_credit_target); |
| 233 | seq_printf(m, "\nPending send_pending: %x send_payload_pending:" |
| 234 | " %x smbd_send_pending: %x smbd_recv_pending: %x", |
| 235 | atomic_read(&server->smbd_conn->send_pending), |
| 236 | atomic_read(&server->smbd_conn->send_payload_pending), |
| 237 | server->smbd_conn->smbd_send_pending, |
| 238 | server->smbd_conn->smbd_recv_pending); |
| 239 | seq_printf(m, "\nReceive buffers count_receive_queue: %x " |
| 240 | "count_empty_packet_queue: %x", |
| 241 | server->smbd_conn->count_receive_queue, |
| 242 | server->smbd_conn->count_empty_packet_queue); |
| 243 | seq_printf(m, "\nMR responder_resources: %x " |
| 244 | "max_frmr_depth: %x mr_type: %x", |
| 245 | server->smbd_conn->responder_resources, |
| 246 | server->smbd_conn->max_frmr_depth, |
| 247 | server->smbd_conn->mr_type); |
| 248 | seq_printf(m, "\nMR mr_ready_count: %x mr_used_count: %x", |
| 249 | atomic_read(&server->smbd_conn->mr_ready_count), |
| 250 | atomic_read(&server->smbd_conn->mr_used_count)); |
| 251 | skip_rdma: |
| 252 | #endif |
Steve French | ede2e52 | 2018-01-31 14:34:37 -0600 | [diff] [blame] | 253 | seq_printf(m, "\nNumber of credits: %d Dialect 0x%x", |
| 254 | server->credits, server->dialect); |
| 255 | if (server->sign) |
| 256 | seq_printf(m, " signed"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | i++; |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 258 | list_for_each(tmp2, &server->smb_ses_list) { |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 259 | ses = list_entry(tmp2, struct cifs_ses, |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 260 | smb_ses_list); |
| 261 | if ((ses->serverDomain == NULL) || |
| 262 | (ses->serverOS == NULL) || |
| 263 | (ses->serverNOS == NULL)) { |
Steve French | 1fa089e | 2017-09-20 16:46:49 -0500 | [diff] [blame] | 264 | seq_printf(m, "\n%d) Name: %s Uses: %d Capability: 0x%x\tSession Status: %d\t", |
| 265 | i, ses->serverName, ses->ses_count, |
| 266 | ses->capabilities, ses->status); |
| 267 | if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) |
| 268 | seq_printf(m, "Guest\t"); |
| 269 | else if (ses->session_flags & SMB2_SESSION_FLAG_IS_NULL) |
| 270 | seq_printf(m, "Anonymous\t"); |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 271 | } else { |
| 272 | seq_printf(m, |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 273 | "\n%d) Name: %s Domain: %s Uses: %d OS:" |
| 274 | " %s\n\tNOS: %s\tCapability: 0x%x\n\tSMB" |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 275 | " session status: %d\t", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 276 | i, ses->serverName, ses->serverDomain, |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 277 | ses->ses_count, ses->serverOS, ses->serverNOS, |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 278 | ses->capabilities, ses->status); |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 279 | } |
Long Li | 8339dd3 | 2017-11-07 01:54:55 -0700 | [diff] [blame] | 280 | if (server->rdma) |
| 281 | seq_printf(m, "RDMA\n\t"); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 282 | seq_printf(m, "TCP status: %d\n\tLocal Users To " |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 283 | "Server: %d SecMode: 0x%x Req On Wire: %d", |
| 284 | server->tcpStatus, server->srv_count, |
Pavel Shilovsky | fc40f9c | 2012-02-17 17:09:12 +0300 | [diff] [blame] | 285 | server->sec_mode, in_flight(server)); |
Steve French | 131afd0b | 2005-10-07 09:51:05 -0700 | [diff] [blame] | 286 | |
| 287 | #ifdef CONFIG_CIFS_STATS2 |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 288 | seq_printf(m, " In Send: %d In MaxReq Wait: %d", |
Steve French | 789e666 | 2011-08-09 18:44:44 +0000 | [diff] [blame] | 289 | atomic_read(&server->in_send), |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 290 | atomic_read(&server->num_waiters)); |
Steve French | 131afd0b | 2005-10-07 09:51:05 -0700 | [diff] [blame] | 291 | #endif |
| 292 | |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 293 | seq_puts(m, "\n\tShares:"); |
| 294 | j = 0; |
Aurelien Aptel | 02cf590 | 2018-01-24 13:46:12 +0100 | [diff] [blame] | 295 | |
| 296 | seq_printf(m, "\n\t%d) IPC: ", j); |
| 297 | if (ses->tcon_ipc) |
| 298 | cifs_debug_tcon(m, ses->tcon_ipc); |
| 299 | else |
| 300 | seq_puts(m, "none\n"); |
| 301 | |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 302 | list_for_each(tmp3, &ses->tcon_list) { |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 303 | tcon = list_entry(tmp3, struct cifs_tcon, |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 304 | tcon_list); |
| 305 | ++j; |
Aurelien Aptel | 02cf590 | 2018-01-24 13:46:12 +0100 | [diff] [blame] | 306 | seq_printf(m, "\n\t%d) ", j); |
| 307 | cifs_debug_tcon(m, tcon); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | seq_puts(m, "\n\tMIDs:\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
| 312 | spin_lock(&GlobalMid_Lock); |
Jeff Layton | 14fbf50 | 2008-11-14 13:53:46 -0500 | [diff] [blame] | 313 | list_for_each(tmp3, &server->pending_mid_q) { |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 314 | mid_entry = list_entry(tmp3, struct mid_q_entry, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | qhead); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 316 | seq_printf(m, "\tState: %d com: %d pid:" |
Pavel Shilovsky | 7c9421e | 2012-03-23 14:28:03 -0400 | [diff] [blame] | 317 | " %d cbdata: %p mid %llu\n", |
| 318 | mid_entry->mid_state, |
| 319 | le16_to_cpu(mid_entry->command), |
| 320 | mid_entry->pid, |
| 321 | mid_entry->callback_data, |
| 322 | mid_entry->mid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 324 | spin_unlock(&GlobalMid_Lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | } |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 327 | spin_unlock(&cifs_tcp_ses_lock); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 328 | seq_putc(m, '\n'); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | /* BB add code to dump additional info such as TCP session info now */ |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 331 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 334 | static int cifs_debug_data_proc_open(struct inode *inode, struct file *file) |
| 335 | { |
| 336 | return single_open(file, cifs_debug_data_proc_show, NULL); |
| 337 | } |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 338 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 339 | static const struct file_operations cifs_debug_data_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 340 | .open = cifs_debug_data_proc_open, |
| 341 | .read = seq_read, |
| 342 | .llseek = seq_lseek, |
| 343 | .release = single_release, |
| 344 | }; |
| 345 | |
| 346 | #ifdef CONFIG_CIFS_STATS |
| 347 | static ssize_t cifs_stats_proc_write(struct file *file, |
| 348 | const char __user *buffer, size_t count, loff_t *ppos) |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 349 | { |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 350 | bool bv; |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 351 | int rc; |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 352 | struct list_head *tmp1, *tmp2, *tmp3; |
| 353 | struct TCP_Server_Info *server; |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 354 | struct cifs_ses *ses; |
| 355 | struct cifs_tcon *tcon; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 356 | |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 357 | rc = kstrtobool_from_user(buffer, count, &bv); |
| 358 | if (rc == 0) { |
Steve French | 4498eed5 | 2005-12-03 13:58:57 -0800 | [diff] [blame] | 359 | #ifdef CONFIG_CIFS_STATS2 |
| 360 | atomic_set(&totBufAllocCount, 0); |
| 361 | atomic_set(&totSmBufAllocCount, 0); |
| 362 | #endif /* CONFIG_CIFS_STATS2 */ |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 363 | spin_lock(&cifs_tcp_ses_lock); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 364 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
| 365 | server = list_entry(tmp1, struct TCP_Server_Info, |
| 366 | tcp_ses_list); |
Steve French | c2b3382 | 2008-11-17 03:57:13 +0000 | [diff] [blame] | 367 | list_for_each(tmp2, &server->smb_ses_list) { |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 368 | ses = list_entry(tmp2, struct cifs_ses, |
Steve French | c2b3382 | 2008-11-17 03:57:13 +0000 | [diff] [blame] | 369 | smb_ses_list); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 370 | list_for_each(tmp3, &ses->tcon_list) { |
| 371 | tcon = list_entry(tmp3, |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 372 | struct cifs_tcon, |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 373 | tcon_list); |
| 374 | atomic_set(&tcon->num_smbs_sent, 0); |
Pavel Shilovsky | 44c5818 | 2012-05-28 14:16:31 +0400 | [diff] [blame] | 375 | if (server->ops->clear_stats) |
| 376 | server->ops->clear_stats(tcon); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 377 | } |
| 378 | } |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 379 | } |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 380 | spin_unlock(&cifs_tcp_ses_lock); |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 381 | } else { |
| 382 | return rc; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 385 | return count; |
Steve French | 1047abc | 2005-10-11 19:58:06 -0700 | [diff] [blame] | 386 | } |
| 387 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 388 | static int cifs_stats_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 390 | int i; |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 391 | struct list_head *tmp1, *tmp2, *tmp3; |
| 392 | struct TCP_Server_Info *server; |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 393 | struct cifs_ses *ses; |
| 394 | struct cifs_tcon *tcon; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 396 | seq_printf(m, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | "Resources in use\nCIFS Session: %d\n", |
| 398 | sesInfoAllocCount.counter); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 399 | seq_printf(m, "Share (unique mount targets): %d\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | tconInfoAllocCount.counter); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 401 | seq_printf(m, "SMB Request/Response Buffer: %d Pool size: %d\n", |
Steve French | b8643e1 | 2005-04-28 22:41:07 -0700 | [diff] [blame] | 402 | bufAllocCount.counter, |
| 403 | cifs_min_rcv + tcpSesAllocCount.counter); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 404 | seq_printf(m, "SMB Small Req/Resp Buffer: %d Pool size: %d\n", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 405 | smBufAllocCount.counter, cifs_min_small); |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 406 | #ifdef CONFIG_CIFS_STATS2 |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 407 | seq_printf(m, "Total Large %d Small %d Allocations\n", |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 408 | atomic_read(&totBufAllocCount), |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 409 | atomic_read(&totSmBufAllocCount)); |
Steve French | 07475ff | 2005-12-03 14:11:37 -0800 | [diff] [blame] | 410 | #endif /* CONFIG_CIFS_STATS2 */ |
| 411 | |
Jeff Layton | 8097531 | 2011-01-11 07:24:02 -0500 | [diff] [blame] | 412 | seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount)); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 413 | seq_printf(m, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | "\n%d session %d share reconnects\n", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 415 | tcpSesReconnectCount.counter, tconInfoReconnectCount.counter); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 417 | seq_printf(m, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | "Total vfs operations: %d maximum at one time: %d\n", |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 419 | GlobalCurrentXid, GlobalMaxActiveXid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
| 421 | i = 0; |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 422 | spin_lock(&cifs_tcp_ses_lock); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 423 | list_for_each(tmp1, &cifs_tcp_ses_list) { |
| 424 | server = list_entry(tmp1, struct TCP_Server_Info, |
| 425 | tcp_ses_list); |
| 426 | list_for_each(tmp2, &server->smb_ses_list) { |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 427 | ses = list_entry(tmp2, struct cifs_ses, |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 428 | smb_ses_list); |
| 429 | list_for_each(tmp3, &ses->tcon_list) { |
| 430 | tcon = list_entry(tmp3, |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 431 | struct cifs_tcon, |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 432 | tcon_list); |
| 433 | i++; |
| 434 | seq_printf(m, "\n%d) %s", i, tcon->treeName); |
| 435 | if (tcon->need_reconnect) |
| 436 | seq_puts(m, "\tDISCONNECTED "); |
Pavel Shilovsky | 44c5818 | 2012-05-28 14:16:31 +0400 | [diff] [blame] | 437 | seq_printf(m, "\nSMBs: %d", |
| 438 | atomic_read(&tcon->num_smbs_sent)); |
| 439 | if (server->ops->print_stats) |
| 440 | server->ops->print_stats(m, tcon); |
Jeff Layton | f1987b4 | 2008-11-15 11:12:47 -0500 | [diff] [blame] | 441 | } |
| 442 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | } |
Suresh Jayaraman | 3f9bcca | 2010-10-18 23:29:37 +0530 | [diff] [blame] | 444 | spin_unlock(&cifs_tcp_ses_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 446 | seq_putc(m, '\n'); |
| 447 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 449 | |
| 450 | static int cifs_stats_proc_open(struct inode *inode, struct file *file) |
| 451 | { |
| 452 | return single_open(file, cifs_stats_proc_show, NULL); |
| 453 | } |
| 454 | |
| 455 | static const struct file_operations cifs_stats_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 456 | .open = cifs_stats_proc_open, |
| 457 | .read = seq_read, |
| 458 | .llseek = seq_lseek, |
| 459 | .release = single_release, |
| 460 | .write = cifs_stats_proc_write, |
| 461 | }; |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 462 | #endif /* STATS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Long Li | d8ec913 | 2017-11-07 01:54:58 -0700 | [diff] [blame] | 464 | #ifdef CONFIG_CIFS_SMB_DIRECT |
| 465 | #define PROC_FILE_DEFINE(name) \ |
| 466 | static ssize_t name##_write(struct file *file, const char __user *buffer, \ |
| 467 | size_t count, loff_t *ppos) \ |
| 468 | { \ |
| 469 | int rc; \ |
| 470 | rc = kstrtoint_from_user(buffer, count, 10, & name); \ |
| 471 | if (rc) \ |
| 472 | return rc; \ |
| 473 | return count; \ |
| 474 | } \ |
| 475 | static int name##_proc_show(struct seq_file *m, void *v) \ |
| 476 | { \ |
| 477 | seq_printf(m, "%d\n", name ); \ |
| 478 | return 0; \ |
| 479 | } \ |
| 480 | static int name##_open(struct inode *inode, struct file *file) \ |
| 481 | { \ |
| 482 | return single_open(file, name##_proc_show, NULL); \ |
| 483 | } \ |
| 484 | \ |
| 485 | static const struct file_operations cifs_##name##_proc_fops = { \ |
| 486 | .open = name##_open, \ |
| 487 | .read = seq_read, \ |
| 488 | .llseek = seq_lseek, \ |
| 489 | .release = single_release, \ |
| 490 | .write = name##_write, \ |
| 491 | } |
| 492 | |
Long Li | d8ec913 | 2017-11-07 01:54:58 -0700 | [diff] [blame] | 493 | PROC_FILE_DEFINE(rdma_readwrite_threshold); |
| 494 | PROC_FILE_DEFINE(smbd_max_frmr_depth); |
| 495 | PROC_FILE_DEFINE(smbd_keep_alive_interval); |
| 496 | PROC_FILE_DEFINE(smbd_max_receive_size); |
| 497 | PROC_FILE_DEFINE(smbd_max_fragmented_recv_size); |
| 498 | PROC_FILE_DEFINE(smbd_max_send_size); |
| 499 | PROC_FILE_DEFINE(smbd_send_credit_target); |
| 500 | PROC_FILE_DEFINE(smbd_receive_credit_max); |
| 501 | #endif |
| 502 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | static struct proc_dir_entry *proc_fs_cifs; |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 504 | static const struct file_operations cifsFYI_proc_fops; |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 505 | static const struct file_operations cifs_lookup_cache_proc_fops; |
| 506 | static const struct file_operations traceSMB_proc_fops; |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 507 | static const struct file_operations cifs_security_flags_proc_fops; |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 508 | static const struct file_operations cifs_linux_ext_proc_fops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
| 510 | void |
| 511 | cifs_proc_init(void) |
| 512 | { |
Alexey Dobriyan | 36a5aeb | 2008-04-29 01:01:42 -0700 | [diff] [blame] | 513 | proc_fs_cifs = proc_mkdir("fs/cifs", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | if (proc_fs_cifs == NULL) |
| 515 | return; |
| 516 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 517 | proc_create("DebugData", 0, proc_fs_cifs, &cifs_debug_data_proc_fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | |
| 519 | #ifdef CONFIG_CIFS_STATS |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 520 | proc_create("Stats", 0, proc_fs_cifs, &cifs_stats_proc_fops); |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 521 | #endif /* STATS */ |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 522 | proc_create("cifsFYI", 0, proc_fs_cifs, &cifsFYI_proc_fops); |
| 523 | proc_create("traceSMB", 0, proc_fs_cifs, &traceSMB_proc_fops); |
Steve French | 99b1f5b | 2008-07-24 02:37:45 +0000 | [diff] [blame] | 524 | proc_create("LinuxExtensionsEnabled", 0, proc_fs_cifs, |
| 525 | &cifs_linux_ext_proc_fops); |
Steve French | 99b1f5b | 2008-07-24 02:37:45 +0000 | [diff] [blame] | 526 | proc_create("SecurityFlags", 0, proc_fs_cifs, |
| 527 | &cifs_security_flags_proc_fops); |
| 528 | proc_create("LookupCacheEnabled", 0, proc_fs_cifs, |
| 529 | &cifs_lookup_cache_proc_fops); |
Long Li | d8ec913 | 2017-11-07 01:54:58 -0700 | [diff] [blame] | 530 | #ifdef CONFIG_CIFS_SMB_DIRECT |
| 531 | proc_create("rdma_readwrite_threshold", 0, proc_fs_cifs, |
| 532 | &cifs_rdma_readwrite_threshold_proc_fops); |
| 533 | proc_create("smbd_max_frmr_depth", 0, proc_fs_cifs, |
| 534 | &cifs_smbd_max_frmr_depth_proc_fops); |
| 535 | proc_create("smbd_keep_alive_interval", 0, proc_fs_cifs, |
| 536 | &cifs_smbd_keep_alive_interval_proc_fops); |
| 537 | proc_create("smbd_max_receive_size", 0, proc_fs_cifs, |
| 538 | &cifs_smbd_max_receive_size_proc_fops); |
| 539 | proc_create("smbd_max_fragmented_recv_size", 0, proc_fs_cifs, |
| 540 | &cifs_smbd_max_fragmented_recv_size_proc_fops); |
| 541 | proc_create("smbd_max_send_size", 0, proc_fs_cifs, |
| 542 | &cifs_smbd_max_send_size_proc_fops); |
| 543 | proc_create("smbd_send_credit_target", 0, proc_fs_cifs, |
| 544 | &cifs_smbd_send_credit_target_proc_fops); |
| 545 | proc_create("smbd_receive_credit_max", 0, proc_fs_cifs, |
| 546 | &cifs_smbd_receive_credit_max_proc_fops); |
| 547 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | void |
| 551 | cifs_proc_clean(void) |
| 552 | { |
| 553 | if (proc_fs_cifs == NULL) |
| 554 | return; |
| 555 | |
| 556 | remove_proc_entry("DebugData", proc_fs_cifs); |
| 557 | remove_proc_entry("cifsFYI", proc_fs_cifs); |
| 558 | remove_proc_entry("traceSMB", proc_fs_cifs); |
| 559 | #ifdef CONFIG_CIFS_STATS |
| 560 | remove_proc_entry("Stats", proc_fs_cifs); |
| 561 | #endif |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 562 | remove_proc_entry("SecurityFlags", proc_fs_cifs); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 563 | remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 564 | remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); |
Long Li | d8ec913 | 2017-11-07 01:54:58 -0700 | [diff] [blame] | 565 | #ifdef CONFIG_CIFS_SMB_DIRECT |
| 566 | remove_proc_entry("rdma_readwrite_threshold", proc_fs_cifs); |
| 567 | remove_proc_entry("smbd_max_frmr_depth", proc_fs_cifs); |
| 568 | remove_proc_entry("smbd_keep_alive_interval", proc_fs_cifs); |
| 569 | remove_proc_entry("smbd_max_receive_size", proc_fs_cifs); |
| 570 | remove_proc_entry("smbd_max_fragmented_recv_size", proc_fs_cifs); |
| 571 | remove_proc_entry("smbd_max_send_size", proc_fs_cifs); |
| 572 | remove_proc_entry("smbd_send_credit_target", proc_fs_cifs); |
| 573 | remove_proc_entry("smbd_receive_credit_max", proc_fs_cifs); |
| 574 | #endif |
Alexey Dobriyan | 36a5aeb | 2008-04-29 01:01:42 -0700 | [diff] [blame] | 575 | remove_proc_entry("fs/cifs", NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | } |
| 577 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 578 | static int cifsFYI_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 580 | seq_printf(m, "%d\n", cifsFYI); |
| 581 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 583 | |
| 584 | static int cifsFYI_proc_open(struct inode *inode, struct file *file) |
| 585 | { |
| 586 | return single_open(file, cifsFYI_proc_show, NULL); |
| 587 | } |
| 588 | |
| 589 | static ssize_t cifsFYI_proc_write(struct file *file, const char __user *buffer, |
| 590 | size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | { |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 592 | char c[2] = { '\0' }; |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 593 | bool bv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | int rc; |
| 595 | |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 596 | rc = get_user(c[0], buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | if (rc) |
| 598 | return rc; |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 599 | if (strtobool(c, &bv) == 0) |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 600 | cifsFYI = bv; |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 601 | else if ((c[0] > '1') && (c[0] <= '9')) |
| 602 | cifsFYI = (int) (c[0] - '0'); /* see cifs_debug.h for meanings */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 603 | |
| 604 | return count; |
| 605 | } |
| 606 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 607 | static const struct file_operations cifsFYI_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 608 | .open = cifsFYI_proc_open, |
| 609 | .read = seq_read, |
| 610 | .llseek = seq_lseek, |
| 611 | .release = single_release, |
| 612 | .write = cifsFYI_proc_write, |
| 613 | }; |
| 614 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 615 | static int cifs_linux_ext_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 617 | seq_printf(m, "%d\n", linuxExtEnabled); |
| 618 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 620 | |
| 621 | static int cifs_linux_ext_proc_open(struct inode *inode, struct file *file) |
| 622 | { |
| 623 | return single_open(file, cifs_linux_ext_proc_show, NULL); |
| 624 | } |
| 625 | |
| 626 | static ssize_t cifs_linux_ext_proc_write(struct file *file, |
| 627 | const char __user *buffer, size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | { |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 629 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 631 | rc = kstrtobool_from_user(buffer, count, &linuxExtEnabled); |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 632 | if (rc) |
| 633 | return rc; |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 634 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 635 | return count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | } |
| 637 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 638 | static const struct file_operations cifs_linux_ext_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 639 | .open = cifs_linux_ext_proc_open, |
| 640 | .read = seq_read, |
| 641 | .llseek = seq_lseek, |
| 642 | .release = single_release, |
| 643 | .write = cifs_linux_ext_proc_write, |
| 644 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 646 | static int cifs_lookup_cache_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 648 | seq_printf(m, "%d\n", lookupCacheEnabled); |
| 649 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 651 | |
| 652 | static int cifs_lookup_cache_proc_open(struct inode *inode, struct file *file) |
| 653 | { |
| 654 | return single_open(file, cifs_lookup_cache_proc_show, NULL); |
| 655 | } |
| 656 | |
| 657 | static ssize_t cifs_lookup_cache_proc_write(struct file *file, |
| 658 | const char __user *buffer, size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 659 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | int rc; |
| 661 | |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 662 | rc = kstrtobool_from_user(buffer, count, &lookupCacheEnabled); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | if (rc) |
| 664 | return rc; |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 665 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | return count; |
| 667 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 668 | |
| 669 | static const struct file_operations cifs_lookup_cache_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 670 | .open = cifs_lookup_cache_proc_open, |
| 671 | .read = seq_read, |
| 672 | .llseek = seq_lseek, |
| 673 | .release = single_release, |
| 674 | .write = cifs_lookup_cache_proc_write, |
| 675 | }; |
| 676 | |
| 677 | static int traceSMB_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 679 | seq_printf(m, "%d\n", traceSMB); |
| 680 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 682 | |
| 683 | static int traceSMB_proc_open(struct inode *inode, struct file *file) |
| 684 | { |
| 685 | return single_open(file, traceSMB_proc_show, NULL); |
| 686 | } |
| 687 | |
| 688 | static ssize_t traceSMB_proc_write(struct file *file, const char __user *buffer, |
| 689 | size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | int rc; |
| 692 | |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 693 | rc = kstrtobool_from_user(buffer, count, &traceSMB); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | if (rc) |
| 695 | return rc; |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 696 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 697 | return count; |
| 698 | } |
| 699 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 700 | static const struct file_operations traceSMB_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 701 | .open = traceSMB_proc_open, |
| 702 | .read = seq_read, |
| 703 | .llseek = seq_lseek, |
| 704 | .release = single_release, |
| 705 | .write = traceSMB_proc_write, |
| 706 | }; |
| 707 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 708 | static int cifs_security_flags_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 709 | { |
Jeff Layton | 04912d6 | 2010-04-24 07:57:45 -0400 | [diff] [blame] | 710 | seq_printf(m, "0x%x\n", global_secflags); |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 711 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 713 | |
| 714 | static int cifs_security_flags_proc_open(struct inode *inode, struct file *file) |
| 715 | { |
| 716 | return single_open(file, cifs_security_flags_proc_show, NULL); |
| 717 | } |
| 718 | |
Jeff Layton | 52dfb44 | 2013-05-26 07:01:02 -0400 | [diff] [blame] | 719 | /* |
| 720 | * Ensure that if someone sets a MUST flag, that we disable all other MAY |
| 721 | * flags except for the ones corresponding to the given MUST flag. If there are |
| 722 | * multiple MUST flags, then try to prefer more secure ones. |
| 723 | */ |
| 724 | static void |
| 725 | cifs_security_flags_handle_must_flags(unsigned int *flags) |
| 726 | { |
| 727 | unsigned int signflags = *flags & CIFSSEC_MUST_SIGN; |
| 728 | |
| 729 | if ((*flags & CIFSSEC_MUST_KRB5) == CIFSSEC_MUST_KRB5) |
| 730 | *flags = CIFSSEC_MUST_KRB5; |
| 731 | else if ((*flags & CIFSSEC_MUST_NTLMSSP) == CIFSSEC_MUST_NTLMSSP) |
| 732 | *flags = CIFSSEC_MUST_NTLMSSP; |
| 733 | else if ((*flags & CIFSSEC_MUST_NTLMV2) == CIFSSEC_MUST_NTLMV2) |
| 734 | *flags = CIFSSEC_MUST_NTLMV2; |
| 735 | else if ((*flags & CIFSSEC_MUST_NTLM) == CIFSSEC_MUST_NTLM) |
| 736 | *flags = CIFSSEC_MUST_NTLM; |
Niklas Cassel | 7a1ceba | 2015-01-22 14:16:34 +0100 | [diff] [blame] | 737 | else if (CIFSSEC_MUST_LANMAN && |
| 738 | (*flags & CIFSSEC_MUST_LANMAN) == CIFSSEC_MUST_LANMAN) |
Jeff Layton | 52dfb44 | 2013-05-26 07:01:02 -0400 | [diff] [blame] | 739 | *flags = CIFSSEC_MUST_LANMAN; |
Niklas Cassel | 7a1ceba | 2015-01-22 14:16:34 +0100 | [diff] [blame] | 740 | else if (CIFSSEC_MUST_PLNTXT && |
| 741 | (*flags & CIFSSEC_MUST_PLNTXT) == CIFSSEC_MUST_PLNTXT) |
Jeff Layton | 52dfb44 | 2013-05-26 07:01:02 -0400 | [diff] [blame] | 742 | *flags = CIFSSEC_MUST_PLNTXT; |
| 743 | |
| 744 | *flags |= signflags; |
| 745 | } |
| 746 | |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 747 | static ssize_t cifs_security_flags_proc_write(struct file *file, |
| 748 | const char __user *buffer, size_t count, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 749 | { |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 750 | int rc; |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 751 | unsigned int flags; |
| 752 | char flags_string[12]; |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 753 | bool bv; |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 754 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 755 | if ((count < 1) || (count > 11)) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 756 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 758 | memset(flags_string, 0, 12); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 759 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 760 | if (copy_from_user(flags_string, buffer, count)) |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 761 | return -EFAULT; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 762 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 763 | if (count < 3) { |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 764 | /* single char or single char followed by null */ |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 765 | if (strtobool(flags_string, &bv) == 0) { |
Andy Shevchenko | 28e2aed | 2014-08-27 16:49:42 +0300 | [diff] [blame] | 766 | global_secflags = bv ? CIFSSEC_MAX : CIFSSEC_DEF; |
Steve French | a013689 | 2007-10-04 20:05:09 +0000 | [diff] [blame] | 767 | return count; |
Kees Cook | 1404297 | 2016-03-17 14:22:54 -0700 | [diff] [blame] | 768 | } else if (!isdigit(flags_string[0])) { |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 769 | cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", |
| 770 | flags_string); |
Steve French | a013689 | 2007-10-04 20:05:09 +0000 | [diff] [blame] | 771 | return -EINVAL; |
| 772 | } |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 773 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 775 | /* else we have a number */ |
| 776 | rc = kstrtouint(flags_string, 0, &flags); |
| 777 | if (rc) { |
| 778 | cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", |
| 779 | flags_string); |
| 780 | return rc; |
| 781 | } |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 782 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 783 | cifs_dbg(FYI, "sec flags 0x%x\n", flags); |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 784 | |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 785 | if (flags == 0) { |
| 786 | cifs_dbg(VFS, "Invalid SecurityFlags: %s\n", flags_string); |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 787 | return -EINVAL; |
| 788 | } |
| 789 | |
Steve French | 221601c | 2007-06-05 20:35:06 +0000 | [diff] [blame] | 790 | if (flags & ~CIFSSEC_MASK) { |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 791 | cifs_dbg(VFS, "Unsupported security flags: 0x%x\n", |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 792 | flags & ~CIFSSEC_MASK); |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 793 | return -EINVAL; |
| 794 | } |
Jeff Layton | 7715dad | 2013-05-26 07:01:01 -0400 | [diff] [blame] | 795 | |
Jeff Layton | 52dfb44 | 2013-05-26 07:01:02 -0400 | [diff] [blame] | 796 | cifs_security_flags_handle_must_flags(&flags); |
| 797 | |
Steve French | bdc4bf6e | 2006-06-02 22:57:13 +0000 | [diff] [blame] | 798 | /* flags look ok - update the global security flags for cifs module */ |
Jeff Layton | 04912d6 | 2010-04-24 07:57:45 -0400 | [diff] [blame] | 799 | global_secflags = flags; |
| 800 | if (global_secflags & CIFSSEC_MUST_SIGN) { |
Steve French | 762e5ab | 2007-06-28 18:41:42 +0000 | [diff] [blame] | 801 | /* requiring signing implies signing is allowed */ |
Jeff Layton | 04912d6 | 2010-04-24 07:57:45 -0400 | [diff] [blame] | 802 | global_secflags |= CIFSSEC_MAY_SIGN; |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 803 | cifs_dbg(FYI, "packet signing now required\n"); |
Jeff Layton | 04912d6 | 2010-04-24 07:57:45 -0400 | [diff] [blame] | 804 | } else if ((global_secflags & CIFSSEC_MAY_SIGN) == 0) { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 805 | cifs_dbg(FYI, "packet signing disabled\n"); |
Steve French | 762e5ab | 2007-06-28 18:41:42 +0000 | [diff] [blame] | 806 | } |
| 807 | /* BB should we turn on MAY flags for other MUST options? */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | return count; |
| 809 | } |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 810 | |
| 811 | static const struct file_operations cifs_security_flags_proc_fops = { |
Alexey Dobriyan | f984c7b | 2008-07-24 02:34:24 +0000 | [diff] [blame] | 812 | .open = cifs_security_flags_proc_open, |
| 813 | .read = seq_read, |
| 814 | .llseek = seq_lseek, |
| 815 | .release = single_release, |
| 816 | .write = cifs_security_flags_proc_write, |
| 817 | }; |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 818 | #else |
Steve French | e086fce | 2008-02-18 04:03:58 +0000 | [diff] [blame] | 819 | inline void cifs_proc_init(void) |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 820 | { |
| 821 | } |
| 822 | |
Steve French | e086fce | 2008-02-18 04:03:58 +0000 | [diff] [blame] | 823 | inline void cifs_proc_clean(void) |
Steve French | 90c81e0 | 2008-02-12 20:32:36 +0000 | [diff] [blame] | 824 | { |
| 825 | } |
| 826 | #endif /* PROC_FS */ |