From owner-svn-src-user@FreeBSD.ORG Sun Nov 24 09:15:22 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3DF2358C; Sun, 24 Nov 2013 09:15:22 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1F04C27CD; Sun, 24 Nov 2013 09:15:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAO9FLC0088591; Sun, 24 Nov 2013 09:15:21 GMT (envelope-from pho@svn.freebsd.org) Received: (from pho@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAO9FL1e088590; Sun, 24 Nov 2013 09:15:21 GMT (envelope-from pho@svn.freebsd.org) Message-Id: <201311240915.rAO9FL1e088590@svn.freebsd.org> From: Peter Holm Date: Sun, 24 Nov 2013 09:15:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r258510 - user/pho/stress2/misc X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Nov 2013 09:15:22 -0000 Author: pho Date: Sun Nov 24 09:15:21 2013 New Revision: 258510 URL: http://svnweb.freebsd.org/changeset/base/258510 Log: Cleaned up test scenario, run as user nobody and as a daemon like the test scenario syscall4.sh which this test is based on. Sponsored by: EMC / Isilon storage division Modified: user/pho/stress2/misc/pread.sh Modified: user/pho/stress2/misc/pread.sh ============================================================================== --- user/pho/stress2/misc/pread.sh Sun Nov 24 09:09:43 2013 (r258509) +++ user/pho/stress2/misc/pread.sh Sun Nov 24 09:15:21 2013 (r258510) @@ -53,12 +53,21 @@ echo "Testing tmpfs(5)" umount $mntpoint echo "Testing fdescfs(5)" -/tmp/pread /dev/fd +mount -t fdescfs null /dev/fd +for i in `jot 100`; do + /tmp/pread /dev/fd +done + +while mount | grep -q "on /dev/fd "; do + umount /dev/fd || sleep 1 +done echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/pread $mntpoint -umount $mntpoint +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 @@ -68,15 +77,30 @@ mount /dev/md${mdstart}$part $mntpoint cp -a /usr/include $mntpoint echo "Testing FFS" /tmp/pread $mntpoint -umount $mntpoint +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done mount -t nullfs /bin $mntpoint echo "Testing nullfs(5)" /tmp/pread $mntpoint -umount $mntpoint +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done + +echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/pread $mntpoint -umount $mntpoint +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done + +echo "Testing devfs(8)" +mount -t devfs devfs $mntpoint +/tmp/pread $mntpoint +while mount | grep -q "on $mntpoint "; do + umount $mntpoint || sleep 1 +done rm -f /tmp/pread exit 0 @@ -85,8 +109,10 @@ EOF #include #include #include +#include #include #include +#include #include #include #include @@ -111,7 +137,7 @@ test(char *path) signal(SIGSEGV, hand); signal(SIGABRT, hand); - ftsoptions = 0; + ftsoptions = FTS_PHYSICAL; args[0] = path; args[1] = 0; @@ -119,8 +145,11 @@ test(char *path) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { - if ((fd = open(p->fts_path, O_RDONLY)) == -1) - warn("open(%s)", p->fts_path); + if ((fd = open(p->fts_path, O_RDONLY)) == -1) { + if (errno != EACCES && errno != ENXIO) + warn("open(%s)", p->fts_path); + continue; + } alarm(1); pread(fd, (void *)0xdeadc0de, 0x7ffffff, 0xffffffff); pread(fd, buf, 0x7ffffff, 0xffffffff); @@ -137,6 +166,19 @@ int main(int argc __unused, char **argv) { int i; + struct passwd *pw; + + if ((pw = getpwnam("nobody")) == NULL) + err(1, "no such user: nobody"); + + if (setgroups(1, &pw->pw_gid) || + setegid(pw->pw_gid) || setgid(pw->pw_gid) || + seteuid(pw->pw_uid) || setuid(pw->pw_uid)) + err(1, "Can't drop privileges to \"nobody\""); + endpwent(); + + if (daemon(0, 0) == -1) + err(1, "daemon()"); for (i = 0; i < 10; i++) { if (fork() == 0)