changeset 24294:bc91c75ddbd7

[illumos-gate merge] commit f557613a52efd99cf11a085bca7a35c5e93315f1 12001 cpu_uarray_free(NULL) panics commit 6b02bf31e294d16b68704ede69fdbddaf757fe30 11999 installboot: multiple stage1 locations are mismanaged commit a8661d6d41898fc90e65007115e5c3be62013bbf 11863 SMB2 CREATE should validate impersonation level 11864 SMB2 CREATE should reject absolute paths 11865 SMB2 CREATE should check MxAc create context size commit 327d9711d19fe801a2788ee1cbc0f9de27f6e8b5 11791 idm: this statement may fall through commit 5f1e4180f616c1eac1d07284e8238a8759a414d1 12000 mdb: disk_label does compute gpt partition array crc wrong commit b5acee43ccb19bbf950ab21d1d87ef9d8d47ca9e 11991 format: first efi partition can start from efi_first_u_lba Conflicts: usr/src/test/crypto-tests/tests/modes/aes/ctr/aes_ctr.c
author Jerry Jelinek <jerry.jelinek@joyent.com>
date Wed, 20 Nov 2019 12:34:54 +0000
parents e1297b786920 (current diff) c237145c3351 (diff)
children 6bce93a3a5ec
files usr/src/test/crypto-tests/tests/common/cryptotest.h usr/src/test/crypto-tests/tests/common/cryptotest_pkcs.c
diffstat 8 files changed, 81 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/boot/installboot/i386/installboot.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/cmd/boot/installboot/i386/installboot.c	Wed Nov 20 12:34:54 2019 +0000
@@ -453,8 +453,8 @@
 compare_stage1_cb(struct partlist *plist)
 {
 	if (write_vbr) {
-		(void) printf("%s will be written to %s\n", plist->pl_src_name,
-		    plist->pl_devname);
+		(void) printf("%s is newer than one in %s\n",
+		    plist->pl_src_name, plist->pl_devname);
 	}
 	return (write_vbr);
 }
@@ -1993,7 +1993,29 @@
 	struct partlist *mbr, *stage1, *stage2;
 	uuid_t uuid;
 
+	/*
+	 * Create disk uuid. We only need reasonable amount of uniqueness
+	 * to allow biosdev to identify disk based on mbr differences.
+	 */
+	uuid_generate(uuid);
+
 	mbr = stage1 = stage2 = NULL;
+
+	/* First find stage 2. */
+	STAILQ_FOREACH(pl, data->plist, pl_next) {
+		if (pl->pl_type == IB_BBLK_STAGE2) {
+			stage2 = pl;
+
+			/*
+			 * When stage2 needs update, make sure we also
+			 * update stage1.
+			 */
+			if (pl->pl_cb.compare != NULL &&
+			    pl->pl_cb.compare(pl))
+				write_vbr = true;
+			break;
+		}
+	}
 	/*
 	 * Walk list and pick up BIOS boot blocks. EFI boot programs
 	 * can be set in place.
@@ -2005,10 +2027,10 @@
 			break;
 		case IB_BBLK_STAGE1:
 			stage1 = pl;
+			if (stage2 != NULL)
+				prepare_stage1(stage1, stage2, uuid);
 			break;
 		case IB_BBLK_STAGE2:
-			stage2 = pl;
-			/* FALLTHROUGH */
 		case IB_BBLK_EFI:
 			prepare_bootblock(data, pl, update_str);
 			break;
@@ -2021,12 +2043,6 @@
 	if (stage2 == NULL)
 		return;
 
-	/*
-	 * Create disk uuid. We only need reasonable amount of uniqueness
-	 * to allow biosdev to identify disk based on mbr differences.
-	 */
-	uuid_generate(uuid);
-
 	if (mbr != NULL) {
 		prepare_stage1(mbr, stage2, uuid);
 
@@ -2041,10 +2057,6 @@
 			    stage1->pl_device->stage.start;
 		}
 	}
