Unverified Commit d09efbc6 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3672 smb: client: fix potential OOB in smb2_dump_detail()

parents f99278bc d887e2c0
Loading
Loading
Loading
Loading
+15 −15
Original line number Original line Diff line number Diff line
@@ -165,6 +165,21 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
	}
	}


	mid = le64_to_cpu(shdr->MessageId);
	mid = le64_to_cpu(shdr->MessageId);
	if (check_smb2_hdr(shdr, mid))
		return 1;

	if (shdr->StructureSize != SMB2_HEADER_STRUCTURE_SIZE) {
		cifs_dbg(VFS, "Invalid structure size %u\n",
			 le16_to_cpu(shdr->StructureSize));
		return 1;
	}

	command = le16_to_cpu(shdr->Command);
	if (command >= NUMBER_OF_SMB2_COMMANDS) {
		cifs_dbg(VFS, "Invalid SMB2 command %d\n", command);
		return 1;
	}

	if (len < pdu_size) {
	if (len < pdu_size) {
		if ((len >= hdr_size)
		if ((len >= hdr_size)
		    && (shdr->Status != 0)) {
		    && (shdr->Status != 0)) {
@@ -185,21 +200,6 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
		return 1;
		return 1;
	}
	}


	if (check_smb2_hdr(shdr, mid))
		return 1;

	if (shdr->StructureSize != SMB2_HEADER_STRUCTURE_SIZE) {
		cifs_dbg(VFS, "Illegal structure size %u\n",
			 le16_to_cpu(shdr->StructureSize));
		return 1;
	}

	command = le16_to_cpu(shdr->Command);
	if (command >= NUMBER_OF_SMB2_COMMANDS) {
		cifs_dbg(VFS, "Illegal SMB2 command %d\n", command);
		return 1;
	}

	if (smb2_rsp_struct_sizes[command] != pdu->StructureSize2) {
	if (smb2_rsp_struct_sizes[command] != pdu->StructureSize2) {
		if (command != SMB2_OPLOCK_BREAK_HE && (shdr->Status == 0 ||
		if (command != SMB2_OPLOCK_BREAK_HE && (shdr->Status == 0 ||
		    pdu->StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2)) {
		    pdu->StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2)) {
+4 −2
Original line number Original line Diff line number Diff line
@@ -248,8 +248,10 @@ smb2_dump_detail(void *buf, struct TCP_Server_Info *server)
	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
	cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
		 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId,
		 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId,
		 shdr->ProcessId);
		 shdr->ProcessId);
	if (!server->ops->check_message(buf, server->total_read, server)) {
		cifs_dbg(VFS, "smb buf %p len %u\n", buf,
		cifs_dbg(VFS, "smb buf %p len %u\n", buf,
			 server->ops->calc_smb_size(buf, server));
			 server->ops->calc_smb_size(buf, server));
	}
#endif
#endif
}
}