Steve French | 929be90 | 2021-06-18 00:31:49 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: LGPL-2.1 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 2 | /* |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 3 | * |
| 4 | * SMB/CIFS session setup handling routines |
| 5 | * |
Steve French | d185cda | 2009-04-30 17:45:10 +0000 | [diff] [blame] | 6 | * Copyright (c) International Business Machines Corp., 2006, 2009 |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 7 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 8 | * |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include "cifspdu.h" |
| 12 | #include "cifsglob.h" |
| 13 | #include "cifsproto.h" |
| 14 | #include "cifs_unicode.h" |
| 15 | #include "cifs_debug.h" |
| 16 | #include "ntlmssp.h" |
| 17 | #include "nterr.h" |
Steve French | 9c53588 | 2006-06-01 05:09:10 +0000 | [diff] [blame] | 18 | #include <linux/utsname.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Steve French | 2442421 | 2007-11-16 23:37:35 +0000 | [diff] [blame] | 20 | #include "cifs_spnego.h" |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 21 | #include "smb2proto.h" |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 22 | #include "fs_context.h" |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 23 | |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 24 | static int |
| 25 | cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, |
| 26 | struct cifs_server_iface *iface); |
| 27 | |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 28 | bool |
| 29 | is_server_using_iface(struct TCP_Server_Info *server, |
| 30 | struct cifs_server_iface *iface) |
| 31 | { |
| 32 | struct sockaddr_in *i4 = (struct sockaddr_in *)&iface->sockaddr; |
| 33 | struct sockaddr_in6 *i6 = (struct sockaddr_in6 *)&iface->sockaddr; |
| 34 | struct sockaddr_in *s4 = (struct sockaddr_in *)&server->dstaddr; |
| 35 | struct sockaddr_in6 *s6 = (struct sockaddr_in6 *)&server->dstaddr; |
| 36 | |
| 37 | if (server->dstaddr.ss_family != iface->sockaddr.ss_family) |
| 38 | return false; |
| 39 | if (server->dstaddr.ss_family == AF_INET) { |
| 40 | if (s4->sin_addr.s_addr != i4->sin_addr.s_addr) |
| 41 | return false; |
| 42 | } else if (server->dstaddr.ss_family == AF_INET6) { |
| 43 | if (memcmp(&s6->sin6_addr, &i6->sin6_addr, |
| 44 | sizeof(i6->sin6_addr)) != 0) |
| 45 | return false; |
| 46 | } else { |
| 47 | /* unknown family.. */ |
| 48 | return false; |
| 49 | } |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface) |
| 54 | { |
| 55 | int i; |
| 56 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 57 | spin_lock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 58 | for (i = 0; i < ses->chan_count; i++) { |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 59 | if (is_server_using_iface(ses->chans[i].server, iface)) { |
| 60 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 61 | return true; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 62 | } |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 63 | } |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 64 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 65 | return false; |
| 66 | } |
| 67 | |
| 68 | /* returns number of channels added */ |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 69 | int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses) |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 70 | { |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 71 | int old_chan_count, new_chan_count; |
| 72 | int left; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 73 | int i = 0; |
| 74 | int rc = 0; |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 75 | int tries = 0; |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 76 | struct cifs_server_iface *ifaces = NULL; |
| 77 | size_t iface_count; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 78 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 79 | if (ses->server->dialect < SMB30_PROT_ID) { |
| 80 | cifs_dbg(VFS, "multichannel is not supported on this protocol version, use 3.0 or above\n"); |
| 81 | return 0; |
| 82 | } |
| 83 | |
| 84 | spin_lock(&ses->chan_lock); |
| 85 | |
| 86 | new_chan_count = old_chan_count = ses->chan_count; |
| 87 | left = ses->chan_max - ses->chan_count; |
| 88 | |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 89 | if (left <= 0) { |
| 90 | cifs_dbg(FYI, |
| 91 | "ses already at max_channels (%zu), nothing to open\n", |
| 92 | ses->chan_max); |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 93 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 94 | return 0; |
| 95 | } |
| 96 | |
Steve French | 9c2dc11 | 2021-05-07 20:00:41 -0500 | [diff] [blame] | 97 | if (!(ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) { |
| 98 | cifs_dbg(VFS, "server %s does not support multichannel\n", ses->server->hostname); |
| 99 | ses->chan_max = 1; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 100 | spin_unlock(&ses->chan_lock); |
Steve French | 9c2dc11 | 2021-05-07 20:00:41 -0500 | [diff] [blame] | 101 | return 0; |
| 102 | } |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 103 | spin_unlock(&ses->chan_lock); |
Steve French | 9c2dc11 | 2021-05-07 20:00:41 -0500 | [diff] [blame] | 104 | |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 105 | /* |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 106 | * Make a copy of the iface list at the time and use that |
| 107 | * instead so as to not hold the iface spinlock for opening |
| 108 | * channels |
| 109 | */ |
| 110 | spin_lock(&ses->iface_lock); |
| 111 | iface_count = ses->iface_count; |
| 112 | if (iface_count <= 0) { |
| 113 | spin_unlock(&ses->iface_lock); |
Aurelien Aptel | 343a1b7 | 2020-02-06 10:19:11 +0100 | [diff] [blame] | 114 | cifs_dbg(VFS, "no iface list available to open channels\n"); |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 115 | return 0; |
| 116 | } |
| 117 | ifaces = kmemdup(ses->iface_list, iface_count*sizeof(*ifaces), |
| 118 | GFP_ATOMIC); |
| 119 | if (!ifaces) { |
| 120 | spin_unlock(&ses->iface_lock); |
| 121 | return 0; |
| 122 | } |
| 123 | spin_unlock(&ses->iface_lock); |
| 124 | |
| 125 | /* |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 126 | * Keep connecting to same, fastest, iface for all channels as |
| 127 | * long as its RSS. Try next fastest one if not RSS or channel |
| 128 | * creation fails. |
| 129 | */ |
| 130 | while (left > 0) { |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 131 | struct cifs_server_iface *iface; |
| 132 | |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 133 | tries++; |
| 134 | if (tries > 3*ses->chan_max) { |
Steve French | bbbf9ea | 2020-05-30 17:29:50 -0500 | [diff] [blame] | 135 | cifs_dbg(FYI, "too many channel open attempts (%d channels left to open)\n", |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 136 | left); |
| 137 | break; |
| 138 | } |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 139 | |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 140 | iface = &ifaces[i]; |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 141 | if (is_ses_using_iface(ses, iface) && !iface->rss_capable) { |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 142 | i = (i+1) % iface_count; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 143 | continue; |
| 144 | } |
| 145 | |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 146 | rc = cifs_ses_add_channel(cifs_sb, ses, iface); |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 147 | if (rc) { |
| 148 | cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n", |
| 149 | i, rc); |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 150 | i = (i+1) % iface_count; |
Aurelien Aptel | 65a37a3 | 2019-11-20 17:15:59 +0100 | [diff] [blame] | 151 | continue; |
| 152 | } |
| 153 | |
| 154 | cifs_dbg(FYI, "successfully opened new channel on iface#%d\n", |
| 155 | i); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 156 | left--; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 157 | new_chan_count++; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 158 | } |
| 159 | |
Aurelien Aptel | 9a7d5a9 | 2019-12-04 16:14:54 +0100 | [diff] [blame] | 160 | kfree(ifaces); |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 161 | return new_chan_count - old_chan_count; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Aurelien Aptel | 2f58967 | 2020-04-24 16:55:31 +0200 | [diff] [blame] | 164 | /* |
| 165 | * If server is a channel of ses, return the corresponding enclosing |
| 166 | * cifs_chan otherwise return NULL. |
| 167 | */ |
| 168 | struct cifs_chan * |
| 169 | cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server) |
| 170 | { |
| 171 | int i; |
| 172 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 173 | spin_lock(&ses->chan_lock); |
Aurelien Aptel | 2f58967 | 2020-04-24 16:55:31 +0200 | [diff] [blame] | 174 | for (i = 0; i < ses->chan_count; i++) { |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 175 | if (ses->chans[i].server == server) { |
| 176 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | 2f58967 | 2020-04-24 16:55:31 +0200 | [diff] [blame] | 177 | return &ses->chans[i]; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 178 | } |
Aurelien Aptel | 2f58967 | 2020-04-24 16:55:31 +0200 | [diff] [blame] | 179 | } |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 180 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | 2f58967 | 2020-04-24 16:55:31 +0200 | [diff] [blame] | 181 | return NULL; |
| 182 | } |
| 183 | |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 184 | static int |
| 185 | cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, |
| 186 | struct cifs_server_iface *iface) |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 187 | { |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 188 | struct TCP_Server_Info *chan_server; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 189 | struct cifs_chan *chan; |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 190 | struct smb3_fs_context ctx = {NULL}; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 191 | static const char unc_fmt[] = "\\%s\\foo"; |
| 192 | char unc[sizeof(unc_fmt)+SERVER_NAME_LEN_WITH_NULL] = {0}; |
| 193 | struct sockaddr_in *ipv4 = (struct sockaddr_in *)&iface->sockaddr; |
| 194 | struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)&iface->sockaddr; |
| 195 | int rc; |
| 196 | unsigned int xid = get_xid(); |
| 197 | |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 198 | if (iface->sockaddr.ss_family == AF_INET) |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 199 | cifs_dbg(FYI, "adding channel to ses %p (speed:%zu bps rdma:%s ip:%pI4)\n", |
| 200 | ses, iface->speed, iface->rdma_capable ? "yes" : "no", |
| 201 | &ipv4->sin_addr); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 202 | else |
Aurelien Aptel | 5e53895 | 2021-05-28 16:32:48 +0200 | [diff] [blame] | 203 | cifs_dbg(FYI, "adding channel to ses %p (speed:%zu bps rdma:%s ip:%pI6)\n", |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 204 | ses, iface->speed, iface->rdma_capable ? "yes" : "no", |
| 205 | &ipv6->sin6_addr); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 206 | |
| 207 | /* |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 208 | * Setup a ctx with mostly the same info as the existing |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 209 | * session and overwrite it with the requested iface data. |
| 210 | * |
| 211 | * We need to setup at least the fields used for negprot and |
| 212 | * sesssetup. |
| 213 | * |
Ronnie Sahlberg | 24e0a1e | 2020-12-10 00:06:02 -0600 | [diff] [blame] | 214 | * We only need the ctx here, so we can reuse memory from |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 215 | * the session and server without caring about memory |
| 216 | * management. |
| 217 | */ |
| 218 | |
| 219 | /* Always make new connection for now (TODO?) */ |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 220 | ctx.nosharesock = true; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 221 | |
| 222 | /* Auth */ |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 223 | ctx.domainauto = ses->domainAuto; |
| 224 | ctx.domainname = ses->domainName; |
| 225 | ctx.username = ses->user_name; |
| 226 | ctx.password = ses->password; |
| 227 | ctx.sectype = ses->sectype; |
| 228 | ctx.sign = ses->sign; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 229 | |
| 230 | /* UNC and paths */ |
| 231 | /* XXX: Use ses->server->hostname? */ |
Steve French | b438fcf | 2021-02-20 19:24:11 -0600 | [diff] [blame] | 232 | sprintf(unc, unc_fmt, ses->ip_addr); |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 233 | ctx.UNC = unc; |
| 234 | ctx.prepath = ""; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 235 | |
Steve French | bbbf9ea | 2020-05-30 17:29:50 -0500 | [diff] [blame] | 236 | /* Reuse same version as master connection */ |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 237 | ctx.vals = ses->server->vals; |
| 238 | ctx.ops = ses->server->ops; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 239 | |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 240 | ctx.noblocksnd = ses->server->noblocksnd; |
| 241 | ctx.noautotune = ses->server->noautotune; |
| 242 | ctx.sockopt_tcp_nodelay = ses->server->tcp_nodelay; |
| 243 | ctx.echo_interval = ses->server->echo_interval / HZ; |
Aurelien Aptel | a249cc8 | 2021-03-04 17:42:21 +0000 | [diff] [blame] | 244 | ctx.max_credits = ses->server->max_credits; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 245 | |
| 246 | /* |
| 247 | * This will be used for encoding/decoding user/domain/pw |
| 248 | * during sess setup auth. |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 249 | */ |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 250 | ctx.local_nls = cifs_sb->local_nls; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 251 | |
| 252 | /* Use RDMA if possible */ |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 253 | ctx.rdma = iface->rdma_capable; |
| 254 | memcpy(&ctx.dstaddr, &iface->sockaddr, sizeof(struct sockaddr_storage)); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 255 | |
| 256 | /* reuse master con client guid */ |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 257 | memcpy(&ctx.client_guid, ses->server->client_guid, |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 258 | SMB2_CLIENT_GUID_SIZE); |
Ronnie Sahlberg | 3fa1c6d | 2020-12-09 23:07:12 -0600 | [diff] [blame] | 259 | ctx.use_client_guid = true; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 260 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 261 | chan_server = cifs_get_tcp_session(&ctx); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 262 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 263 | mutex_lock(&ses->session_mutex); |
| 264 | spin_lock(&ses->chan_lock); |
Aurelien Aptel | 8eec795 | 2020-04-24 15:24:05 +0200 | [diff] [blame] | 265 | chan = ses->binding_chan = &ses->chans[ses->chan_count]; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 266 | chan->server = chan_server; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 267 | if (IS_ERR(chan->server)) { |
| 268 | rc = PTR_ERR(chan->server); |
| 269 | chan->server = NULL; |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 270 | spin_unlock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 271 | goto out; |
| 272 | } |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 273 | spin_unlock(&ses->chan_lock); |
| 274 | |
Paulo Alcantara (SUSE) | 3345bb4 | 2019-12-04 11:25:06 -0300 | [diff] [blame] | 275 | spin_lock(&cifs_tcp_ses_lock); |
| 276 | chan->server->is_channel = true; |
| 277 | spin_unlock(&cifs_tcp_ses_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 278 | |
| 279 | /* |
| 280 | * We need to allocate the server crypto now as we will need |
| 281 | * to sign packets before we generate the channel signing key |
| 282 | * (we sign with the session key) |
| 283 | */ |
| 284 | rc = smb311_crypto_shash_allocate(chan->server); |
| 285 | if (rc) { |
| 286 | cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__); |
| 287 | goto out; |
| 288 | } |
| 289 | |
| 290 | ses->binding = true; |
| 291 | rc = cifs_negotiate_protocol(xid, ses); |
| 292 | if (rc) |
| 293 | goto out; |
| 294 | |
Ronnie Sahlberg | 387ec58 | 2020-12-14 16:40:20 +1000 | [diff] [blame] | 295 | rc = cifs_setup_session(xid, ses, cifs_sb->local_nls); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 296 | if (rc) |
| 297 | goto out; |
| 298 | |
| 299 | /* success, put it on the list |
Steve French | bbbf9ea | 2020-05-30 17:29:50 -0500 | [diff] [blame] | 300 | * XXX: sharing ses between 2 tcp servers is not possible, the |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 301 | * way "internal" linked lists works in linux makes element |
| 302 | * only able to belong to one list |
| 303 | * |
| 304 | * the binding session is already established so the rest of |
| 305 | * the code should be able to look it up, no need to add the |
| 306 | * ses to the new server. |
| 307 | */ |
| 308 | |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 309 | spin_lock(&ses->chan_lock); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 310 | ses->chan_count++; |
| 311 | atomic_set(&ses->chan_seq, 0); |
Shyam Prasad N | 724244c | 2021-07-19 10:54:46 +0000 | [diff] [blame^] | 312 | spin_unlock(&ses->chan_lock); |
| 313 | |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 314 | out: |
| 315 | ses->binding = false; |
Aurelien Aptel | 8eec795 | 2020-04-24 15:24:05 +0200 | [diff] [blame] | 316 | ses->binding_chan = NULL; |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 317 | mutex_unlock(&ses->session_mutex); |
| 318 | |
| 319 | if (rc && chan->server) |
| 320 | cifs_put_tcp_session(chan->server, 0); |
Aurelien Aptel | d70e9fa | 2019-09-20 06:31:10 +0200 | [diff] [blame] | 321 | |
| 322 | return rc; |
| 323 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 324 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 325 | static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 326 | { |
| 327 | __u32 capabilities = 0; |
| 328 | |
| 329 | /* init fields common to all four types of SessSetup */ |
Steve French | eca6acf | 2009-02-20 05:43:09 +0000 | [diff] [blame] | 330 | /* Note that offsets for first seven fields in req struct are same */ |
| 331 | /* in CIFS Specs so does not matter which of 3 forms of struct */ |
| 332 | /* that we use in next few lines */ |
| 333 | /* Note that header is initialized to zero in header_assemble */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 334 | pSMB->req.AndXCommand = 0xFF; |
Jeff Layton | c974bef | 2011-10-11 06:41:32 -0400 | [diff] [blame] | 335 | pSMB->req.MaxBufferSize = cpu_to_le16(min_t(u32, |
| 336 | CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4, |
| 337 | USHRT_MAX)); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 338 | pSMB->req.MaxMpxCount = cpu_to_le16(ses->server->maxReq); |
Fabian Frederick | bc09d14 | 2014-12-10 15:41:15 -0800 | [diff] [blame] | 339 | pSMB->req.VcNumber = cpu_to_le16(1); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 340 | |
| 341 | /* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */ |
| 342 | |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 343 | /* BB verify whether signing required on neg or just on auth frame |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 344 | (and NTLM case) */ |
| 345 | |
| 346 | capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS | |
| 347 | CAP_LARGE_WRITE_X | CAP_LARGE_READ_X; |
| 348 | |
Jeff Layton | 38d77c5 | 2013-05-26 07:01:00 -0400 | [diff] [blame] | 349 | if (ses->server->sign) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 350 | pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; |
| 351 | |
| 352 | if (ses->capabilities & CAP_UNICODE) { |
| 353 | pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE; |
| 354 | capabilities |= CAP_UNICODE; |
| 355 | } |
| 356 | if (ses->capabilities & CAP_STATUS32) { |
| 357 | pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS; |
| 358 | capabilities |= CAP_STATUS32; |
| 359 | } |
| 360 | if (ses->capabilities & CAP_DFS) { |
| 361 | pSMB->req.hdr.Flags2 |= SMBFLG2_DFS; |
| 362 | capabilities |= CAP_DFS; |
| 363 | } |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 364 | if (ses->capabilities & CAP_UNIX) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 365 | capabilities |= CAP_UNIX; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 366 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 367 | return capabilities; |
| 368 | } |
| 369 | |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 370 | static void |
| 371 | unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp) |
| 372 | { |
| 373 | char *bcc_ptr = *pbcc_area; |
| 374 | int bytes_ret = 0; |
| 375 | |
| 376 | /* Copy OS version */ |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 377 | bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32, |
| 378 | nls_cp); |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 379 | bcc_ptr += 2 * bytes_ret; |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 380 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release, |
| 381 | 32, nls_cp); |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 382 | bcc_ptr += 2 * bytes_ret; |
| 383 | bcc_ptr += 2; /* trailing null */ |
| 384 | |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 385 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS, |
| 386 | 32, nls_cp); |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 387 | bcc_ptr += 2 * bytes_ret; |
| 388 | bcc_ptr += 2; /* trailing null */ |
| 389 | |
| 390 | *pbcc_area = bcc_ptr; |
| 391 | } |
| 392 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 393 | static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 394 | const struct nls_table *nls_cp) |
| 395 | { |
| 396 | char *bcc_ptr = *pbcc_area; |
| 397 | int bytes_ret = 0; |
| 398 | |
| 399 | /* copy domain */ |
| 400 | if (ses->domainName == NULL) { |
| 401 | /* Sending null domain better than using a bogus domain name (as |
| 402 | we did briefly in 2.6.18) since server will use its default */ |
| 403 | *bcc_ptr = 0; |
| 404 | *(bcc_ptr+1) = 0; |
| 405 | bytes_ret = 0; |
| 406 | } else |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 407 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName, |
Chen Gang | 057d633 | 2013-07-19 09:01:36 +0800 | [diff] [blame] | 408 | CIFS_MAX_DOMAINNAME_LEN, nls_cp); |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 409 | bcc_ptr += 2 * bytes_ret; |
| 410 | bcc_ptr += 2; /* account for null terminator */ |
| 411 | |
| 412 | *pbcc_area = bcc_ptr; |
| 413 | } |
| 414 | |
| 415 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 416 | static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 417 | const struct nls_table *nls_cp) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 418 | { |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 419 | char *bcc_ptr = *pbcc_area; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 420 | int bytes_ret = 0; |
| 421 | |
| 422 | /* BB FIXME add check that strings total less |
| 423 | than 335 or will need to send them as arrays */ |
| 424 | |
Steve French | 0223cf0 | 2006-06-27 19:50:57 +0000 | [diff] [blame] | 425 | /* unicode strings, must be word aligned before the call */ |
| 426 | /* if ((long) bcc_ptr % 2) { |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 427 | *bcc_ptr = 0; |
| 428 | bcc_ptr++; |
Steve French | 0223cf0 | 2006-06-27 19:50:57 +0000 | [diff] [blame] | 429 | } */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 430 | /* copy user */ |
Steve French | 8727c8a | 2011-02-25 01:11:56 -0600 | [diff] [blame] | 431 | if (ses->user_name == NULL) { |
Steve French | 6e659c6 | 2006-11-08 23:10:46 +0000 | [diff] [blame] | 432 | /* null user mount */ |
| 433 | *bcc_ptr = 0; |
| 434 | *(bcc_ptr+1) = 0; |
Steve French | 301a6a3 | 2010-02-06 07:08:53 +0000 | [diff] [blame] | 435 | } else { |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 436 | bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name, |
Scott Lovenberg | 8c3a2b4 | 2013-08-09 08:47:17 -0400 | [diff] [blame] | 437 | CIFS_MAX_USERNAME_LEN, nls_cp); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 438 | } |
| 439 | bcc_ptr += 2 * bytes_ret; |
| 440 | bcc_ptr += 2; /* account for null termination */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 441 | |
Jeff Layton | 0d3a01f | 2007-10-16 17:32:19 +0000 | [diff] [blame] | 442 | unicode_domain_string(&bcc_ptr, ses, nls_cp); |
| 443 | unicode_oslm_strings(&bcc_ptr, nls_cp); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 444 | |
| 445 | *pbcc_area = bcc_ptr; |
| 446 | } |
| 447 | |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 448 | static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 449 | const struct nls_table *nls_cp) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 450 | { |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 451 | char *bcc_ptr = *pbcc_area; |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 452 | int len; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 453 | |
| 454 | /* copy user */ |
| 455 | /* BB what about null user mounts - check that we do this BB */ |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 456 | /* copy user */ |
Shirish Pargaonkar | de47a41 | 2012-02-02 15:28:28 -0600 | [diff] [blame] | 457 | if (ses->user_name != NULL) { |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 458 | len = strscpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN); |
| 459 | if (WARN_ON_ONCE(len < 0)) |
| 460 | len = CIFS_MAX_USERNAME_LEN - 1; |
| 461 | bcc_ptr += len; |
Shirish Pargaonkar | de47a41 | 2012-02-02 15:28:28 -0600 | [diff] [blame] | 462 | } |
Steve French | 8727c8a | 2011-02-25 01:11:56 -0600 | [diff] [blame] | 463 | /* else null user mount */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 464 | *bcc_ptr = 0; |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 465 | bcc_ptr++; /* account for null termination */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 466 | |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 467 | /* copy domain */ |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 468 | if (ses->domainName != NULL) { |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 469 | len = strscpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN); |
| 470 | if (WARN_ON_ONCE(len < 0)) |
| 471 | len = CIFS_MAX_DOMAINNAME_LEN - 1; |
| 472 | bcc_ptr += len; |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 473 | } /* else we will send a null domain name |
Steve French | 6e659c6 | 2006-11-08 23:10:46 +0000 | [diff] [blame] | 474 | so the server will default to its own domain */ |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 475 | *bcc_ptr = 0; |
| 476 | bcc_ptr++; |
| 477 | |
| 478 | /* BB check for overflow here */ |
| 479 | |
| 480 | strcpy(bcc_ptr, "Linux version "); |
| 481 | bcc_ptr += strlen("Linux version "); |
Serge E. Hallyn | 96b644b | 2006-10-02 02:18:13 -0700 | [diff] [blame] | 482 | strcpy(bcc_ptr, init_utsname()->release); |
| 483 | bcc_ptr += strlen(init_utsname()->release) + 1; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 484 | |
| 485 | strcpy(bcc_ptr, CIFS_NETWORK_OPSYS); |
| 486 | bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1; |
| 487 | |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 488 | *pbcc_area = bcc_ptr; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 489 | } |
| 490 | |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 491 | static void |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 492 | decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses, |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 493 | const struct nls_table *nls_cp) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 494 | { |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 495 | int len; |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 496 | char *data = *pbcc_area; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 497 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 498 | cifs_dbg(FYI, "bleft %d\n", bleft); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 499 | |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 500 | kfree(ses->serverOS); |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 501 | ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 502 | cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS); |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 503 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; |
| 504 | data += len; |
| 505 | bleft -= len; |
| 506 | if (bleft <= 0) |
| 507 | return; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 508 | |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 509 | kfree(ses->serverNOS); |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 510 | ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 511 | cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS); |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 512 | len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2; |
| 513 | data += len; |
| 514 | bleft -= len; |
| 515 | if (bleft <= 0) |
| 516 | return; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 517 | |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 518 | kfree(ses->serverDomain); |
Steve French | acbbb76 | 2012-01-18 22:32:33 -0600 | [diff] [blame] | 519 | ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 520 | cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain); |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 521 | |
Jeff Layton | 5914079 | 2009-04-30 07:16:21 -0400 | [diff] [blame] | 522 | return; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Jeff Layton | 7d06645 | 2013-05-24 07:41:00 -0400 | [diff] [blame] | 525 | static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft, |
| 526 | struct cifs_ses *ses, |
| 527 | const struct nls_table *nls_cp) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 528 | { |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 529 | int len; |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 530 | char *bcc_ptr = *pbcc_area; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 531 | |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 532 | cifs_dbg(FYI, "decode sessetup ascii. bleft %d\n", bleft); |
Steve French | 50c2f75 | 2007-07-13 00:33:32 +0000 | [diff] [blame] | 533 | |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 534 | len = strnlen(bcc_ptr, bleft); |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 535 | if (len >= bleft) |
Jeff Layton | 7d06645 | 2013-05-24 07:41:00 -0400 | [diff] [blame] | 536 | return; |
Steve French | 50c2f75 | 2007-07-13 00:33:32 +0000 | [diff] [blame] | 537 | |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 538 | kfree(ses->serverOS); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 539 | |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 540 | ses->serverOS = kmalloc(len + 1, GFP_KERNEL); |
Namjae Jeon | 27b7edc | 2014-08-20 19:39:28 +0900 | [diff] [blame] | 541 | if (ses->serverOS) { |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 542 | memcpy(ses->serverOS, bcc_ptr, len); |
| 543 | ses->serverOS[len] = 0; |
Namjae Jeon | 27b7edc | 2014-08-20 19:39:28 +0900 | [diff] [blame] | 544 | if (strncmp(ses->serverOS, "OS/2", 4) == 0) |
| 545 | cifs_dbg(FYI, "OS/2 server\n"); |
| 546 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 547 | |
| 548 | bcc_ptr += len + 1; |
| 549 | bleft -= len + 1; |
| 550 | |
| 551 | len = strnlen(bcc_ptr, bleft); |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 552 | if (len >= bleft) |
Jeff Layton | 7d06645 | 2013-05-24 07:41:00 -0400 | [diff] [blame] | 553 | return; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 554 | |
Steve French | 26f5736 | 2007-08-30 22:09:15 +0000 | [diff] [blame] | 555 | kfree(ses->serverNOS); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 556 | |
Ronnie Sahlberg | 340625e | 2019-08-27 09:30:14 +1000 | [diff] [blame] | 557 | ses->serverNOS = kmalloc(len + 1, GFP_KERNEL); |
| 558 | if (ses->serverNOS) { |
| 559 | memcpy(ses->serverNOS, bcc_ptr, len); |
| 560 | ses->serverNOS[len] = 0; |
| 561 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 562 | |
| 563 | bcc_ptr += len + 1; |
| 564 | bleft -= len + 1; |
| 565 | |
Steve French | 790fe57 | 2007-07-07 19:25:05 +0000 | [diff] [blame] | 566 | len = strnlen(bcc_ptr, bleft); |
| 567 | if (len > bleft) |
Jeff Layton | 7d06645 | 2013-05-24 07:41:00 -0400 | [diff] [blame] | 568 | return; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 569 | |
Steve French | 9ac00b7 | 2006-09-30 04:13:17 +0000 | [diff] [blame] | 570 | /* No domain field in LANMAN case. Domain is |
| 571 | returned by old servers in the SMB negprot response */ |
| 572 | /* BB For newer servers which do not support Unicode, |
| 573 | but thus do return domain here we could add parsing |
| 574 | for it later, but it is not very important */ |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 575 | cifs_dbg(FYI, "ascii: bytes left %d\n", bleft); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 576 | } |
| 577 | |
Pavel Shilovsky | 5478f9b | 2011-12-27 16:22:00 +0400 | [diff] [blame] | 578 | int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 579 | struct cifs_ses *ses) |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 580 | { |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 581 | unsigned int tioffset; /* challenge message target info area */ |
| 582 | unsigned int tilen; /* challenge message target info area length */ |
| 583 | |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 584 | CHALLENGE_MESSAGE *pblob = (CHALLENGE_MESSAGE *)bcc_ptr; |
| 585 | |
| 586 | if (blob_len < sizeof(CHALLENGE_MESSAGE)) { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 587 | cifs_dbg(VFS, "challenge blob len %d too small\n", blob_len); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 588 | return -EINVAL; |
| 589 | } |
| 590 | |
| 591 | if (memcmp(pblob->Signature, "NTLMSSP", 8)) { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 592 | cifs_dbg(VFS, "blob signature incorrect %s\n", |
| 593 | pblob->Signature); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 594 | return -EINVAL; |
| 595 | } |
| 596 | if (pblob->MessageType != NtLmChallenge) { |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 597 | cifs_dbg(VFS, "Incorrect message type %d\n", |
| 598 | pblob->MessageType); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 599 | return -EINVAL; |
| 600 | } |
| 601 | |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 602 | memcpy(ses->ntlmssp->cryptkey, pblob->Challenge, CIFS_CRYPTO_KEY_SIZE); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 603 | /* BB we could decode pblob->NegotiateFlags; some may be useful */ |
| 604 | /* In particular we can examine sign flags */ |
| 605 | /* BB spec says that if AvId field of MsvAvTimestamp is populated then |
| 606 | we must set the MIC field of the AUTHENTICATE_MESSAGE */ |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 607 | ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags); |
Steve French | 5443d13 | 2011-03-13 05:08:25 +0000 | [diff] [blame] | 608 | tioffset = le32_to_cpu(pblob->TargetInfoArray.BufferOffset); |
| 609 | tilen = le16_to_cpu(pblob->TargetInfoArray.Length); |
Dan Carpenter | 4991a5f | 2012-01-31 11:52:01 +0300 | [diff] [blame] | 610 | if (tioffset > blob_len || tioffset + tilen > blob_len) { |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 611 | cifs_dbg(VFS, "tioffset + tilen too high %u + %u\n", |
| 612 | tioffset, tilen); |
Dan Carpenter | 4991a5f | 2012-01-31 11:52:01 +0300 | [diff] [blame] | 613 | return -EINVAL; |
| 614 | } |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 615 | if (tilen) { |
Silviu-Mihai Popescu | f7f7c18 | 2013-03-11 18:22:32 +0200 | [diff] [blame] | 616 | ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen, |
| 617 | GFP_KERNEL); |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 618 | if (!ses->auth_key.response) { |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 619 | cifs_dbg(VFS, "Challenge target info alloc failure\n"); |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 620 | return -ENOMEM; |
| 621 | } |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 622 | ses->auth_key.len = tilen; |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 623 | } |
| 624 | |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 625 | return 0; |
| 626 | } |
| 627 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 628 | static int size_of_ntlmssp_blob(struct cifs_ses *ses, int base_size) |
| 629 | { |
| 630 | int sz = base_size + ses->auth_key.len |
| 631 | - CIFS_SESS_KEY_SIZE + CIFS_CPHTXT_SIZE + 2; |
| 632 | |
| 633 | if (ses->domainName) |
| 634 | sz += sizeof(__le16) * strnlen(ses->domainName, CIFS_MAX_DOMAINNAME_LEN); |
| 635 | else |
| 636 | sz += sizeof(__le16); |
| 637 | |
| 638 | if (ses->user_name) |
| 639 | sz += sizeof(__le16) * strnlen(ses->user_name, CIFS_MAX_USERNAME_LEN); |
| 640 | else |
| 641 | sz += sizeof(__le16); |
| 642 | |
| 643 | sz += sizeof(__le16) * strnlen(ses->workstation_name, CIFS_MAX_WORKSTATION_LEN); |
| 644 | |
| 645 | return sz; |
| 646 | } |
| 647 | |
| 648 | static inline void cifs_security_buffer_from_str(SECURITY_BUFFER *pbuf, |
| 649 | char *str_value, |
| 650 | int str_length, |
| 651 | unsigned char *pstart, |
| 652 | unsigned char **pcur, |
| 653 | const struct nls_table *nls_cp) |
| 654 | { |
| 655 | unsigned char *tmp = pstart; |
| 656 | int len; |
| 657 | |
| 658 | if (!pbuf) |
| 659 | return; |
| 660 | |
| 661 | if (!pcur) |
| 662 | pcur = &tmp; |
| 663 | |
| 664 | if (!str_value) { |
| 665 | pbuf->BufferOffset = cpu_to_le32(*pcur - pstart); |
| 666 | pbuf->Length = 0; |
| 667 | pbuf->MaximumLength = 0; |
| 668 | *pcur += sizeof(__le16); |
| 669 | } else { |
| 670 | len = cifs_strtoUTF16((__le16 *)*pcur, |
| 671 | str_value, |
| 672 | str_length, |
| 673 | nls_cp); |
| 674 | len *= sizeof(__le16); |
| 675 | pbuf->BufferOffset = cpu_to_le32(*pcur - pstart); |
| 676 | pbuf->Length = cpu_to_le16(len); |
| 677 | pbuf->MaximumLength = cpu_to_le16(len); |
| 678 | *pcur += len; |
| 679 | } |
| 680 | } |
| 681 | |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 682 | /* BB Move to ntlmssp.c eventually */ |
| 683 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 684 | int build_ntlmssp_negotiate_blob(unsigned char **pbuffer, |
| 685 | u16 *buflen, |
| 686 | struct cifs_ses *ses, |
| 687 | const struct nls_table *nls_cp) |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 688 | { |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 689 | int rc = 0; |
Aurelien Aptel | f6a6bf7 | 2019-09-20 06:22:14 +0200 | [diff] [blame] | 690 | struct TCP_Server_Info *server = cifs_ses_server(ses); |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 691 | NEGOTIATE_MESSAGE *sec_blob; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 692 | __u32 flags; |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 693 | unsigned char *tmp; |
| 694 | int len; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 695 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 696 | len = size_of_ntlmssp_blob(ses, sizeof(NEGOTIATE_MESSAGE)); |
| 697 | *pbuffer = kmalloc(len, GFP_KERNEL); |
| 698 | if (!*pbuffer) { |
| 699 | rc = -ENOMEM; |
| 700 | cifs_dbg(VFS, "Error %d during NTLMSSP allocation\n", rc); |
| 701 | *buflen = 0; |
| 702 | goto setup_ntlm_neg_ret; |
| 703 | } |
| 704 | sec_blob = (NEGOTIATE_MESSAGE *)*pbuffer; |
| 705 | |
| 706 | memset(*pbuffer, 0, sizeof(NEGOTIATE_MESSAGE)); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 707 | memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); |
| 708 | sec_blob->MessageType = NtLmNegotiate; |
| 709 | |
| 710 | /* BB is NTLMV2 session security format easier to use here? */ |
| 711 | flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | |
| 712 | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | |
Pavel Shilovsky | cabfb36 | 2016-11-07 18:20:50 -0800 | [diff] [blame] | 713 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | |
| 714 | NTLMSSP_NEGOTIATE_SEAL; |
Aurelien Aptel | f6a6bf7 | 2019-09-20 06:22:14 +0200 | [diff] [blame] | 715 | if (server->sign) |
Steve French | 745e507 | 2010-09-08 21:09:27 +0000 | [diff] [blame] | 716 | flags |= NTLMSSP_NEGOTIATE_SIGN; |
Aurelien Aptel | f6a6bf7 | 2019-09-20 06:22:14 +0200 | [diff] [blame] | 717 | if (!server->session_estab || ses->ntlmssp->sesskey_per_smbsess) |
Pavel Shilovsky | cabfb36 | 2016-11-07 18:20:50 -0800 | [diff] [blame] | 718 | flags |= NTLMSSP_NEGOTIATE_KEY_XCH; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 719 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 720 | tmp = *pbuffer + sizeof(NEGOTIATE_MESSAGE); |
Shirish Pargaonkar | df8fbc24 | 2010-12-11 14:19:22 -0600 | [diff] [blame] | 721 | sec_blob->NegotiateFlags = cpu_to_le32(flags); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 722 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 723 | /* these fields should be null in negotiate phase MS-NLMP 3.1.5.1.1 */ |
| 724 | cifs_security_buffer_from_str(&sec_blob->DomainName, |
| 725 | NULL, |
| 726 | CIFS_MAX_DOMAINNAME_LEN, |
| 727 | *pbuffer, &tmp, |
| 728 | nls_cp); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 729 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 730 | cifs_security_buffer_from_str(&sec_blob->WorkstationName, |
| 731 | NULL, |
| 732 | CIFS_MAX_WORKSTATION_LEN, |
| 733 | *pbuffer, &tmp, |
| 734 | nls_cp); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 735 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 736 | *buflen = tmp - *pbuffer; |
| 737 | setup_ntlm_neg_ret: |
| 738 | return rc; |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | int build_ntlmssp_auth_blob(unsigned char **pbuffer, |
Shirish Pargaonkar | 89f150f | 2010-10-19 11:47:52 -0500 | [diff] [blame] | 742 | u16 *buflen, |
Steve French | 96daf2b | 2011-05-27 04:34:02 +0000 | [diff] [blame] | 743 | struct cifs_ses *ses, |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 744 | const struct nls_table *nls_cp) |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 745 | { |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 746 | int rc; |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 747 | AUTHENTICATE_MESSAGE *sec_blob; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 748 | __u32 flags; |
| 749 | unsigned char *tmp; |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 750 | int len; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 751 | |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 752 | rc = setup_ntlmv2_rsp(ses, nls_cp); |
| 753 | if (rc) { |
| 754 | cifs_dbg(VFS, "Error %d during NTLMSSP authentication\n", rc); |
| 755 | *buflen = 0; |
| 756 | goto setup_ntlmv2_ret; |
| 757 | } |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 758 | |
| 759 | len = size_of_ntlmssp_blob(ses, sizeof(AUTHENTICATE_MESSAGE)); |
| 760 | *pbuffer = kmalloc(len, GFP_KERNEL); |
Nicholas Mc Guire | 126c97f | 2018-08-23 12:24:02 +0200 | [diff] [blame] | 761 | if (!*pbuffer) { |
| 762 | rc = -ENOMEM; |
| 763 | cifs_dbg(VFS, "Error %d during NTLMSSP allocation\n", rc); |
| 764 | *buflen = 0; |
| 765 | goto setup_ntlmv2_ret; |
| 766 | } |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 767 | sec_blob = (AUTHENTICATE_MESSAGE *)*pbuffer; |
| 768 | |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 769 | memcpy(sec_blob->Signature, NTLMSSP_SIGNATURE, 8); |
| 770 | sec_blob->MessageType = NtLmAuthenticate; |
| 771 | |
| 772 | flags = NTLMSSP_NEGOTIATE_56 | |
| 773 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | |
| 774 | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | |
Pavel Shilovsky | cabfb36 | 2016-11-07 18:20:50 -0800 | [diff] [blame] | 775 | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 776 | NTLMSSP_NEGOTIATE_SEAL | NTLMSSP_NEGOTIATE_WORKSTATION_SUPPLIED; |
Pavel Shilovsky | cabfb36 | 2016-11-07 18:20:50 -0800 | [diff] [blame] | 777 | if (ses->server->sign) |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 778 | flags |= NTLMSSP_NEGOTIATE_SIGN; |
Pavel Shilovsky | cabfb36 | 2016-11-07 18:20:50 -0800 | [diff] [blame] | 779 | if (!ses->server->session_estab || ses->ntlmssp->sesskey_per_smbsess) |
| 780 | flags |= NTLMSSP_NEGOTIATE_KEY_XCH; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 781 | |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 782 | tmp = *pbuffer + sizeof(AUTHENTICATE_MESSAGE); |
Shirish Pargaonkar | df8fbc24 | 2010-12-11 14:19:22 -0600 | [diff] [blame] | 783 | sec_blob->NegotiateFlags = cpu_to_le32(flags); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 784 | |
| 785 | sec_blob->LmChallengeResponse.BufferOffset = |
| 786 | cpu_to_le32(sizeof(AUTHENTICATE_MESSAGE)); |
| 787 | sec_blob->LmChallengeResponse.Length = 0; |
| 788 | sec_blob->LmChallengeResponse.MaximumLength = 0; |
| 789 | |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 790 | sec_blob->NtChallengeResponse.BufferOffset = |
| 791 | cpu_to_le32(tmp - *pbuffer); |
Stefan Metzmacher | cfda35d | 2016-05-03 10:52:30 +0200 | [diff] [blame] | 792 | if (ses->user_name != NULL) { |
Stefan Metzmacher | cfda35d | 2016-05-03 10:52:30 +0200 | [diff] [blame] | 793 | memcpy(tmp, ses->auth_key.response + CIFS_SESS_KEY_SIZE, |
| 794 | ses->auth_key.len - CIFS_SESS_KEY_SIZE); |
| 795 | tmp += ses->auth_key.len - CIFS_SESS_KEY_SIZE; |
Steve French | c8e56f1 | 2010-09-08 21:10:58 +0000 | [diff] [blame] | 796 | |
Stefan Metzmacher | cfda35d | 2016-05-03 10:52:30 +0200 | [diff] [blame] | 797 | sec_blob->NtChallengeResponse.Length = |
| 798 | cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); |
| 799 | sec_blob->NtChallengeResponse.MaximumLength = |
| 800 | cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); |
| 801 | } else { |
| 802 | /* |
| 803 | * don't send an NT Response for anonymous access |
| 804 | */ |
| 805 | sec_blob->NtChallengeResponse.Length = 0; |
| 806 | sec_blob->NtChallengeResponse.MaximumLength = 0; |
| 807 | } |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 808 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 809 | cifs_security_buffer_from_str(&sec_blob->DomainName, |
| 810 | ses->domainName, |
| 811 | CIFS_MAX_DOMAINNAME_LEN, |
| 812 | *pbuffer, &tmp, |
| 813 | nls_cp); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 814 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 815 | cifs_security_buffer_from_str(&sec_blob->UserName, |
| 816 | ses->user_name, |
| 817 | CIFS_MAX_USERNAME_LEN, |
| 818 | *pbuffer, &tmp, |
| 819 | nls_cp); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 820 | |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 821 | cifs_security_buffer_from_str(&sec_blob->WorkstationName, |
| 822 | ses->workstation_name, |
| 823 | CIFS_MAX_WORKSTATION_LEN, |
| 824 | *pbuffer, &tmp, |
| 825 | nls_cp); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 826 | |
Shirish Pargaonkar | df8fbc24 | 2010-12-11 14:19:22 -0600 | [diff] [blame] | 827 | if (((ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_KEY_XCH) || |
| 828 | (ses->ntlmssp->server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC)) |
| 829 | && !calc_seckey(ses)) { |
Shirish Pargaonkar | d3686d5 | 2010-10-28 09:53:07 -0500 | [diff] [blame] | 830 | memcpy(tmp, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE); |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 831 | sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); |
Shirish Pargaonkar | d2b9152 | 2010-10-21 14:25:08 -0500 | [diff] [blame] | 832 | sec_blob->SessionKey.Length = cpu_to_le16(CIFS_CPHTXT_SIZE); |
| 833 | sec_blob->SessionKey.MaximumLength = |
| 834 | cpu_to_le16(CIFS_CPHTXT_SIZE); |
| 835 | tmp += CIFS_CPHTXT_SIZE; |
| 836 | } else { |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 837 | sec_blob->SessionKey.BufferOffset = cpu_to_le32(tmp - *pbuffer); |
Shirish Pargaonkar | d2b9152 | 2010-10-21 14:25:08 -0500 | [diff] [blame] | 838 | sec_blob->SessionKey.Length = 0; |
| 839 | sec_blob->SessionKey.MaximumLength = 0; |
| 840 | } |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 841 | |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 842 | *buflen = tmp - *pbuffer; |
Shirish Pargaonkar | 2b149f1 | 2010-09-18 22:02:18 -0500 | [diff] [blame] | 843 | setup_ntlmv2_ret: |
Shirish Pargaonkar | 89f150f | 2010-10-19 11:47:52 -0500 | [diff] [blame] | 844 | return rc; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 845 | } |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 846 | |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 847 | enum securityEnum |
Sachin Prabhu | ef65aae | 2017-01-18 15:35:57 +0530 | [diff] [blame] | 848 | cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested) |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 849 | { |
| 850 | switch (server->negflavor) { |
| 851 | case CIFS_NEGFLAVOR_EXTENDED: |
| 852 | switch (requested) { |
| 853 | case Kerberos: |
| 854 | case RawNTLMSSP: |
| 855 | return requested; |
| 856 | case Unspecified: |
| 857 | if (server->sec_ntlmssp && |
| 858 | (global_secflags & CIFSSEC_MAY_NTLMSSP)) |
| 859 | return RawNTLMSSP; |
| 860 | if ((server->sec_kerberos || server->sec_mskerberos) && |
| 861 | (global_secflags & CIFSSEC_MAY_KRB5)) |
| 862 | return Kerberos; |
Gustavo A. R. Silva | df561f66 | 2020-08-23 17:36:59 -0500 | [diff] [blame] | 863 | fallthrough; |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 864 | default: |
| 865 | return Unspecified; |
| 866 | } |
| 867 | case CIFS_NEGFLAVOR_UNENCAP: |
| 868 | switch (requested) { |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 869 | case NTLMv2: |
| 870 | return requested; |
| 871 | case Unspecified: |
| 872 | if (global_secflags & CIFSSEC_MAY_NTLMV2) |
| 873 | return NTLMv2; |
Gustavo A. R. Silva | 21ac58f | 2020-11-20 12:24:14 -0600 | [diff] [blame] | 874 | break; |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 875 | default: |
Sachin Prabhu | dde2356 | 2013-09-27 18:35:42 +0100 | [diff] [blame] | 876 | break; |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 877 | } |
Ronnie Sahlberg | 76a3c92 | 2021-08-19 20:34:58 +1000 | [diff] [blame] | 878 | fallthrough; |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 879 | default: |
| 880 | return Unspecified; |
| 881 | } |
| 882 | } |
| 883 | |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 884 | struct sess_data { |
| 885 | unsigned int xid; |
| 886 | struct cifs_ses *ses; |
| 887 | struct nls_table *nls_cp; |
| 888 | void (*func)(struct sess_data *); |
| 889 | int result; |
| 890 | |
| 891 | /* we will send the SMB in three pieces: |
| 892 | * a fixed length beginning part, an optional |
| 893 | * SPNEGO blob (which can be zero length), and a |
| 894 | * last part which will include the strings |
| 895 | * and rest of bcc area. This allows us to avoid |
| 896 | * a large buffer 17K allocation |
| 897 | */ |
| 898 | int buf0_type; |
| 899 | struct kvec iov[3]; |
| 900 | }; |
| 901 | |
| 902 | static int |
| 903 | sess_alloc_buffer(struct sess_data *sess_data, int wct) |
| 904 | { |
| 905 | int rc; |
| 906 | struct cifs_ses *ses = sess_data->ses; |
| 907 | struct smb_hdr *smb_buf; |
| 908 | |
| 909 | rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses, |
| 910 | (void **)&smb_buf); |
| 911 | |
| 912 | if (rc) |
| 913 | return rc; |
| 914 | |
| 915 | sess_data->iov[0].iov_base = (char *)smb_buf; |
| 916 | sess_data->iov[0].iov_len = be32_to_cpu(smb_buf->smb_buf_length) + 4; |
| 917 | /* |
| 918 | * This variable will be used to clear the buffer |
| 919 | * allocated above in case of any error in the calling function. |
| 920 | */ |
| 921 | sess_data->buf0_type = CIFS_SMALL_BUFFER; |
| 922 | |
| 923 | /* 2000 big enough to fit max user, domain, NOS name etc. */ |
| 924 | sess_data->iov[2].iov_base = kmalloc(2000, GFP_KERNEL); |
| 925 | if (!sess_data->iov[2].iov_base) { |
| 926 | rc = -ENOMEM; |
| 927 | goto out_free_smb_buf; |
| 928 | } |
| 929 | |
| 930 | return 0; |
| 931 | |
| 932 | out_free_smb_buf: |
Ding Hui | d72c741 | 2021-08-17 22:55:10 +0800 | [diff] [blame] | 933 | cifs_small_buf_release(smb_buf); |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 934 | sess_data->iov[0].iov_base = NULL; |
| 935 | sess_data->iov[0].iov_len = 0; |
| 936 | sess_data->buf0_type = CIFS_NO_BUFFER; |
| 937 | return rc; |
| 938 | } |
| 939 | |
| 940 | static void |
| 941 | sess_free_buffer(struct sess_data *sess_data) |
| 942 | { |
| 943 | |
| 944 | free_rsp_buf(sess_data->buf0_type, sess_data->iov[0].iov_base); |
| 945 | sess_data->buf0_type = CIFS_NO_BUFFER; |
| 946 | kfree(sess_data->iov[2].iov_base); |
| 947 | } |
| 948 | |
| 949 | static int |
| 950 | sess_establish_session(struct sess_data *sess_data) |
| 951 | { |
| 952 | struct cifs_ses *ses = sess_data->ses; |
| 953 | |
| 954 | mutex_lock(&ses->server->srv_mutex); |
| 955 | if (!ses->server->session_estab) { |
| 956 | if (ses->server->sign) { |
| 957 | ses->server->session_key.response = |
| 958 | kmemdup(ses->auth_key.response, |
| 959 | ses->auth_key.len, GFP_KERNEL); |
| 960 | if (!ses->server->session_key.response) { |
| 961 | mutex_unlock(&ses->server->srv_mutex); |
| 962 | return -ENOMEM; |
| 963 | } |
| 964 | ses->server->session_key.len = |
| 965 | ses->auth_key.len; |
| 966 | } |
| 967 | ses->server->sequence_number = 0x2; |
| 968 | ses->server->session_estab = true; |
| 969 | } |
| 970 | mutex_unlock(&ses->server->srv_mutex); |
| 971 | |
| 972 | cifs_dbg(FYI, "CIFS session established successfully\n"); |
| 973 | spin_lock(&GlobalMid_Lock); |
| 974 | ses->status = CifsGood; |
| 975 | ses->need_reconnect = false; |
| 976 | spin_unlock(&GlobalMid_Lock); |
| 977 | |
| 978 | return 0; |
| 979 | } |
| 980 | |
| 981 | static int |
| 982 | sess_sendreceive(struct sess_data *sess_data) |
| 983 | { |
| 984 | int rc; |
| 985 | struct smb_hdr *smb_buf = (struct smb_hdr *) sess_data->iov[0].iov_base; |
| 986 | __u16 count; |
Pavel Shilovsky | da502f7 | 2016-10-25 11:38:47 -0700 | [diff] [blame] | 987 | struct kvec rsp_iov = { NULL, 0 }; |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 988 | |
| 989 | count = sess_data->iov[1].iov_len + sess_data->iov[2].iov_len; |
Qinglang Miao | 1a0e7f7 | 2020-07-25 16:56:01 +0800 | [diff] [blame] | 990 | be32_add_cpu(&smb_buf->smb_buf_length, count); |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 991 | put_bcc(count, smb_buf); |
| 992 | |
| 993 | rc = SendReceive2(sess_data->xid, sess_data->ses, |
| 994 | sess_data->iov, 3 /* num_iovecs */, |
| 995 | &sess_data->buf0_type, |
Pavel Shilovsky | da502f7 | 2016-10-25 11:38:47 -0700 | [diff] [blame] | 996 | CIFS_LOG_ERROR, &rsp_iov); |
| 997 | cifs_small_buf_release(sess_data->iov[0].iov_base); |
| 998 | memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec)); |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 999 | |
| 1000 | return rc; |
| 1001 | } |
| 1002 | |
Sachin Prabhu | 583cf7a | 2014-06-16 15:35:26 +0100 | [diff] [blame] | 1003 | static void |
| 1004 | sess_auth_ntlmv2(struct sess_data *sess_data) |
| 1005 | { |
| 1006 | int rc = 0; |
| 1007 | struct smb_hdr *smb_buf; |
| 1008 | SESSION_SETUP_ANDX *pSMB; |
| 1009 | char *bcc_ptr; |
| 1010 | struct cifs_ses *ses = sess_data->ses; |
| 1011 | __u32 capabilities; |
| 1012 | __u16 bytes_remaining; |
| 1013 | |
| 1014 | /* old style NTLM sessionsetup */ |
| 1015 | /* wct = 13 */ |
| 1016 | rc = sess_alloc_buffer(sess_data, 13); |
| 1017 | if (rc) |
| 1018 | goto out; |
| 1019 | |
| 1020 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1021 | bcc_ptr = sess_data->iov[2].iov_base; |
| 1022 | capabilities = cifs_ssetup_hdr(ses, pSMB); |
| 1023 | |
| 1024 | pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities); |
| 1025 | |
| 1026 | /* LM2 password would be here if we supported it */ |
| 1027 | pSMB->req_no_secext.CaseInsensitivePasswordLength = 0; |
| 1028 | |
Stefan Metzmacher | 1a967d6 | 2016-05-03 10:52:30 +0200 | [diff] [blame] | 1029 | if (ses->user_name != NULL) { |
| 1030 | /* calculate nlmv2 response and session key */ |
| 1031 | rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp); |
| 1032 | if (rc) { |
| 1033 | cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc); |
| 1034 | goto out; |
| 1035 | } |
| 1036 | |
| 1037 | memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE, |
| 1038 | ses->auth_key.len - CIFS_SESS_KEY_SIZE); |
| 1039 | bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE; |
| 1040 | |
| 1041 | /* set case sensitive password length after tilen may get |
| 1042 | * assigned, tilen is 0 otherwise. |
| 1043 | */ |
| 1044 | pSMB->req_no_secext.CaseSensitivePasswordLength = |
| 1045 | cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE); |
| 1046 | } else { |
| 1047 | pSMB->req_no_secext.CaseSensitivePasswordLength = 0; |
Sachin Prabhu | 583cf7a | 2014-06-16 15:35:26 +0100 | [diff] [blame] | 1048 | } |
| 1049 | |
Sachin Prabhu | 583cf7a | 2014-06-16 15:35:26 +0100 | [diff] [blame] | 1050 | if (ses->capabilities & CAP_UNICODE) { |
| 1051 | if (sess_data->iov[0].iov_len % 2) { |
| 1052 | *bcc_ptr = 0; |
| 1053 | bcc_ptr++; |
| 1054 | } |
| 1055 | unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); |
| 1056 | } else { |
| 1057 | ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); |
| 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | sess_data->iov[2].iov_len = (long) bcc_ptr - |
| 1062 | (long) sess_data->iov[2].iov_base; |
| 1063 | |
| 1064 | rc = sess_sendreceive(sess_data); |
| 1065 | if (rc) |
| 1066 | goto out; |
| 1067 | |
| 1068 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1069 | smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; |
| 1070 | |
| 1071 | if (smb_buf->WordCount != 3) { |
| 1072 | rc = -EIO; |
| 1073 | cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); |
| 1074 | goto out; |
| 1075 | } |
| 1076 | |
| 1077 | if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN) |
| 1078 | cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */ |
| 1079 | |
| 1080 | ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ |
| 1081 | cifs_dbg(FYI, "UID = %llu\n", ses->Suid); |
| 1082 | |
| 1083 | bytes_remaining = get_bcc(smb_buf); |
| 1084 | bcc_ptr = pByteArea(smb_buf); |
| 1085 | |
| 1086 | /* BB check if Unicode and decode strings */ |
| 1087 | if (bytes_remaining == 0) { |
| 1088 | /* no string area to decode, do nothing */ |
| 1089 | } else if (smb_buf->Flags2 & SMBFLG2_UNICODE) { |
| 1090 | /* unicode string area must be word-aligned */ |
| 1091 | if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { |
| 1092 | ++bcc_ptr; |
| 1093 | --bytes_remaining; |
| 1094 | } |
| 1095 | decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1096 | sess_data->nls_cp); |
| 1097 | } else { |
| 1098 | decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1099 | sess_data->nls_cp); |
| 1100 | } |
| 1101 | |
| 1102 | rc = sess_establish_session(sess_data); |
| 1103 | out: |
| 1104 | sess_data->result = rc; |
| 1105 | sess_data->func = NULL; |
| 1106 | sess_free_buffer(sess_data); |
| 1107 | kfree(ses->auth_key.response); |
| 1108 | ses->auth_key.response = NULL; |
| 1109 | } |
| 1110 | |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1111 | #ifdef CONFIG_CIFS_UPCALL |
| 1112 | static void |
| 1113 | sess_auth_kerberos(struct sess_data *sess_data) |
| 1114 | { |
| 1115 | int rc = 0; |
| 1116 | struct smb_hdr *smb_buf; |
| 1117 | SESSION_SETUP_ANDX *pSMB; |
| 1118 | char *bcc_ptr; |
| 1119 | struct cifs_ses *ses = sess_data->ses; |
| 1120 | __u32 capabilities; |
| 1121 | __u16 bytes_remaining; |
| 1122 | struct key *spnego_key = NULL; |
| 1123 | struct cifs_spnego_msg *msg; |
| 1124 | u16 blob_len; |
| 1125 | |
| 1126 | /* extended security */ |
| 1127 | /* wct = 12 */ |
| 1128 | rc = sess_alloc_buffer(sess_data, 12); |
| 1129 | if (rc) |
| 1130 | goto out; |
| 1131 | |
| 1132 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1133 | bcc_ptr = sess_data->iov[2].iov_base; |
| 1134 | capabilities = cifs_ssetup_hdr(ses, pSMB); |
| 1135 | |
| 1136 | spnego_key = cifs_get_spnego_key(ses); |
| 1137 | if (IS_ERR(spnego_key)) { |
| 1138 | rc = PTR_ERR(spnego_key); |
| 1139 | spnego_key = NULL; |
| 1140 | goto out; |
| 1141 | } |
| 1142 | |
David Howells | 146aa8b | 2015-10-21 14:04:48 +0100 | [diff] [blame] | 1143 | msg = spnego_key->payload.data[0]; |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1144 | /* |
| 1145 | * check version field to make sure that cifs.upcall is |
| 1146 | * sending us a response in an expected form |
| 1147 | */ |
| 1148 | if (msg->version != CIFS_SPNEGO_UPCALL_VERSION) { |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 1149 | cifs_dbg(VFS, "incorrect version of cifs.upcall (expected %d but got %d)\n", |
| 1150 | CIFS_SPNEGO_UPCALL_VERSION, msg->version); |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1151 | rc = -EKEYREJECTED; |
| 1152 | goto out_put_spnego_key; |
| 1153 | } |
| 1154 | |
| 1155 | ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, |
| 1156 | GFP_KERNEL); |
| 1157 | if (!ses->auth_key.response) { |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 1158 | cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n", |
| 1159 | msg->sesskey_len); |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1160 | rc = -ENOMEM; |
| 1161 | goto out_put_spnego_key; |
| 1162 | } |
| 1163 | ses->auth_key.len = msg->sesskey_len; |
| 1164 | |
| 1165 | pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; |
| 1166 | capabilities |= CAP_EXTENDED_SECURITY; |
| 1167 | pSMB->req.Capabilities = cpu_to_le32(capabilities); |
| 1168 | sess_data->iov[1].iov_base = msg->data + msg->sesskey_len; |
| 1169 | sess_data->iov[1].iov_len = msg->secblob_len; |
| 1170 | pSMB->req.SecurityBlobLength = cpu_to_le16(sess_data->iov[1].iov_len); |
| 1171 | |
| 1172 | if (ses->capabilities & CAP_UNICODE) { |
| 1173 | /* unicode strings must be word aligned */ |
| 1174 | if ((sess_data->iov[0].iov_len |
| 1175 | + sess_data->iov[1].iov_len) % 2) { |
| 1176 | *bcc_ptr = 0; |
| 1177 | bcc_ptr++; |
| 1178 | } |
| 1179 | unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp); |
| 1180 | unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp); |
| 1181 | } else { |
| 1182 | /* BB: is this right? */ |
| 1183 | ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp); |
| 1184 | } |
| 1185 | |
| 1186 | sess_data->iov[2].iov_len = (long) bcc_ptr - |
| 1187 | (long) sess_data->iov[2].iov_base; |
| 1188 | |
| 1189 | rc = sess_sendreceive(sess_data); |
| 1190 | if (rc) |
| 1191 | goto out_put_spnego_key; |
| 1192 | |
| 1193 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1194 | smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; |
| 1195 | |
| 1196 | if (smb_buf->WordCount != 4) { |
| 1197 | rc = -EIO; |
| 1198 | cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); |
| 1199 | goto out_put_spnego_key; |
| 1200 | } |
| 1201 | |
| 1202 | if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN) |
| 1203 | cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */ |
| 1204 | |
| 1205 | ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ |
| 1206 | cifs_dbg(FYI, "UID = %llu\n", ses->Suid); |
| 1207 | |
| 1208 | bytes_remaining = get_bcc(smb_buf); |
| 1209 | bcc_ptr = pByteArea(smb_buf); |
| 1210 | |
| 1211 | blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); |
| 1212 | if (blob_len > bytes_remaining) { |
| 1213 | cifs_dbg(VFS, "bad security blob length %d\n", |
| 1214 | blob_len); |
| 1215 | rc = -EINVAL; |
| 1216 | goto out_put_spnego_key; |
| 1217 | } |
| 1218 | bcc_ptr += blob_len; |
| 1219 | bytes_remaining -= blob_len; |
| 1220 | |
| 1221 | /* BB check if Unicode and decode strings */ |
| 1222 | if (bytes_remaining == 0) { |
| 1223 | /* no string area to decode, do nothing */ |
| 1224 | } else if (smb_buf->Flags2 & SMBFLG2_UNICODE) { |
| 1225 | /* unicode string area must be word-aligned */ |
| 1226 | if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { |
| 1227 | ++bcc_ptr; |
| 1228 | --bytes_remaining; |
| 1229 | } |
| 1230 | decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1231 | sess_data->nls_cp); |
| 1232 | } else { |
| 1233 | decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1234 | sess_data->nls_cp); |
| 1235 | } |
| 1236 | |
| 1237 | rc = sess_establish_session(sess_data); |
| 1238 | out_put_spnego_key: |
| 1239 | key_invalidate(spnego_key); |
| 1240 | key_put(spnego_key); |
| 1241 | out: |
| 1242 | sess_data->result = rc; |
| 1243 | sess_data->func = NULL; |
| 1244 | sess_free_buffer(sess_data); |
| 1245 | kfree(ses->auth_key.response); |
| 1246 | ses->auth_key.response = NULL; |
| 1247 | } |
| 1248 | |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1249 | #endif /* ! CONFIG_CIFS_UPCALL */ |
Sachin Prabhu | 583cf7a | 2014-06-16 15:35:26 +0100 | [diff] [blame] | 1250 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1251 | /* |
| 1252 | * The required kvec buffers have to be allocated before calling this |
| 1253 | * function. |
| 1254 | */ |
| 1255 | static int |
| 1256 | _sess_auth_rawntlmssp_assemble_req(struct sess_data *sess_data) |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1257 | { |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1258 | SESSION_SETUP_ANDX *pSMB; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1259 | struct cifs_ses *ses = sess_data->ses; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1260 | __u32 capabilities; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1261 | char *bcc_ptr; |
Steve French | 254e55e | 2006-06-04 05:53:15 +0000 | [diff] [blame] | 1262 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1263 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1264 | |
| 1265 | capabilities = cifs_ssetup_hdr(ses, pSMB); |
| 1266 | if ((pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) == 0) { |
| 1267 | cifs_dbg(VFS, "NTLMSSP requires Unicode support\n"); |
| 1268 | return -ENOSYS; |
Jeff Layton | 3534b85 | 2013-05-24 07:41:01 -0400 | [diff] [blame] | 1269 | } |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1270 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1271 | pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC; |
| 1272 | capabilities |= CAP_EXTENDED_SECURITY; |
| 1273 | pSMB->req.Capabilities |= cpu_to_le32(capabilities); |
| 1274 | |
| 1275 | bcc_ptr = sess_data->iov[2].iov_base; |
| 1276 | /* unicode strings must be word aligned */ |
| 1277 | if ((sess_data->iov[0].iov_len + sess_data->iov[1].iov_len) % 2) { |
| 1278 | *bcc_ptr = 0; |
| 1279 | bcc_ptr++; |
| 1280 | } |
| 1281 | unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp); |
| 1282 | |
| 1283 | sess_data->iov[2].iov_len = (long) bcc_ptr - |
| 1284 | (long) sess_data->iov[2].iov_base; |
| 1285 | |
| 1286 | return 0; |
| 1287 | } |
| 1288 | |
| 1289 | static void |
| 1290 | sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data); |
| 1291 | |
| 1292 | static void |
| 1293 | sess_auth_rawntlmssp_negotiate(struct sess_data *sess_data) |
| 1294 | { |
| 1295 | int rc; |
| 1296 | struct smb_hdr *smb_buf; |
| 1297 | SESSION_SETUP_ANDX *pSMB; |
| 1298 | struct cifs_ses *ses = sess_data->ses; |
| 1299 | __u16 bytes_remaining; |
| 1300 | char *bcc_ptr; |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 1301 | unsigned char *ntlmsspblob = NULL; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1302 | u16 blob_len; |
| 1303 | |
| 1304 | cifs_dbg(FYI, "rawntlmssp session setup negotiate phase\n"); |
| 1305 | |
| 1306 | /* |
| 1307 | * if memory allocation is successful, caller of this function |
| 1308 | * frees it. |
| 1309 | */ |
| 1310 | ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL); |
| 1311 | if (!ses->ntlmssp) { |
| 1312 | rc = -ENOMEM; |
| 1313 | goto out; |
| 1314 | } |
| 1315 | ses->ntlmssp->sesskey_per_smbsess = false; |
| 1316 | |
| 1317 | /* wct = 12 */ |
| 1318 | rc = sess_alloc_buffer(sess_data, 12); |
| 1319 | if (rc) |
| 1320 | goto out; |
| 1321 | |
| 1322 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1323 | |
| 1324 | /* Build security blob before we assemble the request */ |
Shyam Prasad N | 49bd49f | 2021-11-05 19:03:57 +0000 | [diff] [blame] | 1325 | rc = build_ntlmssp_negotiate_blob(&ntlmsspblob, |
| 1326 | &blob_len, ses, |
| 1327 | sess_data->nls_cp); |
| 1328 | if (rc) |
| 1329 | goto out; |
| 1330 | |
| 1331 | sess_data->iov[1].iov_len = blob_len; |
| 1332 | sess_data->iov[1].iov_base = ntlmsspblob; |
| 1333 | pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len); |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1334 | |
| 1335 | rc = _sess_auth_rawntlmssp_assemble_req(sess_data); |
| 1336 | if (rc) |
| 1337 | goto out; |
| 1338 | |
| 1339 | rc = sess_sendreceive(sess_data); |
| 1340 | |
| 1341 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1342 | smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; |
| 1343 | |
| 1344 | /* If true, rc here is expected and not an error */ |
| 1345 | if (sess_data->buf0_type != CIFS_NO_BUFFER && |
| 1346 | smb_buf->Status.CifsError == |
| 1347 | cpu_to_le32(NT_STATUS_MORE_PROCESSING_REQUIRED)) |
| 1348 | rc = 0; |
| 1349 | |
| 1350 | if (rc) |
| 1351 | goto out; |
| 1352 | |
| 1353 | cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n"); |
| 1354 | |
| 1355 | if (smb_buf->WordCount != 4) { |
| 1356 | rc = -EIO; |
| 1357 | cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); |
| 1358 | goto out; |
| 1359 | } |
| 1360 | |
| 1361 | ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */ |
| 1362 | cifs_dbg(FYI, "UID = %llu\n", ses->Suid); |
| 1363 | |
| 1364 | bytes_remaining = get_bcc(smb_buf); |
| 1365 | bcc_ptr = pByteArea(smb_buf); |
| 1366 | |
| 1367 | blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); |
| 1368 | if (blob_len > bytes_remaining) { |
| 1369 | cifs_dbg(VFS, "bad security blob length %d\n", |
| 1370 | blob_len); |
| 1371 | rc = -EINVAL; |
| 1372 | goto out; |
| 1373 | } |
| 1374 | |
| 1375 | rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses); |
| 1376 | out: |
| 1377 | sess_free_buffer(sess_data); |
| 1378 | |
| 1379 | if (!rc) { |
| 1380 | sess_data->func = sess_auth_rawntlmssp_authenticate; |
| 1381 | return; |
| 1382 | } |
| 1383 | |
| 1384 | /* Else error. Cleanup */ |
| 1385 | kfree(ses->auth_key.response); |
| 1386 | ses->auth_key.response = NULL; |
| 1387 | kfree(ses->ntlmssp); |
| 1388 | ses->ntlmssp = NULL; |
| 1389 | |
| 1390 | sess_data->func = NULL; |
| 1391 | sess_data->result = rc; |
| 1392 | } |
| 1393 | |
| 1394 | static void |
| 1395 | sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data) |
| 1396 | { |
| 1397 | int rc; |
| 1398 | struct smb_hdr *smb_buf; |
| 1399 | SESSION_SETUP_ANDX *pSMB; |
| 1400 | struct cifs_ses *ses = sess_data->ses; |
| 1401 | __u16 bytes_remaining; |
| 1402 | char *bcc_ptr; |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 1403 | unsigned char *ntlmsspblob = NULL; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1404 | u16 blob_len; |
| 1405 | |
| 1406 | cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n"); |
| 1407 | |
| 1408 | /* wct = 12 */ |
| 1409 | rc = sess_alloc_buffer(sess_data, 12); |
| 1410 | if (rc) |
| 1411 | goto out; |
| 1412 | |
| 1413 | /* Build security blob before we assemble the request */ |
| 1414 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1415 | smb_buf = (struct smb_hdr *)pSMB; |
Jerome Marchand | b8da344 | 2016-05-26 11:52:25 +0200 | [diff] [blame] | 1416 | rc = build_ntlmssp_auth_blob(&ntlmsspblob, |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1417 | &blob_len, ses, sess_data->nls_cp); |
| 1418 | if (rc) |
| 1419 | goto out_free_ntlmsspblob; |
| 1420 | sess_data->iov[1].iov_len = blob_len; |
| 1421 | sess_data->iov[1].iov_base = ntlmsspblob; |
| 1422 | pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len); |
| 1423 | /* |
| 1424 | * Make sure that we tell the server that we are using |
| 1425 | * the uid that it just gave us back on the response |
| 1426 | * (challenge) |
| 1427 | */ |
| 1428 | smb_buf->Uid = ses->Suid; |
| 1429 | |
| 1430 | rc = _sess_auth_rawntlmssp_assemble_req(sess_data); |
| 1431 | if (rc) |
| 1432 | goto out_free_ntlmsspblob; |
| 1433 | |
| 1434 | rc = sess_sendreceive(sess_data); |
| 1435 | if (rc) |
| 1436 | goto out_free_ntlmsspblob; |
| 1437 | |
| 1438 | pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base; |
| 1439 | smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base; |
| 1440 | if (smb_buf->WordCount != 4) { |
| 1441 | rc = -EIO; |
| 1442 | cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount); |
| 1443 | goto out_free_ntlmsspblob; |
| 1444 | } |
| 1445 | |
| 1446 | if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN) |
| 1447 | cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */ |
| 1448 | |
Sachin Prabhu | ee9bbf4 | 2014-12-03 12:26:36 +0000 | [diff] [blame] | 1449 | if (ses->Suid != smb_buf->Uid) { |
| 1450 | ses->Suid = smb_buf->Uid; |
| 1451 | cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid); |
| 1452 | } |
| 1453 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1454 | bytes_remaining = get_bcc(smb_buf); |
| 1455 | bcc_ptr = pByteArea(smb_buf); |
| 1456 | blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength); |
| 1457 | if (blob_len > bytes_remaining) { |
| 1458 | cifs_dbg(VFS, "bad security blob length %d\n", |
| 1459 | blob_len); |
| 1460 | rc = -EINVAL; |
| 1461 | goto out_free_ntlmsspblob; |
| 1462 | } |
| 1463 | bcc_ptr += blob_len; |
| 1464 | bytes_remaining -= blob_len; |
| 1465 | |
| 1466 | |
| 1467 | /* BB check if Unicode and decode strings */ |
| 1468 | if (bytes_remaining == 0) { |
| 1469 | /* no string area to decode, do nothing */ |
| 1470 | } else if (smb_buf->Flags2 & SMBFLG2_UNICODE) { |
| 1471 | /* unicode string area must be word-aligned */ |
| 1472 | if (((unsigned long) bcc_ptr - (unsigned long) smb_buf) % 2) { |
| 1473 | ++bcc_ptr; |
| 1474 | --bytes_remaining; |
| 1475 | } |
| 1476 | decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1477 | sess_data->nls_cp); |
| 1478 | } else { |
| 1479 | decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses, |
| 1480 | sess_data->nls_cp); |
| 1481 | } |
| 1482 | |
| 1483 | out_free_ntlmsspblob: |
| 1484 | kfree(ntlmsspblob); |
| 1485 | out: |
| 1486 | sess_free_buffer(sess_data); |
| 1487 | |
| 1488 | if (!rc) |
| 1489 | rc = sess_establish_session(sess_data); |
| 1490 | |
| 1491 | /* Cleanup */ |
| 1492 | kfree(ses->auth_key.response); |
| 1493 | ses->auth_key.response = NULL; |
| 1494 | kfree(ses->ntlmssp); |
| 1495 | ses->ntlmssp = NULL; |
| 1496 | |
| 1497 | sess_data->func = NULL; |
| 1498 | sess_data->result = rc; |
| 1499 | } |
| 1500 | |
Steve French | 2792407 | 2014-07-11 07:47:01 -0500 | [diff] [blame] | 1501 | static int select_sec(struct cifs_ses *ses, struct sess_data *sess_data) |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1502 | { |
| 1503 | int type; |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 1504 | |
Sachin Prabhu | ef65aae | 2017-01-18 15:35:57 +0530 | [diff] [blame] | 1505 | type = cifs_select_sectype(ses->server, ses->sectype); |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 1506 | cifs_dbg(FYI, "sess setup type %d\n", type); |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 1507 | if (type == Unspecified) { |
Joe Perches | a0a3036 | 2020-04-14 22:42:53 -0700 | [diff] [blame] | 1508 | cifs_dbg(VFS, "Unable to select appropriate authentication method!\n"); |
Jeff Layton | 3f61822 | 2013-06-12 19:52:14 -0500 | [diff] [blame] | 1509 | return -EINVAL; |
| 1510 | } |
| 1511 | |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 1512 | switch (type) { |
Sachin Prabhu | 583cf7a | 2014-06-16 15:35:26 +0100 | [diff] [blame] | 1513 | case NTLMv2: |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1514 | sess_data->func = sess_auth_ntlmv2; |
| 1515 | break; |
Sachin Prabhu | ee03c64 | 2014-06-16 15:35:27 +0100 | [diff] [blame] | 1516 | case Kerberos: |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1517 | #ifdef CONFIG_CIFS_UPCALL |
| 1518 | sess_data->func = sess_auth_kerberos; |
| 1519 | break; |
| 1520 | #else |
| 1521 | cifs_dbg(VFS, "Kerberos negotiated but upcall support disabled!\n"); |
| 1522 | return -ENOSYS; |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1523 | #endif /* CONFIG_CIFS_UPCALL */ |
| 1524 | case RawNTLMSSP: |
| 1525 | sess_data->func = sess_auth_rawntlmssp_negotiate; |
| 1526 | break; |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 1527 | default: |
Joe Perches | f96637b | 2013-05-04 22:12:25 -0500 | [diff] [blame] | 1528 | cifs_dbg(VFS, "secType %d not supported!\n", type); |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1529 | return -ENOSYS; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1530 | } |
| 1531 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1532 | return 0; |
| 1533 | } |
Steve French | 2442421 | 2007-11-16 23:37:35 +0000 | [diff] [blame] | 1534 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1535 | int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, |
| 1536 | const struct nls_table *nls_cp) |
| 1537 | { |
| 1538 | int rc = 0; |
| 1539 | struct sess_data *sess_data; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1540 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1541 | if (ses == NULL) { |
| 1542 | WARN(1, "%s: ses == NULL!", __func__); |
| 1543 | return -EINVAL; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 1544 | } |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1545 | |
| 1546 | sess_data = kzalloc(sizeof(struct sess_data), GFP_KERNEL); |
| 1547 | if (!sess_data) |
| 1548 | return -ENOMEM; |
| 1549 | |
| 1550 | rc = select_sec(ses, sess_data); |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 1551 | if (rc) |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1552 | goto out; |
Steve French | 0b3cc858 | 2009-05-04 08:37:12 +0000 | [diff] [blame] | 1553 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1554 | sess_data->xid = xid; |
| 1555 | sess_data->ses = ses; |
| 1556 | sess_data->buf0_type = CIFS_NO_BUFFER; |
| 1557 | sess_data->nls_cp = (struct nls_table *) nls_cp; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1558 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1559 | while (sess_data->func) |
| 1560 | sess_data->func(sess_data); |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1561 | |
Sachin Prabhu | cc87c47 | 2014-06-16 15:35:28 +0100 | [diff] [blame] | 1562 | /* Store result before we free sess_data */ |
| 1563 | rc = sess_data->result; |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 1564 | |
| 1565 | out: |
Sachin Prabhu | 80a0e63 | 2014-06-16 15:35:25 +0100 | [diff] [blame] | 1566 | kfree(sess_data); |
| 1567 | return rc; |
Steve French | 3979877 | 2006-05-31 22:40:51 +0000 | [diff] [blame] | 1568 | } |