-
-	if (stage1 != NULL) {
-		prepare_stage1(stage1, stage2, uuid);
-	}
 }
 
 /*
--- a/usr/src/cmd/format/menu_command.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/cmd/format/menu_command.c	Wed Nov 20 12:34:54 2019 +0000
@@ -574,16 +574,18 @@
 		 */
 		new_partitiontable(tptr, oldtype);
 	} else if ((index == other_choice) && (cur_label == L_TYPE_EFI)) {
+		uint64_t start_lba = cur_parts->etoc->efi_first_u_lba;
+
 		maxLBA = get_mlba();
 		cur_parts->etoc->efi_last_lba = maxLBA;
-		cur_parts->etoc->efi_last_u_lba = maxLBA - 34;
+		cur_parts->etoc->efi_last_u_lba = maxLBA - start_lba;
 		for (i = 0; i < cur_parts->etoc->efi_nparts; i++) {
 			cur_parts->etoc->efi_parts[i].p_start = 0;
 			cur_parts->etoc->efi_parts[i].p_size = 0;
 			cur_parts->etoc->efi_parts[i].p_tag = V_UNASSIGNED;
 		}
 		cur_parts->etoc->efi_parts[8].p_start =
-		    maxLBA - 34 - (1024 * 16);
+		    maxLBA - start_lba - (1024 * 16);
 		cur_parts->etoc->efi_parts[8].p_size = (1024 * 16);
 		cur_parts->etoc->efi_parts[8].p_tag = V_RESERVED;
 		if (write_label()) {
@@ -1103,7 +1105,7 @@
 	 * cause the user to sit for quite awhile with no control, but we
 	 * don't have any other good way of keeping their gun from going off.
 	 */
-	clock = time((time_t *)0);
+	clock = time(NULL);
 	fmt_print("Beginning format. The current time is %s\n",
 	    ctime(&clock));
 	enter_critical();
@@ -1126,7 +1128,7 @@
 				cur_flags |= LABEL_DIRTY;
 		}
 	} else if (cur_disk->label_type == L_TYPE_EFI) {
-		if (start < 34) {
+		if (start < cur_parts->etoc->efi_first_u_lba) {
 			if (cur_disk->disk_flags & DSK_LABEL)
 				cur_flags |= LABEL_DIRTY;
 		}
--- a/usr/src/cmd/format/modify_partition.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/cmd/format/modify_partition.c	Wed Nov 20 12:34:54 2019 +0000
@@ -559,7 +559,7 @@
 	u_ioparam_t	ioparam;
 	char		tmpstr[80];
 	uint64_t	i64;
-	uint64_t	start_lba = 34;
+	uint64_t	start_lba = map->efi_first_u_lba;
 
 	for (i = 0; i < map->efi_nparts - 1; i++) {
 		if (i == float_part)
--- a/usr/src/cmd/format/partition.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/cmd/format/partition.c	Wed Nov 20 12:34:54 2019 +0000
@@ -104,7 +104,7 @@
 	    }
 	}
 	if (max == 0)
-	    max = 34;
+	    max = map->efi_first_u_lba;
 	return (max);
 }
 
@@ -158,7 +158,7 @@
 	    ioparam.io_slist = pflag_choices;
 	    flag = input(FIO_SLIST, msg, ':', &ioparam, &deflt, DATA_INPUT);
 
-	    ioparam.io_bounds.lower = 34;
+	    ioparam.io_bounds.lower = cur_parts->etoc->efi_first_u_lba;
 	    ioparam.io_bounds.upper = cur_parts->etoc->efi_last_u_lba;
 
 	    efi_deflt.start_sector = maxofN(cur_parts->etoc);
--- a/usr/src/cmd/mdb/common/modules/disk_label/disk_label.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/cmd/mdb/common/modules/disk_label/disk_label.c	Wed Nov 20 12:34:54 2019 +0000
@@ -562,7 +562,9 @@
 		return (DCMD_ERR);
 	}
 
-	crc = efi_crc32((unsigned char *)gpet, table_size);
+	crc = efi_crc32((unsigned char *)gpet,
+	    header->efi_gpt_SizeOfPartitionEntry *
+	    header->efi_gpt_NumberOfPartitionEntries);
 
 	mdb_printf("PartitionEntryArrayCRC32: %#x (should be %#x)\n",
 	    header->efi_gpt_PartitionEntryArrayCRC32, crc);
--- a/usr/src/uts/common/fs/smbsrv/smb2_create.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/uts/common/fs/smbsrv/smb2_create.c	Wed Nov 20 12:34:54 2019 +0000
@@ -11,6 +11,7 @@
 
 /*
  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2019 RackTop Systems.
  */
 
 /*
@@ -77,6 +78,7 @@
 	smb2_create_ctx_elem_t cc_in_aapl;
 	smb2_create_ctx_elem_t cc_in_dh_request_v2;
 	smb2_create_ctx_elem_t cc_in_dh_reconnect_v2;
+	smb2_create_ctx_elem_t cc_in_max_access;
 	/* Elements we my place in the response */
 	smb2_create_ctx_elem_t cc_out_max_access;
 	smb2_create_ctx_elem_t cc_out_file_id;
@@ -184,7 +186,7 @@
 		goto errout;
 	}
 	if (NameLength == 0) {
-		op->fqi.fq_path.pn_path = "\\";
+		op->fqi.fq_path.pn_path = "";
 	} else {
 		rc = smb_mbc_decodef(&sr->smb_data, "%#U", sr,
 		    NameLength, &op->fqi.fq_path.pn_path);
@@ -192,6 +194,10 @@
 			status = NT_STATUS_OBJECT_PATH_INVALID;
 			goto errout;
 		}
