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