Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 09c9b0ea authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag '4.17-rc1SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "SMB3 fixes, a few for stable, and some important cleanup work from
  Ronnie of the smb3 transport code"

* tag '4.17-rc1SMB3-Fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: change validate_buf to validate_iov
  cifs: remove rfc1002 hardcoded constants from cifs_discard_remaining_data()
  cifs: Change SMB2_open to return an iov for the error parameter
  cifs: add resp_buf_size to the mid_q_entry structure
  smb3.11: replace a 4 with server->vals->header_preamble_size
  cifs: replace a 4 with server->vals->header_preamble_size
  cifs: add pdu_size to the TCP_Server_Info structure
  SMB311: Improve checking of negotiate security contexts
  SMB3: Fix length checking of SMB3.11 negotiate request
  CIFS: add ONCE flag for cifs_dbg type
  cifs: Use ULL suffix for 64-bit constant
  SMB3: Log at least once if tree connect fails during reconnect
  cifs: smb2pdu: Fix potential NULL pointer dereference
parents f0d98d85 c1596ff5
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -42,23 +42,6 @@ cifs_dump_mem(char *label, void *data, int length)
		       data, length, true);
}

#ifdef CONFIG_CIFS_DEBUG
void cifs_vfs_err(const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;

	va_start(args, fmt);

	vaf.fmt = fmt;
	vaf.va = &args;

	pr_err_ratelimited("CIFS VFS: %pV", &vaf);

	va_end(args);
}
#endif

void cifs_dump_detail(void *buf)
{
#ifdef CONFIG_CIFS_DEBUG2
+22 −12
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ extern int cifsFYI;
#else
#define NOISY 0
#endif
#define ONCE 8

/*
 *	debug ON
@@ -46,21 +47,30 @@ extern int cifsFYI;
 */
#ifdef CONFIG_CIFS_DEBUG

__printf(1, 2) void cifs_vfs_err(const char *fmt, ...);

/* information message: e.g., configuration, major event */
#define cifs_dbg(type, fmt, ...)					\
#define cifs_dbg_func(ratefunc, type, fmt, ...)			\
do {								\
	if (type == FYI && cifsFYI & CIFS_INFO) {			\
		pr_debug_ratelimited("%s: "				\
	if ((type) & FYI && cifsFYI & CIFS_INFO) {		\
		pr_debug_ ## ratefunc("%s: "			\
				fmt, __FILE__, ##__VA_ARGS__);	\
	} else if (type == VFS) {					\
		cifs_vfs_err(fmt, ##__VA_ARGS__);			\
	} else if (type == NOISY && type != 0) {			\
		pr_debug_ratelimited(fmt, ##__VA_ARGS__);		\
	} else if ((type) & VFS) {				\
		pr_err_ ## ratefunc("CuIFS VFS: "		\
				 fmt, ##__VA_ARGS__);		\
	} else if ((type) & NOISY && (NOISY != 0)) {		\
		pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__);	\
	}							\
} while (0)

#define cifs_dbg(type, fmt, ...) \
do {							\
	if ((type) & ONCE)				\
		cifs_dbg_func(once,			\
			 type, fmt, ##__VA_ARGS__);	\
	else						\
		cifs_dbg_func(ratelimited,		\
			type, fmt, ##__VA_ARGS__);	\
} while (0)

/*
 *	debug OFF
 *	---------
+4 −0
Original line number Diff line number Diff line
@@ -665,6 +665,8 @@ struct TCP_Server_Info {
	struct delayed_work	echo; /* echo ping workqueue job */
	char	*smallbuf;	/* pointer to current "small" buffer */
	char	*bigbuf;	/* pointer to current "big" buffer */
	/* Total size of this PDU. Only valid from cifs_demultiplex_thread */
	unsigned int pdu_size;
	unsigned int total_read; /* total amount of data read in this pass */
#ifdef CONFIG_CIFS_FSCACHE
	struct fscache_cookie   *fscache; /* client index cache cookie */
@@ -676,6 +678,7 @@ struct TCP_Server_Info {
	unsigned int	max_read;
	unsigned int	max_write;
#ifdef CONFIG_CIFS_SMB311
	__le16	cipher_type;
	 /* save initital negprot hash */
	__u8	preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
#endif /* 3.1.1 */
@@ -1373,6 +1376,7 @@ struct mid_q_entry {
	mid_handle_t *handle; /* call handle mid callback */
	void *callback_data;	  /* general purpose pointer for callback */
	void *resp_buf;		/* pointer to received SMB header */
	unsigned int resp_buf_size;
	int mid_state;	/* wish this were enum but can not pass to wait_event */
	unsigned int mid_flags;
	__le16 command;		/* smb command code */
+7 −4
Original line number Diff line number Diff line
@@ -206,8 +206,10 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
	mutex_unlock(&ses->session_mutex);
	cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);

	if (rc)
	if (rc) {
		printk_once(KERN_WARNING "reconnect tcon failed rc = %d\n", rc);
		goto out;
	}

	atomic_inc(&tconInfoReconnectCount);

@@ -1416,8 +1418,9 @@ CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
int
cifs_discard_remaining_data(struct TCP_Server_Info *server)
{
	unsigned int rfclen = get_rfc1002_length(server->smallbuf);
	int remaining = rfclen + 4 - server->total_read;
	unsigned int rfclen = server->pdu_size;
	int remaining = rfclen + server->vals->header_preamble_size -
		server->total_read;

	while (remaining > 0) {
		int length;
@@ -1454,7 +1457,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
	unsigned int data_offset, data_len;
	struct cifs_readdata *rdata = mid->callback_data;
	char *buf = server->smallbuf;
	unsigned int buflen = get_rfc1002_length(buf) +
	unsigned int buflen = server->pdu_size +
		server->vals->header_preamble_size;
	bool use_rdma_mr = false;

+3 −1
Original line number Diff line number Diff line
@@ -772,7 +772,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
	int length;
	char *buf = server->smallbuf;
	unsigned int pdu_length = get_rfc1002_length(buf);
	unsigned int pdu_length = server->pdu_size;

	/* make sure this will fit in a large buffer */
	if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
@@ -881,6 +881,7 @@ cifs_demultiplex_thread(void *p)
		 * so we can now interpret the length field.
		 */
		pdu_length = get_rfc1002_length(buf);
		server->pdu_size = pdu_length;

		cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
		if (!is_smb_response(server, buf[0]))
@@ -927,6 +928,7 @@ cifs_demultiplex_thread(void *p)

		server->lstrp = jiffies;
		if (mid_entry != NULL) {
			mid_entry->resp_buf_size = server->pdu_size;
			if ((mid_entry->mid_flags & MID_WAIT_CANCELLED) &&
			     mid_entry->mid_state == MID_RESPONSE_RECEIVED &&
					server->ops->handle_cancelled_mid)
Loading