+		if (op->fqi.fq_path.pn_path[0] == '\\') {
+			status = NT_STATUS_INVALID_PARAMETER;
+			goto errout;
+		}
 	}
 	op->fqi.fq_dnode = sr->tid_tree->t_snode;
 
@@ -405,6 +411,19 @@
 
 	/*
 	 * ImpersonationLevel (spec. says validate + ignore)
+	 */
+	switch (ImpersonationLevel) {
+	case SMB2_IMPERSONATION_ANONYMOUS:
+	case SMB2_IMPERSONATION_IDENTIFICATION:
+	case SMB2_IMPERSONATION_IMPERSONATION:
+	case SMB2_IMPERSONATION_DELEGATE:
+		break;
+	default:
+		status = NT_STATUS_BAD_IMPERSONATION_LEVEL;
+		goto cmd_done;
+	}
+
+	/*
 	 * SmbCreateFlags (spec. says ignore)
 	 */
 
@@ -782,7 +801,8 @@
 			break;
 		case SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQ: /* ("MxAc") */
 			cc->cc_in_flags |= CCTX_QUERY_MAX_ACCESS;
-			/* no input data for this */
+			/* Optional input data for this CC. See below. */
+			cce = &cc->cc_in_max_access;
 			break;
 		case SMB2_CREATE_TIMEWARP_TOKEN:	/* ("TWrp") */
 			cc->cc_in_flags |= CCTX_TIMEWARP_TOKEN;
@@ -858,6 +878,21 @@
 				goto errout;
 			break;
 
+		case SMB2_CREATE_QUERY_MAXIMAL_ACCESS_REQ: /* ("MxAc") */
+			/*
+			 * The SMB spec says this can be either 0 bytes
+			 * (handled above) or an 8 byte timestamp value
+			 * but does not say what its purpose is.
+			 *
+			 * Note: The WPTS expects us to validate that it
+			 * is at least 8 bytes so we read it and discard
+			 * it.  If it was too short the decode will fail.
+			 */
+			rc = smb_mbc_decodef(&cce->cce_mbc, "q", &nttime);
+			if (rc != 0)
+				goto errout;
+			break;
+
 		case SMB2_CREATE_TIMEWARP_TOKEN:	/* ("TWrp") */
 			/*
 			 * Support for opening "Previous Versions".
--- a/usr/src/uts/common/io/idm/idm_conn_sm.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/uts/common/io/idm/idm_conn_sm.c	Wed Nov 20 12:34:54 2019 +0000
@@ -1477,7 +1477,7 @@
 		case CS_S8_CLEANUP:
 		case CS_S10_IN_CLEANUP:
 			action = CA_DROP;
-			break;
+			goto validate_pdu_done;
 		default:
 			action = ((event_ctx->iec_pdu_event_type == CT_TX_PDU) ?
 			    CA_TX_PROTOCOL_ERROR : CA_RX_PROTOCOL_ERROR);
@@ -1503,7 +1503,7 @@
 		case CS_S8_CLEANUP:
 		case CS_S10_IN_CLEANUP:
 			action = CA_DROP;
-			break;
+			goto validate_pdu_done;
 		default:
 			action = ((event_ctx->iec_pdu_event_type == CT_TX_PDU) ?
 			    CA_TX_PROTOCOL_ERROR : CA_RX_PROTOCOL_ERROR);
@@ -1523,7 +1523,7 @@
 		case CS_S8_CLEANUP:
 		case CS_S10_IN_CLEANUP:
 			action = CA_DROP;
-			break;
+			goto validate_pdu_done;
 		default:
 			action = ((event_ctx->iec_pdu_event_type == CT_TX_PDU) ?
 			    CA_TX_PROTOCOL_ERROR : CA_RX_PROTOCOL_ERROR);
--- a/usr/src/uts/common/os/cpu_uarray.c	Tue Nov 19 12:46:14 2019 +0000
+++ b/usr/src/uts/common/os/cpu_uarray.c	Wed Nov 20 12:34:54 2019 +0000
@@ -10,7 +10,7 @@
  */
 
 /*
- * Copyright (c) 2018, Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
  */
 
 #include <sys/cpu_uarray.h>
@@ -45,7 +45,8 @@
 void
 cpu_uarray_free(cpu_uarray_t *cua)
 {
-	kmem_free(cua, cpu_uarray_size(cua->cu_nr_items));
+	if (cua != NULL)
+		kmem_free(cua, cpu_uarray_size(cua->cu_nr_items));
 }
 
 uint64_t