Commit b5013d08 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag '5.16-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs updates from Steve French:

 - reconnect fix for stable

 - minor mount option fix

 - debugging improvement for (TCP) connection issues

 - refactoring of common code to help ksmbd

* tag '5.16-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  smb3: add dynamic trace points for socket connection
  cifs: Move SMB2_Create definitions to the shared area
  cifs: Move more definitions into the shared area
  cifs: move NEGOTIATE_PROTOCOL definitions out into the common area
  cifs: Create a new shared file holding smb2 pdu definitions
  cifs: add mount parameter tcpnodelay
  cifs: To match file servers, make sure the server hostname matches
parents 2acda754 d7171cd1
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include <linux/key-type.h> #include <linux/key-type.h>
#include "cifs_spnego.h" #include "cifs_spnego.h"
#include "fscache.h" #include "fscache.h"
#include "smb2pdu.h"
#ifdef CONFIG_CIFS_DFS_UPCALL #ifdef CONFIG_CIFS_DFS_UPCALL
#include "dfs_cache.h" #include "dfs_cache.h"
#endif #endif
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <crypto/internal/hash.h> #include <crypto/internal/hash.h>
#include <linux/scatterlist.h> #include <linux/scatterlist.h>
#include <uapi/linux/cifs/cifs_mount.h> #include <uapi/linux/cifs/cifs_mount.h>
#include "../smbfs_common/smb2pdu.h"
#include "smb2pdu.h" #include "smb2pdu.h"
#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
...@@ -776,7 +777,7 @@ revert_current_mid(struct TCP_Server_Info *server, const unsigned int val) ...@@ -776,7 +777,7 @@ revert_current_mid(struct TCP_Server_Info *server, const unsigned int val)
static inline void static inline void
revert_current_mid_from_hdr(struct TCP_Server_Info *server, revert_current_mid_from_hdr(struct TCP_Server_Info *server,
const struct smb2_sync_hdr *shdr) const struct smb2_hdr *shdr)
{ {
unsigned int num = le16_to_cpu(shdr->CreditCharge); unsigned int num = le16_to_cpu(shdr->CreditCharge);
......
...@@ -677,7 +677,7 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed) ...@@ -677,7 +677,7 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed)
static unsigned int static unsigned int
smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
{ {
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer; struct smb2_hdr *shdr = (struct smb2_hdr *)buffer;
/* /*
* SMB1 does not use credits. * SMB1 does not use credits.
...@@ -794,7 +794,6 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server) ...@@ -794,7 +794,6 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
*/ */
} }
kfree(server->hostname);
kfree(server); kfree(server);
length = atomic_dec_return(&tcpSesAllocCount); length = atomic_dec_return(&tcpSesAllocCount);
...@@ -878,7 +877,7 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -878,7 +877,7 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
static void static void
smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
{ {
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buffer; struct smb2_hdr *shdr = (struct smb2_hdr *)buffer;
int scredits, in_flight; int scredits, in_flight;
/* /*
...@@ -1235,6 +1234,9 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context * ...@@ -1235,6 +1234,9 @@ static int match_server(struct TCP_Server_Info *server, struct smb3_fs_context *
if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns))
return 0; return 0;
if (strcasecmp(server->hostname, ctx->server_hostname))
return 0;
if (!match_address(server, addr, if (!match_address(server, addr,
(struct sockaddr *)&ctx->srcaddr)) (struct sockaddr *)&ctx->srcaddr))
return 0; return 0;
...@@ -1336,6 +1338,7 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) ...@@ -1336,6 +1338,7 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect)
kfree(server->session_key.response); kfree(server->session_key.response);
server->session_key.response = NULL; server->session_key.response = NULL;
server->session_key.len = 0; server->session_key.len = 0;
kfree(server->hostname);
task = xchg(&server->tsk, NULL); task = xchg(&server->tsk, NULL);
if (task) if (task)
...@@ -1361,14 +1364,15 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx) ...@@ -1361,14 +1364,15 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx)
goto out_err; goto out_err;
} }
tcp_ses->hostname = kstrdup(ctx->server_hostname, GFP_KERNEL);
if (!tcp_ses->hostname) {
rc = -ENOMEM;
goto out_err;
}
tcp_ses->ops = ctx->ops; tcp_ses->ops = ctx->ops;
tcp_ses->vals = ctx->vals; tcp_ses->vals = ctx->vals;
cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns)); cifs_set_net_ns(tcp_ses, get_net(current->nsproxy->net_ns));
tcp_ses->hostname = extract_hostname(ctx->UNC);
if (IS_ERR(tcp_ses->hostname)) {
rc = PTR_ERR(tcp_ses->hostname);
goto out_err_crypto_release;
}
tcp_ses->conn_id = atomic_inc_return(&tcpSesNextId); tcp_ses->conn_id = atomic_inc_return(&tcpSesNextId);
tcp_ses->noblockcnt = ctx->rootfs; tcp_ses->noblockcnt = ctx->rootfs;
...@@ -1497,8 +1501,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx) ...@@ -1497,8 +1501,7 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx)
out_err: out_err:
if (tcp_ses) { if (tcp_ses) {
if (!IS_ERR(tcp_ses->hostname)) kfree(tcp_ses->hostname);
kfree(tcp_ses->hostname);
if (tcp_ses->ssocket) if (tcp_ses->ssocket)
sock_release(tcp_ses->ssocket); sock_release(tcp_ses->ssocket);
kfree(tcp_ses); kfree(tcp_ses);
...@@ -2646,11 +2649,12 @@ generic_ip_connect(struct TCP_Server_Info *server) ...@@ -2646,11 +2649,12 @@ generic_ip_connect(struct TCP_Server_Info *server)
rc = 0; rc = 0;
if (rc < 0) { if (rc < 0) {
cifs_dbg(FYI, "Error %d connecting to server\n", rc); cifs_dbg(FYI, "Error %d connecting to server\n", rc);
trace_smb3_connect_err(server->hostname, server->conn_id, &server->dstaddr, rc);
sock_release(socket); sock_release(socket);
server->ssocket = NULL; server->ssocket = NULL;
return rc; return rc;
} }
trace_smb3_connect_done(server->hostname, server->conn_id, &server->dstaddr);
if (sport == htons(RFC1001_PORT)) if (sport == htons(RFC1001_PORT))
rc = ip_rfc1001_connect(server); rc = ip_rfc1001_connect(server);
......
...@@ -116,6 +116,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = { ...@@ -116,6 +116,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {
fsparam_flag("nosharesock", Opt_nosharesock), fsparam_flag("nosharesock", Opt_nosharesock),
fsparam_flag_no("persistenthandles", Opt_persistent), fsparam_flag_no("persistenthandles", Opt_persistent),
fsparam_flag_no("resilienthandles", Opt_resilient), fsparam_flag_no("resilienthandles", Opt_resilient),
fsparam_flag_no("tcpnodelay", Opt_tcp_nodelay),
fsparam_flag("domainauto", Opt_domainauto), fsparam_flag("domainauto", Opt_domainauto),
fsparam_flag("rdma", Opt_rdma), fsparam_flag("rdma", Opt_rdma),
fsparam_flag("modesid", Opt_modesid), fsparam_flag("modesid", Opt_modesid),
...@@ -318,6 +319,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx ...@@ -318,6 +319,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx
DUP_CTX_STR(mount_options); DUP_CTX_STR(mount_options);
DUP_CTX_STR(username); DUP_CTX_STR(username);
DUP_CTX_STR(password); DUP_CTX_STR(password);
DUP_CTX_STR(server_hostname);
DUP_CTX_STR(UNC); DUP_CTX_STR(UNC);
DUP_CTX_STR(source); DUP_CTX_STR(source);
DUP_CTX_STR(domainname); DUP_CTX_STR(domainname);
...@@ -456,6 +458,11 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx) ...@@ -456,6 +458,11 @@ smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx)
if (!pos) if (!pos)
return -EINVAL; return -EINVAL;
/* record the server hostname */
ctx->server_hostname = kstrndup(devname + 2, pos - devname - 2, GFP_KERNEL);
if (!ctx->server_hostname)
return -ENOMEM;
/* skip past delimiter */ /* skip past delimiter */
++pos; ++pos;
...@@ -1383,6 +1390,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, ...@@ -1383,6 +1390,13 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
} }
} }
break; break;
case Opt_tcp_nodelay:
/* tcp nodelay should not usually be needed since we CORK/UNCORK the socket */
if (result.negated)
ctx->sockopt_tcp_nodelay = false;
else
ctx->sockopt_tcp_nodelay = true;
break;
case Opt_domainauto: case Opt_domainauto:
ctx->domainauto = true; ctx->domainauto = true;
break; break;
...@@ -1496,6 +1510,8 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx) ...@@ -1496,6 +1510,8 @@ smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx)
ctx->username = NULL; ctx->username = NULL;
kfree_sensitive(ctx->password); kfree_sensitive(ctx->password);
ctx->password = NULL; ctx->password = NULL;
kfree(ctx->server_hostname);
ctx->server_hostname = NULL;
kfree(ctx->UNC); kfree(ctx->UNC);
ctx->UNC = NULL; ctx->UNC = NULL;
kfree(ctx->source); kfree(ctx->source);
......
...@@ -98,6 +98,7 @@ enum cifs_param { ...@@ -98,6 +98,7 @@ enum cifs_param {
Opt_nosharesock, Opt_nosharesock,
Opt_persistent, Opt_persistent,
Opt_resilient, Opt_resilient,
Opt_tcp_nodelay,
Opt_domainauto, Opt_domainauto,
Opt_rdma, Opt_rdma,
Opt_modesid, Opt_modesid,
...@@ -166,6 +167,7 @@ struct smb3_fs_context { ...@@ -166,6 +167,7 @@ struct smb3_fs_context {
char *password; char *password;
char *domainname; char *domainname;
char *source; char *source;
char *server_hostname;
char *UNC; char *UNC;
char *nodename; char *nodename;
char *iocharset; /* local code page for mapping to and from Unicode */ char *iocharset; /* local code page for mapping to and from Unicode */
......
...@@ -152,7 +152,7 @@ cifs_buf_get(void) ...@@ -152,7 +152,7 @@ cifs_buf_get(void)
* SMB2 header is bigger than CIFS one - no problems to clean some * SMB2 header is bigger than CIFS one - no problems to clean some
* more bytes for CIFS. * more bytes for CIFS.
*/ */
size_t buf_size = sizeof(struct smb2_sync_hdr); size_t buf_size = sizeof(struct smb2_hdr);
/* /*
* We could use negotiated size instead of max_msgsize - * We could use negotiated size instead of max_msgsize -
......
...@@ -2439,14 +2439,16 @@ smb2_print_status(__le32 status) ...@@ -2439,14 +2439,16 @@ smb2_print_status(__le32 status)
int int
map_smb2_to_linux_error(char *buf, bool log_err) map_smb2_to_linux_error(char *buf, bool log_err)
{ {
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
unsigned int i; unsigned int i;
int rc = -EIO; int rc = -EIO;
__le32 smb2err = shdr->Status; __le32 smb2err = shdr->Status;
if (smb2err == 0) { if (smb2err == 0) {
trace_smb3_cmd_done(shdr->TreeId, shdr->SessionId, trace_smb3_cmd_done(le32_to_cpu(shdr->Id.SyncId.TreeId),
le16_to_cpu(shdr->Command), le64_to_cpu(shdr->MessageId)); le64_to_cpu(shdr->SessionId),
le16_to_cpu(shdr->Command),
le64_to_cpu(shdr->MessageId));
return 0; return 0;
} }
...@@ -2470,8 +2472,10 @@ map_smb2_to_linux_error(char *buf, bool log_err) ...@@ -2470,8 +2472,10 @@ map_smb2_to_linux_error(char *buf, bool log_err)
cifs_dbg(FYI, "Mapping SMB2 status code 0x%08x to POSIX err %d\n", cifs_dbg(FYI, "Mapping SMB2 status code 0x%08x to POSIX err %d\n",
__le32_to_cpu(smb2err), rc); __le32_to_cpu(smb2err), rc);
trace_smb3_cmd_err(shdr->TreeId, shdr->SessionId, trace_smb3_cmd_err(le32_to_cpu(shdr->Id.SyncId.TreeId),
le16_to_cpu(shdr->Command), le64_to_cpu(shdr->SessionId),
le64_to_cpu(shdr->MessageId), le32_to_cpu(smb2err), rc); le16_to_cpu(shdr->Command),
le64_to_cpu(shdr->MessageId),
le32_to_cpu(smb2err), rc);
return rc; return rc;
} }
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
* *
*/ */
#include <linux/ctype.h> #include <linux/ctype.h>
#include "smb2pdu.h"
#include "cifsglob.h" #include "cifsglob.h"
#include "cifsproto.h" #include "cifsproto.h"
#include "smb2proto.h" #include "smb2proto.h"
...@@ -19,7 +18,7 @@ ...@@ -19,7 +18,7 @@
#include "nterr.h" #include "nterr.h"
static int static int
check_smb2_hdr(struct smb2_sync_hdr *shdr, __u64 mid) check_smb2_hdr(struct smb2_hdr *shdr, __u64 mid)
{ {
__u64 wire_mid = le64_to_cpu(shdr->MessageId); __u64 wire_mid = le64_to_cpu(shdr->MessageId);
...@@ -81,9 +80,9 @@ static const __le16 smb2_rsp_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = { ...@@ -81,9 +80,9 @@ static const __le16 smb2_rsp_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = {
/* SMB2_OPLOCK_BREAK */ cpu_to_le16(24) /* SMB2_OPLOCK_BREAK */ cpu_to_le16(24)
}; };
#define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_sync_hdr) + sizeof(struct smb2_negotiate_rsp)) #define SMB311_NEGPROT_BASE_SIZE (sizeof(struct smb2_hdr) + sizeof(struct smb2_negotiate_rsp))
static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, static __u32 get_neg_ctxt_len(struct smb2_hdr *hdr, __u32 len,
__u32 non_ctxlen) __u32 non_ctxlen)
{ {
__u16 neg_count; __u16 neg_count;
...@@ -135,13 +134,13 @@ static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, ...@@ -135,13 +134,13 @@ static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len,
int int
smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
{ {
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
struct smb2_sync_pdu *pdu = (struct smb2_sync_pdu *)shdr; struct smb2_pdu *pdu = (struct smb2_pdu *)shdr;
__u64 mid; __u64 mid;
__u32 clc_len; /* calculated length */ __u32 clc_len; /* calculated length */
int command; int command;
int pdu_size = sizeof(struct smb2_sync_pdu); int pdu_size = sizeof(struct smb2_pdu);
int hdr_size = sizeof(struct smb2_sync_hdr); int hdr_size = sizeof(struct smb2_hdr);
/* /*
* Add function to do table lookup of StructureSize by command * Add function to do table lookup of StructureSize by command
...@@ -155,7 +154,7 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) ...@@ -155,7 +154,7 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
/* decrypt frame now that it is completely read in */ /* decrypt frame now that it is completely read in */
spin_lock(&cifs_tcp_ses_lock); spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) { list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
if (ses->Suid == thdr->SessionId) if (ses->Suid == le64_to_cpu(thdr->SessionId))
break; break;
} }
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
...@@ -296,7 +295,7 @@ static const bool has_smb2_data_area[NUMBER_OF_SMB2_COMMANDS] = { ...@@ -296,7 +295,7 @@ static const bool has_smb2_data_area[NUMBER_OF_SMB2_COMMANDS] = {
* area and the offset to it (from the beginning of the smb are also returned. * area and the offset to it (from the beginning of the smb are also returned.
*/ */
char * char *
smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr) smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr)
{ {
*off = 0; *off = 0;
*len = 0; *len = 0;
...@@ -401,8 +400,8 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr) ...@@ -401,8 +400,8 @@ smb2_get_data_area_len(int *off, int *len, struct smb2_sync_hdr *shdr)
unsigned int unsigned int
smb2_calc_size(void *buf, struct TCP_Server_Info *srvr) smb2_calc_size(void *buf, struct TCP_Server_Info *srvr)
{ {
struct smb2_sync_pdu *pdu = (struct smb2_sync_pdu *)buf; struct smb2_pdu *pdu = (struct smb2_pdu *)buf;
struct smb2_sync_hdr *shdr = &pdu->sync_hdr; struct smb2_hdr *shdr = &pdu->hdr;
int offset; /* the offset from the beginning of SMB to data area */ int offset; /* the offset from the beginning of SMB to data area */
int data_length; /* the length of the variable length data area */ int data_length; /* the length of the variable length data area */
/* Structure Size has already been checked to make sure it is 64 */ /* Structure Size has already been checked to make sure it is 64 */
...@@ -669,7 +668,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) ...@@ -669,7 +668,7 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server)
cifs_dbg(FYI, "Checking for oplock break\n"); cifs_dbg(FYI, "Checking for oplock break\n");
if (rsp->sync_hdr.Command != SMB2_OPLOCK_BREAK) if (rsp->hdr.Command != SMB2_OPLOCK_BREAK)
return false; return false;
if (rsp->StructureSize != if (rsp->StructureSize !=
...@@ -816,25 +815,25 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, ...@@ -816,25 +815,25 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
int int
smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server) smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server)
{ {
struct smb2_sync_hdr *sync_hdr = mid->resp_buf; struct smb2_hdr *hdr = mid->resp_buf;
struct smb2_create_rsp *rsp = mid->resp_buf; struct smb2_create_rsp *rsp = mid->resp_buf;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
int rc; int rc;
if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || sync_hdr->Command != SMB2_CREATE || if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || hdr->Command != SMB2_CREATE ||
sync_hdr->Status != STATUS_SUCCESS) hdr->Status != STATUS_SUCCESS)
return 0; return 0;
tcon = smb2_find_smb_tcon(server, sync_hdr->SessionId, tcon = smb2_find_smb_tcon(server, le64_to_cpu(hdr->SessionId),
sync_hdr->TreeId); le32_to_cpu(hdr->Id.SyncId.TreeId));
if (!tcon) if (!tcon)
return -ENOENT; return -ENOENT;
rc = __smb2_handle_cancelled_cmd(tcon, rc = __smb2_handle_cancelled_cmd(tcon,
le16_to_cpu(sync_hdr->Command), le16_to_cpu(hdr->Command),
le64_to_cpu(sync_hdr->MessageId), le64_to_cpu(hdr->MessageId),
rsp->PersistentFileId, le64_to_cpu(rsp->PersistentFileId),
rsp->VolatileFileId); le64_to_cpu(rsp->VolatileFileId));
if (rc) if (rc)
cifs_put_tcon(tcon); cifs_put_tcon(tcon);
...@@ -856,10 +855,10 @@ smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec) ...@@ -856,10 +855,10 @@ smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec)
{ {
int i, rc; int i, rc;
struct sdesc *d; struct sdesc *d;
struct smb2_sync_hdr *hdr; struct smb2_hdr *hdr;
struct TCP_Server_Info *server = cifs_ses_server(ses); struct TCP_Server_Info *server = cifs_ses_server(ses);
hdr = (struct smb2_sync_hdr *)iov[0].iov_base; hdr = (struct smb2_hdr *)iov[0].iov_base;
/* neg prot are always taken */ /* neg prot are always taken */
if (hdr->Command == SMB2_NEGOTIATE) if (hdr->Command == SMB2_NEGOTIATE)
goto ok; goto ok;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -25,7 +25,7 @@ extern int smb2_check_message(char *buf, unsigned int length, ...@@ -25,7 +25,7 @@ extern int smb2_check_message(char *buf, unsigned int length,
struct TCP_Server_Info *server); struct TCP_Server_Info *server);
extern unsigned int smb2_calc_size(void *buf, struct TCP_Server_Info *server); extern unsigned int smb2_calc_size(void *buf, struct TCP_Server_Info *server);
extern char *smb2_get_data_area_len(int *off, int *len, extern char *smb2_get_data_area_len(int *off, int *len,
struct smb2_sync_hdr *shdr); struct smb2_hdr *shdr);
extern __le16 *cifs_convert_path_to_utf16(const char *from, extern __le16 *cifs_convert_path_to_utf16(const char *from,
struct cifs_sb_info *cifs_sb); struct cifs_sb_info *cifs_sb);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/mempool.h> #include <linux/mempool.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <crypto/aead.h> #include <crypto/aead.h>
#include "smb2pdu.h"
#include "cifsglob.h" #include "cifsglob.h"
#include "cifsproto.h" #include "cifsproto.h"
#include "smb2proto.h" #include "smb2proto.h"
...@@ -213,14 +212,14 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, ...@@ -213,14 +212,14 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
unsigned char smb2_signature[SMB2_HMACSHA256_SIZE]; unsigned char smb2_signature[SMB2_HMACSHA256_SIZE];
unsigned char *sigptr = smb2_signature; unsigned char *sigptr = smb2_signature;
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base; struct smb2_hdr *shdr = (struct smb2_hdr *)iov[0].iov_base;
struct cifs_ses *ses; struct cifs_ses *ses;
struct shash_desc *shash; struct shash_desc *shash;
struct crypto_shash *hash; struct crypto_shash *hash;
struct sdesc *sdesc = NULL; struct sdesc *sdesc = NULL;
struct smb_rqst drqst; struct smb_rqst drqst;
ses = smb2_find_smb_ses(server, shdr->SessionId); ses = smb2_find_smb_ses(server, le64_to_cpu(shdr->SessionId));
if (!ses) { if (!ses) {
cifs_server_dbg(VFS, "%s: Could not find session\n", __func__); cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
return 0; return 0;
...@@ -534,14 +533,14 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, ...@@ -534,14 +533,14 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
unsigned char smb3_signature[SMB2_CMACAES_SIZE]; unsigned char smb3_signature[SMB2_CMACAES_SIZE];
unsigned char *sigptr = smb3_signature; unsigned char *sigptr = smb3_signature;
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base; struct smb2_hdr *shdr = (struct smb2_hdr *)iov[0].iov_base;
struct shash_desc *shash; struct shash_desc *shash;
struct crypto_shash *hash; struct crypto_shash *hash;
struct sdesc *sdesc = NULL; struct sdesc *sdesc = NULL;
struct smb_rqst drqst; struct smb_rqst drqst;
u8 key[SMB3_SIGN_KEY_SIZE]; u8 key[SMB3_SIGN_KEY_SIZE];
rc = smb2_get_sign_key(shdr->SessionId, server, key); rc = smb2_get_sign_key(le64_to_cpu(shdr->SessionId), server, key);
if (rc) if (rc)
return 0; return 0;
...@@ -611,12 +610,12 @@ static int ...@@ -611,12 +610,12 @@ static int
smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server) smb2_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server)
{ {
int rc = 0; int rc = 0;
struct smb2_sync_hdr *shdr; struct smb2_hdr *shdr;
struct smb2_sess_setup_req *ssr; struct smb2_sess_setup_req *ssr;
bool is_binding; bool is_binding;
bool is_signed; bool is_signed;
shdr = (struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; shdr = (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
ssr = (struct smb2_sess_setup_req *)shdr; ssr = (struct smb2_sess_setup_req *)shdr;
is_binding = shdr->Command == SMB2_SESSION_SETUP && is_binding = shdr->Command == SMB2_SESSION_SETUP &&
...@@ -642,8 +641,8 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) ...@@ -642,8 +641,8 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
{ {
unsigned int rc; unsigned int rc;
char server_response_sig[SMB2_SIGNATURE_SIZE]; char server_response_sig[SMB2_SIGNATURE_SIZE];
struct smb2_sync_hdr *shdr = struct smb2_hdr *shdr =
(struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
if ((shdr->Command == SMB2_NEGOTIATE) || if ((shdr->Command == SMB2_NEGOTIATE) ||
(shdr->Command == SMB2_SESSION_SETUP) || (shdr->Command == SMB2_SESSION_SETUP) ||
...@@ -689,7 +688,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) ...@@ -689,7 +688,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
*/ */
static inline void static inline void
smb2_seq_num_into_buf(struct TCP_Server_Info *server, smb2_seq_num_into_buf(struct TCP_Server_Info *server,
struct smb2_sync_hdr *shdr) struct smb2_hdr *shdr)
{ {
unsigned int i, num = le16_to_cpu(shdr->CreditCharge); unsigned int i, num = le16_to_cpu(shdr->CreditCharge);
...@@ -700,7 +699,7 @@ smb2_seq_num_into_buf(struct TCP_Server_Info *server, ...@@ -700,7 +699,7 @@ smb2_seq_num_into_buf(struct TCP_Server_Info *server,
} }
static struct mid_q_entry * static struct mid_q_entry *
smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr, smb2_mid_entry_alloc(const struct smb2_hdr *shdr,
struct TCP_Server_Info *server) struct TCP_Server_Info *server)
{ {
struct mid_q_entry *temp; struct mid_q_entry *temp;
...@@ -732,14 +731,15 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr, ...@@ -732,14 +731,15 @@ smb2_mid_entry_alloc(const struct smb2_sync_hdr *shdr,
atomic_inc(&midCount); atomic_inc(&midCount);
temp->mid_state = MID_REQUEST_ALLOCATED; temp->mid_state = MID_REQUEST_ALLOCATED;
trace_smb3_cmd_enter(shdr->TreeId, shdr->SessionId, trace_smb3_cmd_enter(le32_to_cpu(shdr->Id.SyncId.TreeId),
le16_to_cpu(shdr->Command), temp->mid); le64_to_cpu(shdr->SessionId),
le16_to_cpu(shdr->Command), temp->mid);
return temp; return temp;
} }
static int static int
smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server, smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
struct smb2_sync_hdr *shdr, struct mid_q_entry **mid) struct smb2_hdr *shdr, struct mid_q_entry **mid)
{ {
if (server->tcpStatus == CifsExiting) if (server->tcpStatus == CifsExiting)
return -ENOENT; return -ENOENT;
...@@ -807,8 +807,8 @@ smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server, ...@@ -807,8 +807,8 @@ smb2_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
struct smb_rqst *rqst) struct smb_rqst *rqst)
{ {
int rc; int rc;
struct smb2_sync_hdr *shdr = struct smb2_hdr *shdr =
(struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
struct mid_q_entry *mid; struct mid_q_entry *mid;
smb2_seq_num_into_buf(server, shdr); smb2_seq_num_into_buf(server, shdr);
...@@ -833,8 +833,8 @@ struct mid_q_entry * ...@@ -833,8 +833,8 @@ struct mid_q_entry *
smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst) smb2_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
{ {
int rc; int rc;
struct smb2_sync_hdr *shdr = struct smb2_hdr *shdr =
(struct smb2_sync_hdr *)rqst->rq_iov[0].iov_base; (struct smb2_hdr *)rqst->rq_iov[0].iov_base;
struct mid_q_entry *mid; struct mid_q_entry *mid;
if (server->tcpStatus == CifsNeedNegotiate && if (server->tcpStatus == CifsNeedNegotiate &&
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#define _CIFS_TRACE_H #define _CIFS_TRACE_H
#include <linux/tracepoint.h> #include <linux/tracepoint.h>
#include <linux/net.h>
#include <linux/inet.h>
/* /*
* Please use this 3-part article as a reference for writing new tracepoints: * Please use this 3-part article as a reference for writing new tracepoints:
...@@ -854,6 +856,75 @@ DEFINE_EVENT(smb3_lease_err_class, smb3_##name, \ ...@@ -854,6 +856,75 @@ DEFINE_EVENT(smb3_lease_err_class, smb3_##name, \
DEFINE_SMB3_LEASE_ERR_EVENT(lease_err); DEFINE_SMB3_LEASE_ERR_EVENT(lease_err);
DECLARE_EVENT_CLASS(smb3_connect_class,
TP_PROTO(char *hostname,
__u64 conn_id,
const struct __kernel_sockaddr_storage *dst_addr),
TP_ARGS(hostname, conn_id, dst_addr),
TP_STRUCT__entry(
__string(hostname, hostname)
__field(__u64, conn_id)
__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
),
TP_fast_assign(
struct sockaddr_storage *pss = NULL;
__entry->conn_id = conn_id;
pss = (struct sockaddr_storage *)__entry->dst_addr;
*pss = *dst_addr;
__assign_str(hostname, hostname);
),
TP_printk("conn_id=0x%llx server=%s addr=%pISpsfc",
__entry->conn_id,
__get_str(hostname),
__entry->dst_addr)
)
#define DEFINE_SMB3_CONNECT_EVENT(name) \
DEFINE_EVENT(smb3_connect_class, smb3_##name, \
TP_PROTO(char *hostname, \
__u64 conn_id, \
const struct __kernel_sockaddr_storage *addr), \
TP_ARGS(hostname, conn_id, addr))
DEFINE_SMB3_CONNECT_EVENT(connect_done);
DECLARE_EVENT_CLASS(smb3_connect_err_class,
TP_PROTO(char *hostname, __u64 conn_id,
const struct __kernel_sockaddr_storage *dst_addr, int rc),
TP_ARGS(hostname, conn_id, dst_addr, rc),
TP_STRUCT__entry(
__string(hostname, hostname)
__field(__u64, conn_id)
__array(__u8, dst_addr, sizeof(struct sockaddr_storage))
__field(int, rc)
),
TP_fast_assign(
struct sockaddr_storage *pss = NULL;
__entry->conn_id = conn_id;
__entry->rc = rc;
pss = (struct sockaddr_storage *)__entry->dst_addr;
*pss = *dst_addr;
__assign_str(hostname, hostname);
),
TP_printk("rc=%d conn_id=0x%llx server=%s addr=%pISpsfc",
__entry->rc,
__entry->conn_id,
__get_str(hostname),
__entry->dst_addr)
)
#define DEFINE_SMB3_CONNECT_ERR_EVENT(name) \
DEFINE_EVENT(smb3_connect_err_class, smb3_##name, \
TP_PROTO(char *hostname, \
__u64 conn_id, \
const struct __kernel_sockaddr_storage *addr, \
int rc), \
TP_ARGS(hostname, conn_id, addr, rc))
DEFINE_SMB3_CONNECT_ERR_EVENT(connect_err);
DECLARE_EVENT_CLASS(smb3_reconnect_class, DECLARE_EVENT_CLASS(smb3_reconnect_class,
TP_PROTO(__u64 currmid, TP_PROTO(__u64 currmid,
__u64 conn_id, __u64 conn_id,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment