Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src Pull up following revision(s) (requested by martin in tic...
details: https://anonhg.NetBSD.org/src/rev/46256a0a0d7a
branches: netbsd-6
changeset: 774134:46256a0a0d7a
user: riz <riz%NetBSD.org@localhost>
date: Sat May 19 15:34:32 2012 +0000
description:
Pull up following revision(s) (requested by martin in ticket #270):
sys/kern/sys_pipe.c: revision 1.136
tests/lib/libc/sys/t_pipe2.c: revision 1.4
tests/lib/libc/sys/t_pipe2.c: revision 1.5
tests/lib/libc/sys/t_pipe2.c: revision 1.6
tests/lib/libc/sys/t_pipe2.c: revision 1.7
Make sure we can deliver two file descriptors for pipe2() before we set
up anything special (like close on exec).
Fixes PR kern/46457.
Add a case for PR kern/46457. This is skipped for the time being, as it
reproduces the panic described in the PR.
Enable the test for PR kern/46457 now that it does not crash the
kernel any more.
Fix typo in comment.
Simplify the test for PR kern/4645 and make it independend of resource
settings.
diffstat:
sys/kern/sys_pipe.c | 18 ++++++++++--------
tests/lib/libc/sys/t_pipe2.c | 39 +++++++++++++++++++++++++++++++++++++--
2 files changed, 47 insertions(+), 10 deletions(-)
diffs (121 lines):
diff -r 99ae4a18a1a6 -r 46256a0a0d7a sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c Sat May 19 15:32:37 2012 +0000
+++ b/sys/kern/sys_pipe.c Sat May 19 15:34:32 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_pipe.c,v 1.135 2012/01/25 00:28:36 christos Exp $ */
+/* $NetBSD: sys_pipe.c,v 1.135.2.1 2012/05/19 15:34:32 riz Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.135 2012/01/25 00:28:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.135.2.1 2012/05/19 15:34:32 riz Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -267,21 +267,23 @@
if (error)
goto free2;
retval[0] = fd;
- rf->f_flag = FREAD | flags;
- rf->f_type = DTYPE_PIPE;
- rf->f_data = (void *)rpipe;
- rf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
error = fd_allocfile(&wf, &fd);
if (error)
goto free3;
retval[1] = fd;
+
+ rf->f_flag = FREAD | flags;
+ rf->f_type = DTYPE_PIPE;
+ rf->f_data = (void *)rpipe;
+ rf->f_ops = &pipeops;
+ fd_set_exclose(l, (int)retval[0], (flags & O_CLOEXEC) != 0);
+
wf->f_flag = FWRITE | flags;
wf->f_type = DTYPE_PIPE;
wf->f_data = (void *)wpipe;
wf->f_ops = &pipeops;
- fd_set_exclose(l, fd, (flags & O_CLOEXEC) != 0);
+ fd_set_exclose(l, (int)retval[1], (flags & O_CLOEXEC) != 0);
rpipe->pipe_peer = wpipe;
wpipe->pipe_peer = rpipe;
diff -r 99ae4a18a1a6 -r 46256a0a0d7a tests/lib/libc/sys/t_pipe2.c
--- a/tests/lib/libc/sys/t_pipe2.c Sat May 19 15:32:37 2012 +0000
+++ b/tests/lib/libc/sys/t_pipe2.c Sat May 19 15:34:32 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pipe2.c,v 1.3 2012/01/28 02:47:09 christos Exp $ */
+/* $NetBSD: t_pipe2.c,v 1.3.2.1 2012/05/19 15:34:32 riz Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -36,13 +36,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_pipe2.c,v 1.3 2012/01/28 02:47:09 christos Exp $");
+__RCSID("$NetBSD: t_pipe2.c,v 1.3.2.1 2012/05/19 15:34:32 riz Exp $");
#include <atf-c.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
+#include <sys/resource.h>
static void
run(int flags)
@@ -98,6 +99,39 @@
run(0);
}
+ATF_TC(pipe2_consume);
+ATF_TC_HEAD(pipe2_consume, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test that consuming file descriptors "
+ "with pipe2(2) does not crash the system (PR kern/46457)");
+}
+
+ATF_TC_BODY(pipe2_consume, tc)
+{
+ struct rlimit rl;
+ int err, filedes[2];
+
+ err = fcntl(4, F_CLOSEM);
+ ATF_REQUIRE(err == 0);
+
+ err = getrlimit(RLIMIT_NOFILE, &rl);
+ ATF_REQUIRE(err == 0);
+ /*
+ * The heart of this test is to run against the number of open
+ * file descriptor limit in the middle of a pipe2() call - i.e.
+ * before the call only a single descriptor may be openend.
+ */
+ rl.rlim_cur = 4;
+ err = setrlimit(RLIMIT_NOFILE, &rl);
+ ATF_REQUIRE(err == 0);
+
+ /*
+ * atf_tc_skip("The test case causes a panic (PR kern/46457)");
+ */
+ err = pipe2(filedes, O_CLOEXEC);
+ ATF_REQUIRE(err == -1);
+}
+
ATF_TC(pipe2_nonblock);
ATF_TC_HEAD(pipe2_nonblock, tc)
{
@@ -147,6 +181,7 @@
{
ATF_TP_ADD_TC(tp, pipe2_basic);
+ ATF_TP_ADD_TC(tp, pipe2_consume);
ATF_TP_ADD_TC(tp, pipe2_nonblock);
ATF_TP_ADD_TC(tp, pipe2_cloexec);
ATF_TP_ADD_TC(tp, pipe2_nosigpipe);
Home |
Main Index |
Thread Index |
Old Index