Commit c2f3b108 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag '6.17-RC4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

 - Fix two potential NULL pointer references

 - Two debugging improvements (to help debug recent issues) a new
   tracepoint, and minor improvement to DebugData

 - Trivial comment cleanup

* tag '6.17-RC4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: prevent NULL pointer dereference in UTF16 conversion
  smb: client: show negotiated cipher in DebugData
  smb: client: add new tracepoint to trace lease break notification
  smb: client: fix spellings in comments
  smb: client: Fix NULL pointer dereference in cifs_debug_dirs_proc_show()
parents 260aa8d5 70bccd98
Loading
Loading
Loading
Loading
+24 −7
Original line number Diff line number Diff line
@@ -304,6 +304,8 @@ static int cifs_debug_dirs_proc_show(struct seq_file *m, void *v)
			list_for_each(tmp1, &ses->tcon_list) {
				tcon = list_entry(tmp1, struct cifs_tcon, tcon_list);
				cfids = tcon->cfids;
				if (!cfids)
					continue;
				spin_lock(&cfids->cfid_list_lock); /* check lock ordering */
				seq_printf(m, "Num entries: %d\n", cfids->num_entries);
				list_for_each_entry(cfid, &cfids->entries, entry) {
@@ -319,8 +321,6 @@ static int cifs_debug_dirs_proc_show(struct seq_file *m, void *v)
					seq_printf(m, "\n");
				}
				spin_unlock(&cfids->cfid_list_lock);


			}
		}
	}
@@ -347,6 +347,22 @@ static __always_inline const char *compression_alg_str(__le16 alg)
	}
}

static __always_inline const char *cipher_alg_str(__le16 cipher)
{
	switch (cipher) {
	case SMB2_ENCRYPTION_AES128_CCM:
		return "AES128-CCM";
	case SMB2_ENCRYPTION_AES128_GCM:
		return "AES128-GCM";
	case SMB2_ENCRYPTION_AES256_CCM:
		return "AES256-CCM";
	case SMB2_ENCRYPTION_AES256_GCM:
		return "AES256-GCM";
	default:
		return "UNKNOWN";
	}
}

static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
{
	struct mid_q_entry *mid_entry;
@@ -539,6 +555,11 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
		else
			seq_puts(m, "disabled (not supported by this server)");

		/* Show negotiated encryption cipher, even if not required */
		seq_puts(m, "\nEncryption: ");
		if (server->cipher_type)
			seq_printf(m, "Negotiated cipher (%s)", cipher_alg_str(server->cipher_type));

		seq_printf(m, "\n\n\tSessions: ");
		i = 0;
		list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
@@ -576,12 +597,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)

			/* dump session id helpful for use with network trace */
			seq_printf(m, " SessionId: 0x%llx", ses->Suid);
			if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA) {
			if (ses->session_flags & SMB2_SESSION_FLAG_ENCRYPT_DATA)
				seq_puts(m, " encrypted");
				/* can help in debugging to show encryption type */
				if (server->cipher_type == SMB2_ENCRYPTION_AES256_GCM)
					seq_puts(m, "(gcm256)");
			}
			if (ses->sign)
				seq_puts(m, " signed");

+3 −0
Original line number Diff line number Diff line
@@ -629,6 +629,9 @@ cifs_strndup_to_utf16(const char *src, const int maxlen, int *utf16_len,
	int len;
	__le16 *dst;

	if (!src)
		return NULL;

	len = cifs_local_to_utf16_bytes(src, maxlen, cp);
	len += 2; /* NULL */
	dst = kmalloc(len, GFP_KERNEL);
+1 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ static int detect_directory_symlink_target(struct cifs_sb_info *cifs_sb,
	}

	/*
	 * For absolute symlinks it is not possible to determinate
	 * For absolute symlinks it is not possible to determine
	 * if it should point to directory or file.
	 */
	if (symname[0] == '/') {
+2 −2
Original line number Diff line number Diff line
@@ -1005,7 +1005,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
			rc = -EOPNOTSUPP;
	}

	/* Fallback to SMB_COM_SETATTR command when absolutelty needed. */
	/* Fallback to SMB_COM_SETATTR command when absolutely needed. */
	if (rc == -EOPNOTSUPP) {
		cifs_dbg(FYI, "calling SetInformation since SetPathInfo for attrs/times not supported by this server\n");
		rc = SMBSetInformation(xid, tcon, full_path,
@@ -1039,7 +1039,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
		cifsFileInfo_put(open_file);

	/*
	 * Setting the read-only bit is not honered on non-NT servers when done
	* Setting the read-only bit is not honored on non-NT servers when done
	 * via open-semantics. So for setting it, use SMB_COM_SETATTR command.
	 * This command works only after the file is closed, so use it only when
	 * operation was called without the filehandle.
+15 −4
Original line number Diff line number Diff line
@@ -614,6 +614,15 @@ smb2_is_valid_lease_break(char *buffer, struct TCP_Server_Info *server)
	struct cifs_tcon *tcon;
	struct cifs_pending_open *open;

	/* Trace receipt of lease break request from server */
	trace_smb3_lease_break_enter(le32_to_cpu(rsp->CurrentLeaseState),
		le32_to_cpu(rsp->Flags),
		le16_to_cpu(rsp->Epoch),
		le32_to_cpu(rsp->hdr.Id.SyncId.TreeId),
		le64_to_cpu(rsp->hdr.SessionId),
		*((u64 *)rsp->LeaseKey),
		*((u64 *)&rsp->LeaseKey[8]));

	cifs_dbg(FYI, "Checking for lease break\n");

	/* If server is a channel, select the primary channel */
@@ -660,6 +669,8 @@ smb2_is_valid_lease_break(char *buffer, struct TCP_Server_Info *server)
	spin_unlock(&cifs_tcp_ses_lock);
	cifs_dbg(FYI, "Can not process lease break - no lease matched\n");
	trace_smb3_lease_not_found(le32_to_cpu(rsp->CurrentLeaseState),
					   le32_to_cpu(rsp->Flags),
					   le16_to_cpu(rsp->Epoch),
					   le32_to_cpu(rsp->hdr.Id.SyncId.TreeId),
					   le64_to_cpu(rsp->hdr.SessionId),
					   *((u64 *)rsp->LeaseKey),
Loading