Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/librumphijack Object to dup2() if target fd is in the ra...



details:   https://anonhg.NetBSD.org/src/rev/34fb2f4ac8dd
branches:  trunk
changeset: 347046:34fb2f4ac8dd
user:      kre <kre%NetBSD.org@localhost>
date:      Thu Aug 11 09:48:57 2016 +0000

description:
Object to dup2() if target fd is in the range of fd's that
librumphijack reserves for rump to use.

This is not normally a problem, as most applications don't attempt
to use very high fds - but /bin/sh does.

This fix is something of a kludge - really the apparent fd resource limit
ought to be lowered as well, but this is sufficient to allow the shell
to work (when its dup2() gets rejected, it just tries again with a smaller
target fd until it eventually succeeds.)   This fixes the librumphijack
shell ATF tests.

A better, more comprehensive, fix would be good...

diffstat:

 lib/librumphijack/hijack.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r db80e8f9e4d5 -r 34fb2f4ac8dd lib/librumphijack/hijack.c
--- a/lib/librumphijack/hijack.c        Thu Aug 11 09:06:49 2016 +0000
+++ b/lib/librumphijack/hijack.c        Thu Aug 11 09:48:57 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $      */
+/*      $NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $        */
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include <rump/rumpuser_port.h>
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1064,6 +1064,10 @@
                        minfd -= hijack_fdoff;
                isrump = 1;
        } else {
+               if (minfd >= hijack_fdoff) {
+                       errno = EINVAL;
+                       return -1;
+               }
                op_fcntl = GETSYSCALL(host, FCNTL);
                isrump = 0;
        }



Home | Main Index | Thread Index | Old Index