diff options
Diffstat (limited to 'usr/src/test/os-tests')
| -rw-r--r-- | usr/src/test/os-tests/runfiles/default.run | 9 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/Makefile | 5 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/OS-6097.c | 74 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/file-locking/Makefile | 16 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/poll/Makefile | 4 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/secflags/secflags_zonecfg.sh | 10 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/tmpfs/Makefile | 52 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh | 114 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh | 74 | ||||
| -rw-r--r-- | usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c | 94 | 
10 files changed, 437 insertions, 15 deletions
| diff --git a/usr/src/test/os-tests/runfiles/default.run b/usr/src/test/os-tests/runfiles/default.run index de2b29f2f1..d432e7be17 100644 --- a/usr/src/test/os-tests/runfiles/default.run +++ b/usr/src/test/os-tests/runfiles/default.run @@ -26,7 +26,7 @@ timeout = 60  post =  outputdir = /var/tmp/test_results -[/opt/os-tests/tests/poll_test] +[/opt/os-tests/tests/poll]  user = root  tests = ['poll_test', 'epoll_test'] @@ -64,6 +64,10 @@ tests = ['sigqueue_queue_size']  user = root  tests = ['sdevfs_eisdir'] +[/opt/os-tests/tests/tmpfs] +user = root +tests = ['tmpfs_badmount', 'tmpfs_enospc'] +  [/opt/os-tests/tests/stress]  user = root  tests = ['dladm-kstat'] @@ -88,6 +92,9 @@ user = root  timeout = 180  tests = ['acquire-compare', 'kmc-update', '15146'] +[/opt/os-tests/tests/OS-6097.32] +[/opt/os-tests/tests/OS-6097.64] +  [/opt/os-tests/tests/ddi_ufm]  user = root  tests = ['ufm-test-setup', 'ufm-test', 'ufm-test-cleanup'] diff --git a/usr/src/test/os-tests/tests/Makefile b/usr/src/test/os-tests/tests/Makefile index a30832e8ee..613dd50f8c 100644 --- a/usr/src/test/os-tests/tests/Makefile +++ b/usr/src/test/os-tests/tests/Makefile @@ -39,6 +39,7 @@ SUBDIRS =       \  		stress \  		syscall \  		timer \ +		tmpfs \  		uccid \  		$(SUBDIRS_$(MACH)) @@ -46,6 +47,7 @@ PROGS = \  	clock_gettime \  	eventfd \  	odirectory \ +	OS-6097 \  	ucontext \  	writev @@ -61,6 +63,9 @@ ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTDIR)/%) \  odirectory.32 :=	LDLIBS += -lsocket  odirectory.64 :=	LDLIBS64 += -lsocket +OS-6097.32 :=	LDLIBS += -ldlpi +OS-6097.64 :=	LDLIBS64 += -ldlpi +  clock_gettime.32 :=	LDLIBS += -lproc  clock_gettime.32 :=	CSTD = $(CSTD_GNU99)  clock_gettime.64 :=	LDLIBS64 += -lproc diff --git a/usr/src/test/os-tests/tests/OS-6097.c b/usr/src/test/os-tests/tests/OS-6097.c new file mode 100644 index 0000000000..160c01e9c7 --- /dev/null +++ b/usr/src/test/os-tests/tests/OS-6097.c @@ -0,0 +1,74 @@ +/* + * 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 (c) 2017, Joyent, Inc. + */ + +/* + * Regression test for OS-6097. + */ + +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <libdlpi.h> +#include <sys/debug.h> + +int +main(void) +{ +	int ret; +	char path[4096]; +	uint_t num = 4294967294U; +	dlpi_handle_t dh; + +	/* +	 * First, we need to determine a path that doesn't exist to trigger this +	 * bug. We start with the highest possible number and just decrement +	 * until we find something. +	 */ + +	while (num > 0) { +		struct stat st; + +		(void) snprintf(path, sizeof (path), "/dev/net/net%u", num); + +		ret = stat(path, &st); +		if (ret == -1 && errno == ENOENT) +			break; +		if (ret == -1) { +			(void) fprintf(stderr, "test failed: unexpected error " +			    "running stat(2) on %s: %s\n", path, +			    strerror(errno)); +			return (1); +		} +		num--; +	} + +	/* +	 * While technically this is a valid entry that we could try, at this +	 * point we've exhausted so many NICs, there's likely a bug. +	 */ +	if (num == 0) { +		(void) fprintf(stderr, "failed to construct a non-existent " +		    "NIC with a name starting with 'net'\n"); +		return (1); +	} + +	(void) snprintf(path, sizeof (path), "net%u", num); +	ret = dlpi_open(path, &dh, 0); +	VERIFY3U(ret, ==, DLPI_ENOLINK); +	return (0); +} diff --git a/usr/src/test/os-tests/tests/file-locking/Makefile b/usr/src/test/os-tests/tests/file-locking/Makefile index 2f8c6762ad..cd0562777d 100644 --- a/usr/src/test/os-tests/tests/file-locking/Makefile +++ b/usr/src/test/os-tests/tests/file-locking/Makefile @@ -10,7 +10,7 @@  #  # -# Copyright 2016 Joyent, Inc. +# Copyright 2020 Joyent, Inc.  #  include $(SRC)/cmd/Makefile.cmd @@ -28,22 +28,21 @@ SRCS = $(PROGS:%=%.c) $(UTILS:%.o=%.c)  PROGS32 = $(PROGS:%=%.32)  PROGS64 = $(PROGS:%=%.64) -LINTS = $(PROGS:%=%.ln) -LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2 -LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2 -  ROOTOPTDIR = $(ROOT)/opt/os-tests/tests/file-locking  ROOTOPTPROGS = $(PROGS32:%=$(ROOTOPTDIR)/%) \  	$(PROGS64:%=$(ROOTOPTDIR)/%) +all     :=      TARGET = all +install :=      TARGET = install +clean   :=      TARGET = clean +clobber :=      TARGET = clobber +  .KEEP_STATE:  install: $(ROOTOPTPROGS)  all: $(PROGS32) $(PROGS64) -lint: $(LINTS) -  clean:  	-rm $(PROGS32) $(PROGS64) @@ -58,9 +57,6 @@ $(ROOTOPTDIR)/%: %  $(ROOTOPTDIR)/%: %.ksh  	$(INS.rename) -%.ln: %.c -	$(LINT.c) $< $(UTILS) $(LDLIBS) -  %.64.o: %.c  	$(COMPILE64.c) $< -o $@ diff --git a/usr/src/test/os-tests/tests/poll/Makefile b/usr/src/test/os-tests/tests/poll/Makefile index ae416f9628..feffc744fb 100644 --- a/usr/src/test/os-tests/tests/poll/Makefile +++ b/usr/src/test/os-tests/tests/poll/Makefile @@ -11,7 +11,7 @@  #  # Copyright (c) 2012 by Delphix. All rights reserved. -# Copyright 2016 Joyent, Inc. +# Copyright 2017 Joyent, Inc.  #  include $(SRC)/cmd/Makefile.cmd @@ -26,7 +26,7 @@ poll_test.ln := LDLIBS += -lsocket  CSTD = $(CSTD_GNU99)  ROOTOPTPKG = $(ROOT)/opt/os-tests -TESTDIR = $(ROOTOPTPKG)/tests +TESTDIR = $(ROOTOPTPKG)/tests/poll  CMDS = $(PROG:%=$(TESTDIR)/%)  $(CMDS) := FILEMODE = 0555 diff --git a/usr/src/test/os-tests/tests/secflags/secflags_zonecfg.sh b/usr/src/test/os-tests/tests/secflags/secflags_zonecfg.sh index 3ea807f9ae..699b4fe04a 100644 --- a/usr/src/test/os-tests/tests/secflags/secflags_zonecfg.sh +++ b/usr/src/test/os-tests/tests/secflags/secflags_zonecfg.sh @@ -12,14 +12,20 @@  #  # Copyright 2015, Richard Lowe. +# Copyright 2019 Joyent, Inc.  # Verify that zones can be configured with security-flags  LC_ALL=C                        # Collation is important +IS_SMARTOS=$(uname -v | grep ^joyent_) +if [[ -z "$IS_SMARTOS" ]]; then +    create_flag="-b" +fi +  expect_success() {      name=$1 -    (echo "create -b"; +    (echo "create $create_flag";       echo "set zonepath=/$name.$$";       cat /dev/stdin;       echo "verify"; @@ -46,7 +52,7 @@ expect_fail() {      name=$1      expect=$2 -    (echo "create -b"; +    (echo "create $create_flag";       echo "set zonepath=/$name.$$";       cat /dev/stdin;       echo "verify"; diff --git a/usr/src/test/os-tests/tests/tmpfs/Makefile b/usr/src/test/os-tests/tests/tmpfs/Makefile new file mode 100644 index 0000000000..d6515b38fa --- /dev/null +++ b/usr/src/test/os-tests/tests/tmpfs/Makefile @@ -0,0 +1,52 @@ +# +# 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 2016 Joyent, Inc. +# + +include $(SRC)/Makefile.master + +ROOTOPTPKG = $(ROOT)/opt/os-tests +TESTDIR = $(ROOTOPTPKG)/tests/tmpfs + +PROGS = tmpfs_full +SCRIPTS = tmpfs_badmount \ +	  tmpfs_enospc + +include $(SRC)/cmd/Makefile.cmd +include $(SRC)/test/Makefile.com + +CMDS = $(PROGS:%=$(TESTDIR)/%) $(SCRIPTS:%=$(TESTDIR)/%) +$(CMDS) := FILEMODE = 0555 + +all: $(PROGS) + +install: all $(CMDS) + +lint: + +clobber: clean +	-$(RM) $(PROGS) + +clean: +	-$(RM) *.o + +$(CMDS): $(TESTDIR) $(PROGS) + +$(TESTDIR): +	$(INS.dir) + +$(TESTDIR)/%: %.ksh +	$(INS.rename) + +$(TESTDIR)/%: % +	$(INS.file) diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh b/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh new file mode 100644 index 0000000000..7e2c4a6095 --- /dev/null +++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_badmount.ksh @@ -0,0 +1,114 @@ +#!/usr/bin/ksh +# +# 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 2016 Joyent, Inc. +# + +# +# Test various options to try and mount a tmpfs. Aside from the first to +# verify that we can mount tmpfs at all, these should all fail. +# + +tb_arg0=$(basename $0) +tb_mountpoint="/var/tmp/$0.$$" +tb_mount=/usr/sbin/mount +tb_umount=/usr/sbin/umount + +function fatal +{ +	rmdir $tb_mountpoint +	typeset msg="$*" +	[[ -z "$msg" ]] && msg="test failed" +	echo "$tb_arg0: test failed $msg" >&2 +	exit 1 +} + +function check_mount +{ +	mkdir -p $tb_mountpoint || fatal \ +	    "failed to make mountpoint $tb_mountpoint" +	$tb_mount -F tmpfs swap $tb_mountpoint || fatal \ +	    "failed to mount tmpfs, check user perms" +	$tb_umount $tb_mountpoint || fatal \ +	    "failed to unmount test point" +} + +function test_one +{ +	typeset opts=$1 + +	[[ -z "$opts" ]] && fatal "missing required opts" +	$tb_mount -F tmpfs -o $opts swap $tb_mountpoint 2>/dev/null +	if [[ $? -eq 0 ]]; then +		$tb_umount $tb_mountpoint +		fatal "successfully mounted with opts $opts, expected failure" +	fi +} + +check_mount + +# +# Test invalid percentages. +# +test_one "size=-5%" +test_one "size=200%" +test_one "size=55.55555%" +test_one "size=100.0%" +test_one "size=bad%" +test_one "size=30g%" +test_one "size=%" +test_one "size=%wat" + +# +# Test invalid sizes. Only kmg are valid prefixes. +# +test_one "size=hello;world" +test_one "size=0xnope" +test_one "size=3.14g" +test_one "size=3;14" +test_one "size=thisisanormalsize" +test_one "size=" +test_one "size=100mtry" + +# +# Now, we need to try and trigger a bunch of overflow. We're going to do +# this assuming we're on a 64-bit kernel (which will always overflow a +# 32-bit kernel). +# +test_one "size=20000000000000000000" +test_one "size=1ggggggggggggggggggg" +test_one "size=1mmmmmmmmmmmmmmmmmmm" +test_one "size=1kkkkkkkkkkkkkkkkkkk" +test_one "size=1kkkkkkkkkkkkkkkkkkk" +test_one "size=18014398509481983k" +test_one "size=17592186044416m" +test_one "size=17179869185g" +test_one "size=17179869184g" + +# +# Let's throw a couple bad modes around while we're here. +# +test_one "mode=17777" +test_one "mode=27777" +test_one "mode=37777" +test_one "mode=47777" +test_one "mode=57777" +test_one "mode=67777" +test_one "mode=77777" +test_one "mode=87777" +test_one "mode=97777" +test_one "mode=asdf" +test_one "mode=deadbeef" +test_one "mode=kefka" + +rmdir $tb_mountpoint diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh b/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh new file mode 100644 index 0000000000..a285f306e2 --- /dev/null +++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_enospc.ksh @@ -0,0 +1,74 @@ +#!/usr/bin/ksh +# +# 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 2016 Joyent, Inc. +# + +# +# Verify that if we fill up a tmpfs that we can't then perform +# additional things to it that would result in the creation or use of +# kernel memory. +# + +te_arg0=$(basename $0) +te_root=$(dirname $0) +te_bin=$te_root/tmpfs_full +te_mountpoint="/var/tmp/$0.$$" +te_mount=/usr/sbin/mount +te_umount=/usr/sbin/umount +te_testfile=1m +te_mounted= +te_exit=1 + +function fatal +{ +	[[ -n "$te_mounted" ]] && $te_umount $te_mountpoint +	rmdir $te_mountpoint +	typeset msg="$*" +	[[ -z "$msg" ]] && msg="test failed" +	echo "$te_arg0: test failed $msg" >&2 +	exit 1 +} + +function setup +{ +	typeset ofile=$te_mountpoint/$te_testfile + +	mkdir -p $te_mountpoint || fatal \ +	    "failed to make mountpoint $te_mountpoint" +	$te_mount -F tmpfs swap $te_mountpoint || fatal \ +	    "failed to mount tmpfs, check user perms" +	te_mounted=1 +	dd if=/dev/zero of=$ofile bs=1M count=1 2>/dev/null || fatal \ +	    "failed to create a 1 MB file" +	$te_mount -F tmpfs -o remount,size=512k swap $te_mountpoint || +	    fatal "failed to remount tmpfs" +} + +function run_test +{ +	$te_bin $te_mountpoint $te_testfile || fatal "$te_bin failed" +} + +function cleanup +{ +	te_mounted= +	$te_umount $te_mountpoint || fatal "failed to unmount $te_mountpoint" +	rmdir $te_mountpoint || fatal "failed to remove $te_mountpoint" +} + +setup +run_test +cleanup + +exit 0 diff --git a/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c b/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c new file mode 100644 index 0000000000..6c6037710b --- /dev/null +++ b/usr/src/test/os-tests/tests/tmpfs/tmpfs_full.c @@ -0,0 +1,94 @@ +/* + * 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 2016 Joyent, Inc. + */ + +/* + * Given a path to a tmpfs that has already been marked as full, attempt to + * perform certain activities on it, all of which should fail with ENOSPC. + */ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/statvfs.h> +#include <fcntl.h> +#include <errno.h> +#include <strings.h> +#include <sys/debug.h> +#include <unistd.h> + +int +main(int argc, const char *argv[]) +{ +	int fd, ret; +	struct statvfs vfs; + +	if (argc != 3) { +		fprintf(stderr, "test failed: missing path or file\n"); +		return (1); +	} + +	if ((fd = open(argv[1], O_RDONLY)) < 0) { +		fprintf(stderr, "test failed: failed to open root %s: %s\n", +		    argv[1], strerror(errno)); +		return (1); +	} + +	if (fstatvfs(fd, &vfs) != 0) { +		fprintf(stderr, "test failed: failed to stat vfs for %s: %s\n", +		    argv[1], strerror(errno)); +		return (1); +	} + +	if (strncmp("tmpfs", vfs.f_basetype, FSTYPSZ) != 0) { +		fprintf(stderr, "test failed: asked to run on non-tmpfs\n"); +		return (1); +	} + +	/* +	 * Once a few additional bugs in tmpfs are fixed, we should double check +	 * and make sure that the free space here is actually zero before +	 * continuing. +	 */ + +	/* +	 * Go through operations that would create nodes and make sure that they +	 * all fail. +	 */ + +	ret = openat(fd, "Mnemosyne", O_RDWR | O_CREAT, 0755); +	VERIFY3S(ret, ==, -1); +	VERIFY3S(errno, ==, ENOSPC); + +	ret = mkdirat(fd, "Euterpe", 0775); +	VERIFY3S(ret, ==, -1); +	VERIFY3S(errno, ==, ENOSPC); + +	ret = symlinkat("/dev/null", fd, "Melpomene"); +	VERIFY3S(ret, ==, -1); +	VERIFY3S(errno, ==, ENOSPC); + +	ret = linkat(fd, argv[2], fd, "Urania", 0); +	VERIFY3S(ret, ==, -1); +	VERIFY3S(errno, ==, ENOSPC); + +	/* +	 * Make sure we can't create open extended attributes. +	 */ +	ret = openat(fd, "Lethe", O_RDWR | O_CREAT | O_XATTR); +	VERIFY3S(ret, ==, -1); +	VERIFY3S(errno, ==, ENOSPC); + +	return (0); +} | 
