--- old/usr/src/pkg/manifests/system-test-ostest.mf	Wed Aug 28 02:35:12 2019
+++ new/usr/src/pkg/manifests/system-test-ostest.mf	Wed Aug 28 02:35:12 2019
@@ -46,6 +46,7 @@
 file path=opt/os-tests/tests/file-locking/runtests.32 mode=0555
 file path=opt/os-tests/tests/file-locking/runtests.64 mode=0555
 $(i386_ONLY)file path=opt/os-tests/tests/i386/badseg mode=0555
+$(i386_ONLY)file path=opt/os-tests/tests/i386/badseg_exec mode=0555
 $(i386_ONLY)file path=opt/os-tests/tests/i386/ldt mode=0555
 file path=opt/os-tests/tests/pf_key/acquire-compare mode=0555
 file path=opt/os-tests/tests/pf_key/acquire-spray mode=0555
--- old/usr/src/test/os-tests/tests/i386/Makefile	Wed Aug 28 02:35:13 2019
+++ new/usr/src/test/os-tests/tests/i386/Makefile	Wed Aug 28 02:35:13 2019
@@ -10,13 +10,13 @@
 #
 
 #
-# Copyright 2018 Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
 #
 
 include $(SRC)/cmd/Makefile.cmd
 include $(SRC)/test/Makefile.com
 
-PROGS += ldt badseg
+PROGS += ldt badseg_exec badseg
 
 ROOTOPTPKG = $(ROOT)/opt/os-tests
 TESTDIR = $(ROOTOPTPKG)/tests/i386
@@ -24,7 +24,7 @@
 
 CSTD = $(CSTD_GNU99)
 
-# for badseg
+# for badseg_exec
 COPTFLAG =
 
 all: $(PROGS)
@@ -31,8 +31,6 @@
 
 install: all $(ROOTOPTPROGS)
 
-lint:
-
 clobber: clean
 	-$(RM) $(PROGS)
 
--- /dev/null	Wed Aug 28 02:35:13 2019
+++ new/usr/src/test/os-tests/tests/i386/badseg.sh	Wed Aug 28 02:35:13 2019
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+# Copyright 2019 Joyent, Inc.
+#
+
+#
+# badseg intentionally core-dumps. It does a setrlimit(), but we need to
+# prevent global core dumps too: we'll do this by blocking the path for
+# badseg_exec, but let other processes core dump still just in case.
+#
+
+set -e
+set -x
+
+old_enabled=$(/usr/bin/svcprop -p config_params/global_enabled coreadm)
+old_pattern=$(/usr/bin/svcprop -p config_params/global_pattern coreadm)
+old_log=$(/usr/bin/svcprop -p config_params/global_log_enabled coreadm)
+
+mkfile 1m /var/cores/badseg_exec
+coreadm -e global -d log -g /var/cores/%f/%p
+# let it settle
+sleep 3
+
+$(dirname $0)/badseg_exec || true
+
+coreadm -g "$old_pattern"
+
+if [[ "$old_enabled" = "true" ]]; then
+       coreadm -e global
+fi
+
+if [[ "$old_log" = "true" ]]; then
+       coreadm -e log
+fi
+
+rm -f /var/cores/badseg_exec
--- old/usr/src/test/os-tests/tests/i386/badseg.c	Wed Aug 28 02:35:13 2019
+++ /dev/null	Wed Aug 28 02:35:13 2019
@@ -1,148 +0,0 @@
-/*
- * This file and its contents are supplied under the terms of the
- * Common Development and Distribution License ("CDDL"), version 1.0.
- * You may only use this file in accordance with the terms of version
- * 1.0 of the CDDL.
- *
- * A full copy of the text of the CDDL should have accompanied this
- * source.  A copy of the CDDL is also available via the Internet at
- * http://www.illumos.org/license/CDDL.
- */
-
-/*
- * Copyright 2018 Joyent, Inc.
- */
-
-#include <stdlib.h>
-#include <ucontext.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <sys/regset.h>
-
-/*
- * Load a bunch of bad selectors into the seg regs: this will typically cause
- * the child process to core dump, but it shouldn't panic the kernel...
- *
- * It's especially interesting to run this on CPU0.
- */
-
-unsigned short selector;
-
-static void badds(void)
-{
-	__asm__ volatile("movw %0, %%ds" : : "r" (selector));
-}
-
-static void bades(void)
-{
-	__asm__ volatile("movw %0, %%es" : : "r" (selector));
-}
-
-static void badfs(void)
-{
-	__asm__ volatile("movw %0, %%fs" : : "r" (selector));
-}
-
-static void badgs(void)
-{
-	__asm__ volatile("movw %0, %%gs" : : "r" (selector));
-}
-
-static void badss(void)
-{
-	__asm__ volatile("movw %0, %%ss" : : "r" (selector));
-}
-
-static void
-resetseg(uint_t seg)
-{
-	ucontext_t ucp;
-	volatile int done = 0;
-
-	int rc = getcontext(&ucp);
-	if (done) {
-		(void) getcontext(&ucp);
-		return;
-	}
-
-	if (rc == 0) {
-		done = 1;
-		ucp.uc_mcontext.gregs[seg] = selector;
-		(void) setcontext(&ucp);
-	}
-	abort();
-}
-
-static void
-resetcs(void)
-{
-	return (resetseg(CS));
-}
-
-static void
-resetds(void)
-{
-	return (resetseg(DS));
-}
-
-static void
-resetes(void)
-{
-	return (resetseg(ES));
-}
-
-static void
-resetfs(void)
-{
-	return (resetseg(FS));
-}
-
-static void
-resetgs(void)
-{
-	return (resetseg(GS));
-}
-
-static void
-resetss(void)
-{
-	return (resetseg(SS));
-}
-
-static void
-inchild(void (*func)())
-{
-	pid_t pid;
-
-	switch ((pid = fork())) {
-	case 0:
-		func();
-		exit(0);
-	case -1:
-		exit(1);
-	default:
-		(void) waitpid(pid, NULL, 0);
-		return;
-	}
-
-}
-
-int
-main(int argc, char *argv[])
-{
-	for (selector = 0; selector < 8194; selector++) {
-		inchild(resetcs);
-		inchild(resetds);
-		inchild(resetes);
-		inchild(resetfs);
-		inchild(resetgs);
-		inchild(resetss);
-		inchild(badds);
-		inchild(bades);
-		inchild(badfs);
-		inchild(badgs);
-		inchild(badss);
-	}
-
-	exit(0);
-}
--- /dev/null	Wed Aug 28 02:35:13 2019
+++ new/usr/src/test/os-tests/tests/i386/badseg_exec.c	Wed Aug 28 02:35:13 2019
@@ -0,0 +1,156 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2019 Joyent, Inc.
+ */
+
+#include <stdlib.h>
+#include <ucontext.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/regset.h>
+#include <sys/resource.h>
+#include <err.h>
+
+/*
+ * Load a bunch of bad selectors into the seg regs: this will typically cause
+ * the child process to core dump, but it shouldn't panic the kernel...
+ *
+ * It's especially interesting to run this on CPU0.
+ */
+
+unsigned short selector;
+
+static void badds(void)
+{
+	__asm__ volatile("movw %0, %%ds" : : "r" (selector));
+}
+
+static void bades(void)
+{
+	__asm__ volatile("movw %0, %%es" : : "r" (selector));
+}
+
+static void badfs(void)
+{
+	__asm__ volatile("movw %0, %%fs" : : "r" (selector));
+}
+
+static void badgs(void)
+{
+	__asm__ volatile("movw %0, %%gs" : : "r" (selector));
+}
+
+static void badss(void)
+{
+	__asm__ volatile("movw %0, %%ss" : : "r" (selector));
+}
+
+static void
+resetseg(uint_t seg)
+{
+	ucontext_t ucp;
+	volatile int done = 0;
+
+	int rc = getcontext(&ucp);
+	if (done) {
+		(void) getcontext(&ucp);
+		return;
+	}
+
+	if (rc == 0) {
+		done = 1;
+		ucp.uc_mcontext.gregs[seg] = selector;
+		(void) setcontext(&ucp);
+	}
+	abort();
+}
+
+static void
+resetcs(void)
+{
+	return (resetseg(CS));
+}
+
+static void
+resetds(void)
+{
+	return (resetseg(DS));
+}
+
+static void
+resetes(void)
+{
+	return (resetseg(ES));
+}
+
+static void
+resetfs(void)
+{
+	return (resetseg(FS));
+}
+
+static void
+resetgs(void)
+{
+	return (resetseg(GS));
+}
+
+static void
+resetss(void)
+{
+	return (resetseg(SS));
+}
+
+static void
+inchild(void (*func)())
+{
+	pid_t pid;
+
+	switch ((pid = fork())) {
+	case 0:
+		func();
+		exit(EXIT_SUCCESS);
+	case -1:
+		exit(EXIT_FAILURE);
+	default:
+		(void) waitpid(pid, NULL, 0);
+		return;
+	}
+
+}
+
+int
+main(int argc, char *argv[])
+{
+	struct rlimit rl = { 0, };
+
+	if (setrlimit(RLIMIT_CORE, &rl) != 0) {
+		err(EXIT_FAILURE, "failed to disable cores");
+	}
+
+	for (selector = 0; selector < 8194; selector++) {
+		inchild(resetcs);
+		inchild(resetds);
+		inchild(resetes);
+		inchild(resetfs);
+		inchild(resetgs);
+		inchild(resetss);
+		inchild(badds);
+		inchild(bades);
+		inchild(badfs);
+		inchild(badgs);
+		inchild(badss);
+	}
+
+	exit(EXIT_SUCCESS);
+}
