CVS commit: src/lib/librumphijack

2019-09-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Sep 16 00:00:57 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Stop passing -D_INCOMPLETE_XOPEN_C063 (obsolete define)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2019-09-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Sep 16 00:00:57 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Stop passing -D_INCOMPLETE_XOPEN_C063 (obsolete define)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.21 src/lib/librumphijack/Makefile:1.22
--- src/lib/librumphijack/Makefile:1.21	Sun Feb 17 23:33:20 2019
+++ src/lib/librumphijack/Makefile	Mon Sep 16 00:00:56 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.21 2019/02/17 23:33:20 bad Exp $
+#	$NetBSD: Makefile,v 1.22 2019/09/16 00:00:56 kamil Exp $
 #
 
 LIB=		rumphijack
@@ -11,7 +11,6 @@ MAN=		rumphijack.3
 SRCS=		hijack.c hijackdlsym.c
 
 CPPFLAGS+=	-D_DIAGNOSTIC -D_REENTRANT
-CPPFLAGS.hijack.c+= -D_INCOMPLETE_XOPEN_C063
 
 WARNS?=		5
 



CVS commit: src/lib/librumphijack

2019-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 25 20:19:59 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
teach hijack about the new vfs syscalls


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.127 src/lib/librumphijack/hijack.c:1.128
--- src/lib/librumphijack/hijack.c:1.127	Sun Feb 17 18:35:50 2019
+++ src/lib/librumphijack/hijack.c	Wed Sep 25 16:19:59 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $	*/
+/*  $NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $");
 #endif
 
 #include 
@@ -216,7 +216,17 @@ enum dualcall {
 #define REALMOUNT __mount50
 #define REALGETFH __getfh30
 #define REALFHOPEN __fhopen40
+#if !__NetBSD_Prereq__(9,99,13)
+#define REALSTATVFS1 statvfs1
+#define REALFSTATVFS1 fstatvfs1
+#define REALGETVFSSTAT getvfsstat
 #define REALFHSTATVFS1 __fhstatvfs140
+#else
+#define REALSTATVFS1 __statvfs190
+#define REALFSTATVFS1 __fstatvfs190
+#define REALGETVFSSTAT __getvfsstat90
+#define REALFHSTATVFS1 __fhstatvfs190
+#endif
 #define REALSOCKET __socket30
 
 #define LSEEK_ALIAS _lseek
@@ -264,7 +274,10 @@ int REALMOUNT(const char *, const char *
 int REALGETFH(const char *, void *, size_t *);
 int REALFHOPEN(const void *, size_t, int);
 int REALFHSTAT(const void *, size_t, struct stat *);
+int REALSTATVFS1(const char *, struct statvfs *, int);
+int REALFSTATVFS1(int, struct statvfs *, int);
 int REALFHSTATVFS1(const void *, size_t, struct statvfs *, int);
+int REALGETVFSSTAT(struct statvfs *, size_t, int);
 int REALSOCKET(int, int, int);
 
 #define S(a) __STRING(a)
@@ -365,9 +378,9 @@ struct sysnames {
 #endif
 
 #ifdef __NetBSD__
-	{ DUALCALL_STATVFS1,	"statvfs1",	RSYS_NAME(STATVFS1)	},
-	{ DUALCALL_FSTATVFS1,	"fstatvfs1",	RSYS_NAME(FSTATVFS1)	},
-	{ DUALCALL_GETVFSSTAT,	"getvfsstat",	RSYS_NAME(GETVFSSTAT)	},
+	{ DUALCALL_STATVFS1,	S(REALSTATVFS1),RSYS_NAME(STATVFS1)	},
+	{ DUALCALL_FSTATVFS1,	S(REALFSTATVFS1),RSYS_NAME(FSTATVFS1)	},
+	{ DUALCALL_GETVFSSTAT,	S(REALGETVFSSTAT),RSYS_NAME(GETVFSSTAT)	},
 #endif
 
 #ifdef __NetBSD__
@@ -2497,7 +2510,7 @@ FDCALL(int, REALFSTAT, DUALCALL_FSTAT,		
 #endif
 
 #ifdef __NetBSD__
-FDCALL(int, fstatvfs1, DUALCALL_FSTATVFS1,\
+FDCALL(int, REALFSTATVFS1, DUALCALL_FSTATVFS1,\
 	(int fd, struct statvfs *buf, int flags),			\
 	(int, struct statvfs *, int),	\
 	(fd, buf, flags))
@@ -2599,7 +2612,7 @@ PATHCALL(int, lchmod, DUALCALL_LCHMOD,		
 	(path, mode))
 
 #ifdef __NetBSD__
-PATHCALL(int, statvfs1, DUALCALL_STATVFS1,\
+PATHCALL(int, REALSTATVFS1, DUALCALL_STATVFS1,\
 	(const char *path, struct statvfs *buf, int flags),		\
 	(const char *, struct statvfs *, int),\
 	(path, buf, flags))
@@ -2728,7 +2741,7 @@ PATHCALL(int, REALGETFH, DUALCALL_GETFH,
  */
 
 #ifdef __NetBSD__
-VFSCALL(VFSBIT_GETVFSSTAT, int, getvfsstat, DUALCALL_GETVFSSTAT,	\
+VFSCALL(VFSBIT_GETVFSSTAT, int, REALGETVFSSTAT, DUALCALL_GETVFSSTAT,	\
 	(struct statvfs *buf, size_t buflen, int flags),		\
 	(struct statvfs *, size_t, int),\
 	(buf, buflen, flags))



CVS commit: src/lib/librumphijack

2019-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 25 20:19:59 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
teach hijack about the new vfs syscalls


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 20:33:38 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
- implement pselect so that the ssh test has a chance to work
- 1 -> EXIT_FAILURE
- more info about fds


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 20:33:38 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
- implement pselect so that the ssh test has a chance to work
- 1 -> EXIT_FAILURE
- more info about fds


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.131 src/lib/librumphijack/hijack.c:1.132
--- src/lib/librumphijack/hijack.c:1.131	Wed May 27 14:55:36 2020
+++ src/lib/librumphijack/hijack.c	Fri Sep 10 16:33:38 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $");
 #endif
 
 #include 
@@ -187,6 +187,7 @@ enum dualcall {
 #if defined(__NetBSD__)
 
 #if !__NetBSD_Prereq__(5,99,7)
+#define REALSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS pollts
 #define REALKEVENT kevent
@@ -199,6 +200,7 @@ enum dualcall {
 #define REALMKNOD mknod
 #define REALFHSTAT __fhstat40
 #else /* >= 5.99.7 */
+#define REALPSELECT _sys___pselect50
 #define REALSELECT _sys___select50
 #define REALPOLLTS _sys___pollts50
 #define REALKEVENT _sys___kevent50
@@ -248,6 +250,7 @@ int __getcwd(char *, size_t);
 #define REALREAD read
 #define REALPREAD pread
 #define REALPWRITE pwrite
+#define REALPSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS ppoll
 #define REALUTIMES utimes
@@ -262,6 +265,8 @@ int __getcwd(char *, size_t);
 
 #endif /* platform */
 
+int REALPSELECT(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
+		const sigset_t *);
 int REALSELECT(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 int REALPOLLTS(struct pollfd *, nfds_t,
 	   const struct timespec *, const sigset_t *);
@@ -482,7 +487,7 @@ setdup2(int hostfd, int rumpfd)
 {
 
 	if (hostfd > DUP2HIGH) {
-		_DIAGASSERT(0);
+		_DIAGASSERT(/*CONSTCOND*/0);
 		return;
 	}
 
@@ -494,7 +499,7 @@ clrdup2(int hostfd)
 {
 
 	if (hostfd > DUP2HIGH) {
-		_DIAGASSERT(0);
+		_DIAGASSERT(/*CONSTCOND*/0);
 		return;
 	}
 
@@ -696,7 +701,7 @@ sockparser(char *buf)
 			}
 		}
 		if (socketmap[i].name == NULL) {
-			errx(1, "invalid socket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid socket specifier %s", p);
 		}
 	}
 }
@@ -707,16 +712,17 @@ pathparser(char *buf)
 
 	/* sanity-check */
 	if (*buf != '/')
-		errx(1, "hijack path specifier must begin with ``/''");
+		errx(EXIT_FAILURE,
+		"hijack path specifier must begin with ``/''");
 	rumpprefixlen = strlen(buf);
 	if (rumpprefixlen < 2)
-		errx(1, "invalid hijack prefix: %s", buf);
+		errx(EXIT_FAILURE, "invalid hijack prefix: %s", buf);
 	if (buf[rumpprefixlen-1] == '/' && strspn(buf, "/") != rumpprefixlen)
-		errx(1, "hijack prefix may end in slash only if pure "
-		"slash, gave %s", buf);
+		errx(EXIT_FAILURE, "hijack prefix may end in slash only if "
+		"pure slash, gave %s", buf);
 
 	if ((rumpprefix = strdup(buf)) == NULL)
-		err(1, "strdup");
+		err(EXIT_FAILURE, "strdup");
 	rumpprefixlen = strlen(rumpprefix);
 }
 
@@ -737,19 +743,19 @@ blanketparser(char *buf)
 
 	blanket = malloc(nblanket * sizeof(*blanket));
 	if (blanket == NULL)
-		err(1, "alloc blanket %d", nblanket);
+		err(EXIT_FAILURE, "alloc blanket %d", nblanket);
 
 	for (p = strtok_r(buf, ":", &l), i = 0; p;
 	p = strtok_r(NULL, ":", &l), i++) {
 		blanket[i].pfx = strdup(p);
 		if (blanket[i].pfx == NULL)
-			err(1, "strdup blanket");
+			err(EXIT_FAILURE, "strdup blanket");
 		blanket[i].len = strlen(p);
 
 		if (blanket[i].len == 0 || *blanket[i].pfx != '/')
-			errx(1, "invalid blanket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid blanket specifier %s", p);
 		if (*(blanket[i].pfx + blanket[i].len-1) == '/')
-			errx(1, "invalid blanket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid blanket specifier %s", p);
 	}
 }
 
@@ -780,7 +786,8 @@ vfsparser(char *buf)
 	fullmask = 0;
 	for (i = 0; vfscalls[i].name != NULL; i++) {
 		if (fullmask & vfscalls[i].bit)
-			errx(1, "problem exists between vi and chair");
+			errx(EXIT_FAILURE,
+			"problem exists between vi and chair");
 		fullmask |= vfscalls[i].bit;
 	}
 
@@ -810,7 +817,7 @@ vfsparser(char *buf)
 			}
 		}
 		if (vfscalls[i].name == NULL) {
-			errx(1, "invalid vfscall specifier %s", p);
+			errx(EXIT_FAILURE, "invalid vfscall specifier %s", p);
 		}
 	}
 }
@@ -836,7 +843,7 @@ sysctlparser(char *buf)
 		return;
 	}
 
-	errx(1, "sysctl value should be y(es)/n(o), gave: %s", buf);
+	errx(EXIT_FAILURE, "sysctl value should be y(es)/n(o), gave: %s"

CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 21:22:05 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore closefrom(3) for now; too complicated to descern between regular
and rump fds.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 21:22:05 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore closefrom(3) for now; too complicated to descern between regular
and rump fds.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.132 src/lib/librumphijack/hijack.c:1.133
--- src/lib/librumphijack/hijack.c:1.132	Fri Sep 10 16:33:38 2021
+++ src/lib/librumphijack/hijack.c	Fri Sep 10 17:22:05 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $");
 #endif
 
 #include 
@@ -2854,3 +2854,8 @@ nfssvc(int flags, void *argstructp)
 	return op_nfssvc(flags, argstructp);
 }
 #endif /* __NetBSD__ */
+
+int
+closefrom(int fd) {
+	return 0;
+}



CVS commit: src/lib/librumphijack

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 08:32:11 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: fix typo for NetBSD < 5.99.7


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 08:32:11 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: fix typo for NetBSD < 5.99.7


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.133 src/lib/librumphijack/hijack.c:1.134
--- src/lib/librumphijack/hijack.c:1.133	Fri Sep 10 21:22:05 2021
+++ src/lib/librumphijack/hijack.c	Sat Sep 11 08:32:11 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $");
 #endif
 
 #include 
@@ -187,7 +187,7 @@ enum dualcall {
 #if defined(__NetBSD__)
 
 #if !__NetBSD_Prereq__(5,99,7)
-#define REALSELECT pselect
+#define REALPSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS pollts
 #define REALKEVENT kevent



CVS commit: src/lib/librumphijack

2021-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 11 14:22:12 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove fake closefrom()


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 11 14:22:12 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove fake closefrom()


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.134 src/lib/librumphijack/hijack.c:1.135
--- src/lib/librumphijack/hijack.c:1.134	Sat Sep 11 04:32:11 2021
+++ src/lib/librumphijack/hijack.c	Sat Sep 11 10:22:12 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $	*/
+/*  $NetBSD: hijack.c,v 1.135 2021/09/11 14:22:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.135 2021/09/11 14:22:12 christos Exp $");
 #endif
 
 #include 
@@ -2854,8 +2854,3 @@ nfssvc(int flags, void *argstructp)
 	return op_nfssvc(flags, argstructp);
 }
 #endif /* __NetBSD__ */
-
-int
-closefrom(int fd) {
-	return 0;
-}



CVS commit: src/lib/librumphijack

2024-08-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Aug 16 04:23:31 UTC 2024

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: support flock

The original author is k-goda@IIJ.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2024-08-15 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Fri Aug 16 04:23:31 UTC 2024

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: support flock

The original author is k-goda@IIJ.


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.139 src/lib/librumphijack/hijack.c:1.140
--- src/lib/librumphijack/hijack.c:1.139	Tue Aug  1 07:04:15 2023
+++ src/lib/librumphijack/hijack.c	Fri Aug 16 04:23:31 2024
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.139 2023/08/01 07:04:15 mrg Exp $	*/
+/*  $NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.139 2023/08/01 07:04:15 mrg Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.140 2024/08/16 04:23:31 ozaki-r Exp $");
 #endif
 
 #include 
@@ -88,7 +88,7 @@ __RCSID("$NetBSD: hijack.c,v 1.139 2023/
  */
 enum dualcall {
 	DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
-	DUALCALL_IOCTL, DUALCALL_FCNTL,
+	DUALCALL_IOCTL, DUALCALL_FCNTL, DUALCALL_FLOCK,
 	DUALCALL_SOCKET, DUALCALL_ACCEPT,
 #ifndef __linux__
 	DUALCALL_PACCEPT,
@@ -327,6 +327,7 @@ struct sysnames {
 	{ DUALCALL_PWRITEV,	"pwritev",	RSYS_NAME(PWRITEV)	},
 	{ DUALCALL_IOCTL,	"ioctl",	RSYS_NAME(IOCTL)	},
 	{ DUALCALL_FCNTL,	"fcntl",	RSYS_NAME(FCNTL)	},
+	{ DUALCALL_FLOCK,	"flock",	RSYS_NAME(FLOCK)	},
 	{ DUALCALL_DUP2,	"dup2",		RSYS_NAME(DUP2)		},
 	{ DUALCALL_CLOSE,	"close",	RSYS_NAME(CLOSE)	},
 	{ DUALCALL_POLLTS,	S(REALPOLLTS),	RSYS_NAME(POLLTS)	},
@@ -1632,6 +1633,23 @@ fcntl(int fd, int cmd, ...)
 }
 
 int
+flock(int fd, int operation)
+{
+	int (*op_flock)(int, int);
+
+	DPRINTF(("flock -> %d (operation %d)\n", fd, operation));
+
+	if (fd_isrump(fd)) {
+		fd = fd_host2rump(fd);
+		op_flock = GETSYSCALL(rump, FLOCK);
+	} else {
+		op_flock = GETSYSCALL(host, FLOCK);
+	}
+
+	return op_flock(fd, operation);
+}
+
+int
 close(int fd)
 {
 	int (*op_close)(int);



Re: CVS commit: src/lib/librumphijack

2011-01-27 Thread Antti Kantee
On Wed Jan 26 2011 at 13:48:32 -0500, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Wed Jan 26 18:48:32 UTC 2011
> 
> Modified Files:
>   src/lib/librumphijack: hijack.c
> 
> Log Message:
> make SSP friendly

Can you add a comment stating why readlink and getcwd are special cases?

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-01-27 Thread Christos Zoulas
In article <20110127140249.gd23...@cs.hut.fi>,
Antti Kantee   wrote:
>On Wed Jan 26 2011 at 13:48:32 -0500, Christos Zoulas wrote:
>> Module Name: src
>> Committed By:christos
>> Date:Wed Jan 26 18:48:32 UTC 2011
>> 
>> Modified Files:
>>  src/lib/librumphijack: hijack.c
>> 
>> Log Message:
>> make SSP friendly
>
>Can you add a comment stating why readlink and getcwd are special cases?

Just because as it happens they are the other 2 system calls that have
been ssp'fied. We could add more. I thought about providing a mechanism
to say which ones should have default implementations and which ones should
be defined. I don't know how to make a weak inline though that is not
visible :-)

christos



Re: CVS commit: src/lib/librumphijack

2011-02-07 Thread Antti Kantee
On Mon Feb 07 2011 at 11:51:02 +, Antti Kantee wrote:
> Module Name:  src
> Committed By: pooka
> Date: Mon Feb  7 11:51:02 UTC 2011
> 
> Modified Files:
>   src/lib/librumphijack: hijack.c
> 
> Log Message:
> Unbreak the ssp lossage from the default -current build by removing
> it.  I still don't have any idea what the ssp stuff is supposed to
> do and how it's supposed to even begin to work.  If someone wants
> to change this now, run tests/lib/librumphijack before commit so
> that I can avoid another multihour debugging session!

In my debugging frenzy I thought that was the ssp stuff caused the
problem, but in fact it didn't (it doesn't compile, so it cannot cause
runtime problems).

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-07 Thread Christos Zoulas
In article <20110207124333.gg15...@cs.hut.fi>,
Antti Kantee   wrote:
>On Mon Feb 07 2011 at 11:51:02 +, Antti Kantee wrote:
>> Module Name: src
>> Committed By:pooka
>> Date:Mon Feb  7 11:51:02 UTC 2011
>> 
>> Modified Files:
>>  src/lib/librumphijack: hijack.c
>> 
>> Log Message:
>> Unbreak the ssp lossage from the default -current build by removing
>> it.  I still don't have any idea what the ssp stuff is supposed to
>> do and how it's supposed to even begin to work.  If someone wants
>> to change this now, run tests/lib/librumphijack before commit so
>> that I can avoid another multihour debugging session!
>
>In my debugging frenzy I thought that was the ssp stuff caused the
>problem, but in fact it didn't (it doesn't compile, so it cannot cause
>runtime problems).

It used to compile and it seemed fine. Does it still?

christos



Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 05:15:39 +, Christos Zoulas wrote:
> In article <20110207124333.gg15...@cs.hut.fi>,
> Antti Kantee   wrote:
> >On Mon Feb 07 2011 at 11:51:02 +, Antti Kantee wrote:
> >> Module Name:   src
> >> Committed By:  pooka
> >> Date:  Mon Feb  7 11:51:02 UTC 2011
> >> 
> >> Modified Files:
> >>src/lib/librumphijack: hijack.c
> >> 
> >> Log Message:
> >> Unbreak the ssp lossage from the default -current build by removing
> >> it.  I still don't have any idea what the ssp stuff is supposed to
> >> do and how it's supposed to even begin to work.  If someone wants
> >> to change this now, run tests/lib/librumphijack before commit so
> >> that I can avoid another multihour debugging session!
> >
> >In my debugging frenzy I thought that was the ssp stuff caused the
> >problem, but in fact it didn't (it doesn't compile, so it cannot cause
> >runtime problems).
> 
> It used to compile and it seemed fine. Does it still?

I never understood what the ssp code was supposed to do and still don't.

If read is changed to _hijack_read() 3rd party callers will not resolved
here, and therefore the hijack lib does not do the one thing it is
expected to do.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Christos Zoulas
On Feb 8,  5:01pm, po...@cs.hut.fi (Antti Kantee) wrote:
-- Subject: Re: CVS commit: src/lib/librumphijack

| On Tue Feb 08 2011 at 05:15:39 +, Christos Zoulas wrote:
| > In article <20110207124333.gg15...@cs.hut.fi>,
| > Antti Kantee   wrote:
| > >On Mon Feb 07 2011 at 11:51:02 +, Antti Kantee wrote:
| > >> Module Name: src
| > >> Committed By:pooka
| > >> Date:Mon Feb  7 11:51:02 UTC 2011
| > >> 
| > >> Modified Files:
| > >>  src/lib/librumphijack: hijack.c
| > >> 
| > >> Log Message:
| > >> Unbreak the ssp lossage from the default -current build by removing
| > >> it.  I still don't have any idea what the ssp stuff is supposed to
| > >> do and how it's supposed to even begin to work.  If someone wants
| > >> to change this now, run tests/lib/librumphijack before commit so
| > >> that I can avoid another multihour debugging session!
| > >
| > >In my debugging frenzy I thought that was the ssp stuff caused the
| > >problem, but in fact it didn't (it doesn't compile, so it cannot cause
| > >runtime problems).
| > 
| > It used to compile and it seemed fine. Does it still?
| 
| I never understood what the ssp code was supposed to do and still don't.
| 
| If read is changed to _hijack_read() 3rd party callers will not resolved
| here, and therefore the hijack lib does not do the one thing it is
| expected to do.

So the way it works, is that the ssp code hijacks read, via the inline
call in  (the macro expansion), and that inline call,
expands to buffer checking plus calling the original function you've defined
in libc _sys_read(), in your case _hijack_read().

so:


__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \
(__fd, __buf, __len));



rtype __ssp_weak_name(fun) args; \
__ssp_inline rtype fun args; \ 
__ssp_inline rtype fun args { \
__ssp_check(__buf, __len, bos); \
return __ssp_weak_name(fun) call; \
}

by you defining __ssp_weak_name -> _hijack_read(), you end up expanding
in 

ssize_t _hijack_read(int __fd, void *__buf, size_t __len);

inline ssize_t read(int __fd, void *__buf, size_t __len);
inline ssize_t read(int __fd, void *__buf, size_t __len) {
__ssp_check(__buf, __len, bos);
return _hijack_read(__fd, __buf, __len);
}

In your c code then in hijack.c you need to define the body of _hijack_read.
You also end up needing to define the bodies of readlink and getcwd, but
that is easily done...

I hope that helps. The trick to understand here is that you can only do
the ssp check in the inline function, because if you move the check in
the source file, you've lost the information from the caller about the
passed object.

Please let me know if you have any more questions.

christos


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 15:03:11 -0500, Christos Zoulas wrote:
> [explanation]
> 
> In your c code then in hijack.c you need to define the body of _hijack_read.
> You also end up needing to define the bodies of readlink and getcwd, but
> that is easily done...
> 
> I hope that helps. The trick to understand here is that you can only do
> the ssp check in the inline function, because if you move the check in
> the source file, you've lost the information from the caller about the
> passed object.
> 
> Please let me know if you have any more questions.

E2MAGIC ;)

Ok, so it was originally correct (or my code was broken on -current)
since hijack needs _sys_read or otherwise the #ifndef __ssp_weak_name
branch causes the 3rd party caller to have a reference to _sys_read
instead of read.  Sorry for bursting out, been working on too many
branches and this stuff is fairly hard to tune to work flawlessly ...
(I still need to solve compat ... *hrr*)

But, since the real caller already does the ssp check, why does it need
to be performed again in librumphijack where we, as you state above,
no longer have the necessary information.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Christos Zoulas
On Feb 8, 10:30pm, po...@cs.hut.fi (Antti Kantee) wrote:
-- Subject: Re: CVS commit: src/lib/librumphijack

| On Tue Feb 08 2011 at 15:03:11 -0500, Christos Zoulas wrote:
| > [explanation]
| > 
| > In your c code then in hijack.c you need to define the body of _hijack_read.
| > You also end up needing to define the bodies of readlink and getcwd, but
| > that is easily done...
| > 
| > I hope that helps. The trick to understand here is that you can only do
| > the ssp check in the inline function, because if you move the check in
| > the source file, you've lost the information from the caller about the
| > passed object.
| > 
| > Please let me know if you have any more questions.
| 
| E2MAGIC ;)
| 
| Ok, so it was originally correct (or my code was broken on -current)
| since hijack needs _sys_read or otherwise the #ifndef __ssp_weak_name
| branch causes the 3rd party caller to have a reference to _sys_read
| instead of read.  Sorry for bursting out, been working on too many
| branches and this stuff is fairly hard to tune to work flawlessly ...
| (I still need to solve compat ... *hrr*)

Yes, it is too complex. I understand. And I see the problem that callers
of the rump code calling _sys_read instead of hijack read.

| But, since the real caller already does the ssp check, why does it need
| to be performed again in librumphijack where we, as you state above,
| no longer have the necessary information.

It does not do the check in hijack.c (there was one revision that did,
but it has been corrected since). Still the problem remains, how do
we stack the calls to insert the ssp check at the top level, without
resorting to rtld tricks?

christos


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Joerg Sonnenberger
On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> Still the problem remains, how do we stack the calls to insert the ssp
> check at the top level, without resorting to rtld tricks?

Let me try to summarize the situation to make sure I get it right:

The fortification code wants to provide an inline function "read" that
calls the real "read" after doing the argument checks.

rumphijack wants to override the "read" symbol, apply some magic and
call "_sys_read" for the real system call.

To get the layering correct, we could make the fortification code define
another prototype and use double rename, e.g.

ssize_t __real_read(int __fd, ...) __RENAME(read);

__ssp_inline ssize_t read(int __fd, ...) __RENAME(__ssp_read);

__sso_inline ssize_t read(int __fd, ...) {
__ssp_check(__buf, __lean, bos);
return __real_read(__fd, ...);
}

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
> On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> > Still the problem remains, how do we stack the calls to insert the ssp
> > check at the top level, without resorting to rtld tricks?
> 
> Let me try to summarize the situation to make sure I get it right:
> 
> The fortification code wants to provide an inline function "read" that
> calls the real "read" after doing the argument checks.
> 
> rumphijack wants to override the "read" symbol, apply some magic and
> call "_sys_read" for the real system call.

No, it wants to override "whatever is the symbol applications are
resolved to".  For -current this is "_sys_read" (on nb5 it's "read").

And, on a tangent, it would really help if we had some mechanism for
"latest version of symbol exported by libc" (cf. mess with select,
pollts, kevent and socket).  For working compat, I guess we'd need to
bump rumphijack major every time one of them changes, but I can't think
of a good mechanism for an application to automatically select the major
that needs to be used.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 23:22:44 +0200, Antti Kantee wrote:
> On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
> > On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> > > Still the problem remains, how do we stack the calls to insert the ssp
> > > check at the top level, without resorting to rtld tricks?
> > 
> > Let me try to summarize the situation to make sure I get it right:
> > 
> > The fortification code wants to provide an inline function "read" that
> > calls the real "read" after doing the argument checks.
> > 
> > rumphijack wants to override the "read" symbol, apply some magic and
> > call "_sys_read" for the real system call.
> 
> No, it wants to override "whatever is the symbol applications are
> resolved to".  For -current this is "_sys_read" (on nb5 it's "read").

umph, for this case it's always _sys_read since read is just an alias
for _sys_read on all branches.  However, on -current application linkage
"skips" read() (apparently due to the ssp magic).

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Joerg Sonnenberger
On Tue, Feb 08, 2011 at 11:22:44PM +0200, Antti Kantee wrote:
> On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
> > On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> > > Still the problem remains, how do we stack the calls to insert the ssp
> > > check at the top level, without resorting to rtld tricks?
> > 
> > Let me try to summarize the situation to make sure I get it right:
> > 
> > The fortification code wants to provide an inline function "read" that
> > calls the real "read" after doing the argument checks.
> > 
> > rumphijack wants to override the "read" symbol, apply some magic and
> > call "_sys_read" for the real system call.
> 
> No, it wants to override "whatever is the symbol applications are
> resolved to".  For -current this is "_sys_read" (on nb5 it's "read").

That's not what the library is doing according to nm. It defines "read"
and not "_sys_read".

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 22:41:57 +0100, Joerg Sonnenberger wrote:
> On Tue, Feb 08, 2011 at 11:22:44PM +0200, Antti Kantee wrote:
> > On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
> > > On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> > > > Still the problem remains, how do we stack the calls to insert the ssp
> > > > check at the top level, without resorting to rtld tricks?
> > > 
> > > Let me try to summarize the situation to make sure I get it right:
> > > 
> > > The fortification code wants to provide an inline function "read" that
> > > calls the real "read" after doing the argument checks.
> > > 
> > > rumphijack wants to override the "read" symbol, apply some magic and
> > > call "_sys_read" for the real system call.
> > 
> > No, it wants to override "whatever is the symbol applications are
> > resolved to".  For -current this is "_sys_read" (on nb5 it's "read").
> 
> That's not what the library is doing according to nm. It defines "read"
> and not "_sys_read".

Are you sure you're looking at a current version?

pain-rustique:1:~> nm /usr/lib/librumphijack.so | grep read
29d4 T _sys_read
 U pthread_create
 U pthread_join
2a42 T readv

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Antti Kantee
On Tue Feb 08 2011 at 23:04:35 +0100, Joerg Sonnenberger wrote:
> > > > No, it wants to override "whatever is the symbol applications are
> > > > resolved to".  For -current this is "_sys_read" (on nb5 it's "read").
> > > 
> > > That's not what the library is doing according to nm. It defines "read"
> > > and not "_sys_read".
> > 
> > Are you sure you're looking at a current version?
> > 
> > pain-rustique:1:~> nm /usr/lib/librumphijack.so | grep read
> > 29d4 T _sys_read
> >  U pthread_create
> >  U pthread_join
> > 2a42 T readv
> 
> I have different builds arounds. So why is _sys_read special and readv,
> write, writev etc are not?

Like Christos wrote, only read/readlink/getcwd have been ssp'd.
So if you take e.g. httpd which tests/lib/librumphijack/t_tcpip
uses and run nm on it, you get:

 U _sys_read
 U write

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Joerg Sonnenberger
On Tue, Feb 08, 2011 at 11:43:40PM +0200, Antti Kantee wrote:
> On Tue Feb 08 2011 at 22:41:57 +0100, Joerg Sonnenberger wrote:
> > On Tue, Feb 08, 2011 at 11:22:44PM +0200, Antti Kantee wrote:
> > > On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
> > > > On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
> > > > > Still the problem remains, how do we stack the calls to insert the ssp
> > > > > check at the top level, without resorting to rtld tricks?
> > > > 
> > > > Let me try to summarize the situation to make sure I get it right:
> > > > 
> > > > The fortification code wants to provide an inline function "read" that
> > > > calls the real "read" after doing the argument checks.
> > > > 
> > > > rumphijack wants to override the "read" symbol, apply some magic and
> > > > call "_sys_read" for the real system call.
> > > 
> > > No, it wants to override "whatever is the symbol applications are
> > > resolved to".  For -current this is "_sys_read" (on nb5 it's "read").
> > 
> > That's not what the library is doing according to nm. It defines "read"
> > and not "_sys_read".
> 
> Are you sure you're looking at a current version?
> 
> pain-rustique:1:~> nm /usr/lib/librumphijack.so | grep read
> 29d4 T _sys_read
>  U pthread_create
>  U pthread_join
> 2a42 T readv

I have different builds arounds. So why is _sys_read special and readv,
write, writev etc are not?

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Christos Zoulas
In article <20110208210049.ga8...@britannica.bec.de>,
Joerg Sonnenberger   wrote:
>On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
>> Still the problem remains, how do we stack the calls to insert the ssp
>> check at the top level, without resorting to rtld tricks?
>
>Let me try to summarize the situation to make sure I get it right:
>
>The fortification code wants to provide an inline function "read" that
>calls the real "read" after doing the argument checks.
>
>rumphijack wants to override the "read" symbol, apply some magic and
>call "_sys_read" for the real system call.

Yes.

>To get the layering correct, we could make the fortification code define
>another prototype and use double rename, e.g.
>
>ssize_t __real_read(int __fd, ...) __RENAME(read);
>
>__ssp_inline ssize_t read(int __fd, ...) __RENAME(__ssp_read);
>
>__sso_inline ssize_t read(int __fd, ...) {
>   __ssp_check(__buf, __lean, bos);
>   return __real_read(__fd, ...);
>}

Yes, that would work. An extra level of indirection always works.

christos



Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Christos Zoulas
In article <20110208220435.ga10...@britannica.bec.de>,
Joerg Sonnenberger   wrote:
>On Tue, Feb 08, 2011 at 11:43:40PM +0200, Antti Kantee wrote:
>> On Tue Feb 08 2011 at 22:41:57 +0100, Joerg Sonnenberger wrote:
>> > On Tue, Feb 08, 2011 at 11:22:44PM +0200, Antti Kantee wrote:
>> > > On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
>> > > > On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
>> > > > > Still the problem remains, how do we stack the calls to insert the 
>> > > > > ssp
>> > > > > check at the top level, without resorting to rtld tricks?
>> > > > 
>> > > > Let me try to summarize the situation to make sure I get it right:
>> > > > 
>> > > > The fortification code wants to provide an inline function "read" that
>> > > > calls the real "read" after doing the argument checks.
>> > > > 
>> > > > rumphijack wants to override the "read" symbol, apply some magic and
>> > > > call "_sys_read" for the real system call.
>> > > 
>> > > No, it wants to override "whatever is the symbol applications are
>> > > resolved to".  For -current this is "_sys_read" (on nb5 it's "read").
>> > 
>> > That's not what the library is doing according to nm. It defines "read"
>> > and not "_sys_read".
>> 
>> Are you sure you're looking at a current version?
>> 
>> pain-rustique:1:~> nm /usr/lib/librumphijack.so | grep read
>> 29d4 T _sys_read
>>  U pthread_create
>>  U pthread_join
>> 2a42 T readv
>
>I have different builds arounds. So why is _sys_read special and readv,
>write, writev etc are not?

readv should be. We don't bother with writes, because they cannot trash
the stack (although we could and detect overflows).

christos



Re: CVS commit: src/lib/librumphijack

2011-02-08 Thread Christos Zoulas
In article <20110208212244.gk22...@cs.hut.fi>,
Antti Kantee   wrote:
>On Tue Feb 08 2011 at 22:00:49 +0100, Joerg Sonnenberger wrote:
>> On Tue, Feb 08, 2011 at 03:34:54PM -0500, Christos Zoulas wrote:
>> > Still the problem remains, how do we stack the calls to insert the ssp
>> > check at the top level, without resorting to rtld tricks?
>> 
>> Let me try to summarize the situation to make sure I get it right:
>> 
>> The fortification code wants to provide an inline function "read" that
>> calls the real "read" after doing the argument checks.
>> 
>> rumphijack wants to override the "read" symbol, apply some magic and
>> call "_sys_read" for the real system call.
>
>No, it wants to override "whatever is the symbol applications are
>resolved to".  For -current this is "_sys_read" (on nb5 it's "read").

for both is read. _sys_read is just an alias to read so it can be used
internally by libc and ssp.

>And, on a tangent, it would really help if we had some mechanism for
>"latest version of symbol exported by libc" (cf. mess with select,
>pollts, kevent and socket).  For working compat, I guess we'd need to
>bump rumphijack major every time one of them changes, but I can't think
>of a good mechanism for an application to automatically select the major
>that needs to be used.

That would be useful.

christos



Re: CVS commit: src/lib/librumphijack

2011-02-09 Thread Joerg Sonnenberger
On Wed, Feb 09, 2011 at 02:30:38AM +, Christos Zoulas wrote:
> >To get the layering correct, we could make the fortification code define
> >another prototype and use double rename, e.g.
> >
> >ssize_t __real_read(int __fd, ...) __RENAME(read);
> >
> >__ssp_inline ssize_t read(int __fd, ...) __RENAME(__ssp_read);
> >
> >__sso_inline ssize_t read(int __fd, ...) {
> > __ssp_check(__buf, __lean, bos);
> > return __real_read(__fd, ...);
> >}
> 
> Yes, that would work. An extra level of indirection always works.

It isn't really. It is just tricking the compiler into creating the
right external symbols. The result is that using SSP doesn't change
which symbols end up being called.

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-09 Thread Antti Kantee
On Wed Feb 09 2011 at 02:32:17 +, Christos Zoulas wrote:
> >And, on a tangent, it would really help if we had some mechanism for
> >"latest version of symbol exported by libc" (cf. mess with select,
> >pollts, kevent and socket).  For working compat, I guess we'd need to
> >bump rumphijack major every time one of them changes, but I can't think
> >of a good mechanism for an application to automatically select the major
> >that needs to be used.
> 
> That would be useful.

Oh, and one other related thing on my wishlist is having libc export
all syscall stubs in WEAKASM _sys style so that use-fd-to-select-kernel
can work on static linked binaries which cannot use RTLD_NEXT.  I guess
another option would be to compile local syscall stubs, but it seems
easier to have them popping out of libc.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-09 Thread Valeriy E. Ushakov
On Wed, Feb 09, 2011 at 14:06:08 +0200, Antti Kantee wrote:

> On Wed Feb 09 2011 at 02:32:17 +, Christos Zoulas wrote:
> > >And, on a tangent, it would really help if we had some mechanism for
> > >"latest version of symbol exported by libc" (cf. mess with select,
> > >pollts, kevent and socket).  For working compat, I guess we'd need to
> > >bump rumphijack major every time one of them changes, but I can't think
> > >of a good mechanism for an application to automatically select the major
> > >that needs to be used.
> > 
> > That would be useful.
> 
> Oh, and one other related thing on my wishlist is having libc export
> all syscall stubs in WEAKASM _sys style so that use-fd-to-select-kernel
> can work on static linked binaries which cannot use RTLD_NEXT.  I guess
> another option would be to compile local syscall stubs, but it seems
> easier to have them popping out of libc.

Is source-changes-d really the right place for this discussion?

-uwe


Re: CVS commit: src/lib/librumphijack

2011-02-19 Thread Antti Kantee
On Sat Feb 19 2011 at 14:58:45 +0100, Joerg Sonnenberger wrote:
> On Sat, Feb 19, 2011 at 01:10:36PM +, Antti Kantee wrote:
> > Module Name:src
> > Committed By:   pooka
> > Date:   Sat Feb 19 13:10:35 UTC 2011
> > 
> > Modified Files:
> > src/lib/librumphijack: hijack.c
> > 
> > Log Message:
> > hijack __getcwd()
> 
> Why?

to make it work

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-19 Thread Joerg Sonnenberger
On Sat, Feb 19, 2011 at 01:10:36PM +, Antti Kantee wrote:
> Module Name:  src
> Committed By: pooka
> Date: Sat Feb 19 13:10:35 UTC 2011
> 
> Modified Files:
>   src/lib/librumphijack: hijack.c
> 
> Log Message:
> hijack __getcwd()

Why?

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-19 Thread Joerg Sonnenberger
On Sat, Feb 19, 2011 at 07:54:25PM +0200, Antti Kantee wrote:
> On Sat Feb 19 2011 at 14:58:45 +0100, Joerg Sonnenberger wrote:
> > On Sat, Feb 19, 2011 at 01:10:36PM +, Antti Kantee wrote:
> > > Module Name:  src
> > > Committed By: pooka
> > > Date: Sat Feb 19 13:10:35 UTC 2011
> > > 
> > > Modified Files:
> > >   src/lib/librumphijack: hijack.c
> > > 
> > > Log Message:
> > > hijack __getcwd()
> > 
> > Why?
> 
> to make it work

To make *what* work. What is using __getcwd directly and not the
frontends. If this is yet another hack to deal with SSP, please apply
the patch I send to tech-userlevel and test with that first.

Joerg


Re: CVS commit: src/lib/librumphijack

2011-02-20 Thread Antti Kantee
On Sun Feb 20 2011 at 04:34:02 +0100, Joerg Sonnenberger wrote:
> On Sat, Feb 19, 2011 at 07:54:25PM +0200, Antti Kantee wrote:
> > On Sat Feb 19 2011 at 14:58:45 +0100, Joerg Sonnenberger wrote:
> > > On Sat, Feb 19, 2011 at 01:10:36PM +, Antti Kantee wrote:
> > > > Module Name:src
> > > > Committed By:   pooka
> > > > Date:   Sat Feb 19 13:10:35 UTC 2011
> > > > 
> > > > Modified Files:
> > > > src/lib/librumphijack: hijack.c
> > > > 
> > > > Log Message:
> > > > hijack __getcwd()
> > > 
> > > Why?
> > 
> > to make it work
> 
> To make *what* work. What is using __getcwd directly and not the
> frontends. If this is yet another hack to deal with SSP, please apply
> the patch I send to tech-userlevel and test with that first.

To make anything that uses the __getcwd() *system call* work, including,
but definitely not limited to the getcwd() *library function*, cf.

pain-rustique:1:~> wtf rumphijack
rumphijack (3) - System call hijack library
 ^^^

I have no idea about ssp, it's not enabled on my nb5.  As usual, I wrote
tests so I wouldn't have to waste time guessing if things work or if they
don't and so that others wouldn't have to waste their time guessing what
some code was originally meant to do.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-21 Thread YAMAMOTO Takashi
> Module Name:  src
> Committed By: pooka
> Date: Mon Feb  7 19:34:39 UTC 2011
> 
> Modified Files:
>   src/lib/librumphijack: hijack.c
> 
> Log Message:
> Force gcc to generate a stack frame for the call to dlsym(RTLD_NEXT).
> Without this hack at least amd64 -O2 just used jmp and The Wrong
> Thing happened.

do you want -fno-optimize-sibling-calls ?

YAMAMOTO Takashi

> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/lib/librumphijack/hijack.c
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


Re: CVS commit: src/lib/librumphijack

2011-02-22 Thread Antti Kantee
On Mon Feb 21 2011 at 23:19:47 +, YAMAMOTO Takashi wrote:
> > Module Name:src
> > Committed By:   pooka
> > Date:   Mon Feb  7 19:34:39 UTC 2011
> > 
> > Modified Files:
> > src/lib/librumphijack: hijack.c
> > 
> > Log Message:
> > Force gcc to generate a stack frame for the call to dlsym(RTLD_NEXT).
> > Without this hack at least amd64 -O2 just used jmp and The Wrong
> > Thing happened.
> 
> do you want -fno-optimize-sibling-calls ?

Without doing a test-compile, looks like it.  I guess I'll have to move
that function to its own source module, or is there a way to enable
it per-function?

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-22 Thread YAMAMOTO Takashi
> On Mon Feb 21 2011 at 23:19:47 +, YAMAMOTO Takashi wrote:
>> > Module Name:   src
>> > Committed By:  pooka
>> > Date:  Mon Feb  7 19:34:39 UTC 2011
>> > 
>> > Modified Files:
>> >src/lib/librumphijack: hijack.c
>> > 
>> > Log Message:
>> > Force gcc to generate a stack frame for the call to dlsym(RTLD_NEXT).
>> > Without this hack at least amd64 -O2 just used jmp and The Wrong
>> > Thing happened.
>> 
>> do you want -fno-optimize-sibling-calls ?
> 
> Without doing a test-compile, looks like it.  I guess I'll have to move
> that function to its own source module, or is there a way to enable
> it per-function?

i don't think there's a way for our version of gcc to make it per-function.
later versions have "optimize" function attribute.
the real fix here would be an attibute for dlsym, not for a caller of it, tho.

YAMAMOTO Takashi

> 
> -- 
> dld karot toivorikkauttas, kyl rdtei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-23 Thread Antti Kantee
On Wed Feb 23 2011 at 01:31:51 +, YAMAMOTO Takashi wrote:
> > On Mon Feb 21 2011 at 23:19:47 +, YAMAMOTO Takashi wrote:
> >> > Module Name: src
> >> > Committed By:pooka
> >> > Date:Mon Feb  7 19:34:39 UTC 2011
> >> > 
> >> > Modified Files:
> >> >  src/lib/librumphijack: hijack.c
> >> > 
> >> > Log Message:
> >> > Force gcc to generate a stack frame for the call to dlsym(RTLD_NEXT).
> >> > Without this hack at least amd64 -O2 just used jmp and The Wrong
> >> > Thing happened.
> >> 
> >> do you want -fno-optimize-sibling-calls ?
> > 
> > Without doing a test-compile, looks like it.  I guess I'll have to move
> > that function to its own source module, or is there a way to enable
> > it per-function?
> 
> i don't think there's a way for our version of gcc to make it per-function.
> later versions have "optimize" function attribute.
> the real fix here would be an attibute for dlsym, not for a caller of it, tho.

Proposing RTLD_NEXT-FROM-HANDLE was out of the scope of what I wanted to
tackle here.  If someone implements it, I'll be happy to use it, though ;)

Anyway, i'm guessing things work more certainly now that i committed
the -fno-sibling stuff.  And if they don't (e.g. with other compilers),
we have a test which lets us know.

thanks

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-02-26 Thread Valeriy E. Ushakov
On Fri, Feb 25, 2011 at 16:01:42 +, Antti Kantee wrote:

> Module Name:  src
> Committed By: pooka
> Date: Fri Feb 25 16:01:42 UTC 2011
> 
> Modified Files:
>   src/lib/librumphijack: Makefile hijackdlsym.c
> 
> Log Message:
> Ok, for reasons I can't begin to understand, the binaries I tested
> yesterday on powerpc broke overnight.  Apparently adding one more
> function before the call to dlsym() fixes things again.  I hope
> I don't have to add another one tomorrow 
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.7 -r1.8 src/lib/librumphijack/Makefile
> cvs rdiff -u -r1.1 -r1.2 src/lib/librumphijack/hijackdlsym.c

I think this is caused by revision 1.121 of rtld.c (hi, mac!) that
added "hackish_return_address" for ppc.

#ifdef __powerpc__
static void *
hackish_return_address(void)
{
return __builtin_return_address(1);
}
#endif

void *
dlsym(void *handle, const char *name)
{
...
#ifdef __powerpc__
retaddr = hackish_return_address();
#else
retaddr = __builtin_return_address(0);
#endif
...
}


hackish_return_address will be inlined (simple static function) and,
as far as I can tell, gcc does NOT adjust the "level" argument to
__builtin_return_address.

The net effect is that dlsym uses caller's caller address to detect
which module the call comes from, and if caller's caller is in a
different module wrong things happen.

That explains why you need an extra frame.

-uwe


Re: CVS commit: src/lib/librumphijack

2011-02-26 Thread Valeriy E. Ushakov
On Sun, Feb 27, 2011 at 08:12:37 +0300, Valeriy E. Ushakov wrote:

> On Fri, Feb 25, 2011 at 16:01:42 +, Antti Kantee wrote:
> 
> > Module Name:src
> > Committed By:   pooka
> > Date:   Fri Feb 25 16:01:42 UTC 2011
> > 
> > Modified Files:
> > src/lib/librumphijack: Makefile hijackdlsym.c
> > 
> > Log Message:
> > Ok, for reasons I can't begin to understand, the binaries I tested
> > yesterday on powerpc broke overnight.  Apparently adding one more
> > function before the call to dlsym() fixes things again.  I hope
> > I don't have to add another one tomorrow 
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.7 -r1.8 src/lib/librumphijack/Makefile
> > cvs rdiff -u -r1.1 -r1.2 src/lib/librumphijack/hijackdlsym.c
> 
> I think this is caused by revision 1.121 of rtld.c (hi, mac!) that
> added "hackish_return_address" for ppc.
> 
> #ifdef __powerpc__
> static void *
> hackish_return_address(void)
> {
> return __builtin_return_address(1);
> }
> #endif
> 
> void *
> dlsym(void *handle, const char *name)
> {
> ...
> #ifdef __powerpc__
> retaddr = hackish_return_address();
> #else
> retaddr = __builtin_return_address(0);
> #endif
> ...
> }
> 
> 
> hackish_return_address will be inlined (simple static function) and,
> as far as I can tell, gcc does NOT adjust the "level" argument to
> __builtin_return_address.
> 
> The net effect is that dlsym uses caller's caller address to detect
> which module the call comes from, and if caller's caller is in a
> different module wrong things happen.
> 
> That explains why you need an extra frame.

Actually, the real reason behind PR 37812 (that was supposed to be
fixed by the hackish_return_address) might be similar to the issue
with rumphijack_dlsym.

If I read xorg-server/dist/hw/xfree86/loader correctly, you probably
end up with dlsym being tail-called.  My knowledge of ppc asm/abi is
zero, so I can't really tell what goes on there or what went wrong in
the original scenario, but I'd guess your hackish return gets inlined
and with dlsym in tail-call position your caller's caller (unadjusted
level "1") is in the main program and then luck is on your side,
unless you do e.g. RTLD_NEXT.


PS:  this probably calls for some atf tests for dlsym &co.

-uwe


re: CVS commit: src/lib/librumphijack

2011-02-26 Thread matthew green

> > cvs rdiff -u -r1.7 -r1.8 src/lib/librumphijack/Makefile
> > cvs rdiff -u -r1.1 -r1.2 src/lib/librumphijack/hijackdlsym.c
> 
> I think this is caused by revision 1.121 of rtld.c (hi, mac!) that
> added "hackish_return_address" for ppc.
> 
> #ifdef __powerpc__
> static void *
> hackish_return_address(void)
> {
> return __builtin_return_address(1);
> }
> #endif
> 
> void *
> dlsym(void *handle, const char *name)
> {
> ...
> #ifdef __powerpc__
> retaddr = hackish_return_address();
> #else
> retaddr = __builtin_return_address(0);
> #endif
> ...
> }
> 
> 
> hackish_return_address will be inlined (simple static function) and,
> as far as I can tell, gcc does NOT adjust the "level" argument to
> __builtin_return_address.
> 
> The net effect is that dlsym uses caller's caller address to detect
> which module the call comes from, and if caller's caller is in a
> different module wrong things happen.
> 
> That explains why you need an extra frame.

ugh!

mac, what wasn't working that prompted you to do the above?
one hack to make it work would be to apply the noinline
gcc attribute


.mrg.


Re: CVS commit: src/lib/librumphijack

2011-02-27 Thread Antti Kantee
On Sun Feb 27 2011 at 08:12:37 +0300, Valeriy E. Ushakov wrote:
> On Fri, Feb 25, 2011 at 16:01:42 +, Antti Kantee wrote:
> 
> > Module Name:src
> > Committed By:   pooka
> > Date:   Fri Feb 25 16:01:42 UTC 2011
> > 
> > Modified Files:
> > src/lib/librumphijack: Makefile hijackdlsym.c
> > 
> > Log Message:
> > Ok, for reasons I can't begin to understand, the binaries I tested
> > yesterday on powerpc broke overnight.  Apparently adding one more
> > function before the call to dlsym() fixes things again.  I hope
> > I don't have to add another one tomorrow 
> > 
> > 
> > To generate a diff of this commit:
> > cvs rdiff -u -r1.7 -r1.8 src/lib/librumphijack/Makefile
> > cvs rdiff -u -r1.1 -r1.2 src/lib/librumphijack/hijackdlsym.c
> 
> I think this is caused by revision 1.121 of rtld.c (hi, mac!) that
> added "hackish_return_address" for ppc.
> 
> #ifdef __powerpc__
> static void *
> hackish_return_address(void)
> {
> return __builtin_return_address(1);
> }
> #endif
> 
> void *
> dlsym(void *handle, const char *name)
> {
> ...
> #ifdef __powerpc__
> retaddr = hackish_return_address();
> #else
> retaddr = __builtin_return_address(0);
> #endif
> ...
> }
> 
> 
> hackish_return_address will be inlined (simple static function) and,
> as far as I can tell, gcc does NOT adjust the "level" argument to
> __builtin_return_address.
> 
> The net effect is that dlsym uses caller's caller address to detect
> which module the call comes from, and if caller's caller is in a
> different module wrong things happen.
> 
> That explains why you need an extra frame.

What I really can't understand is that I have a very distinct impression
that things worked on Thursday (and screencaps to show it).  Then, after
riz installed a new userland, things were broken on Friday.  However,
I was using the same ld.elf_so binary I had compiled for debugging,
so it cannot be that the new toolchain inlined the call while the old
one didn't.

Anyway, apparently I don't have to put yet another callframe there,
since things are still working ;)

http://www.netbsd.org/~riz/macppc-atf/

Btw, if someone is looking for something interesting, look at the
posix_fadvise test.

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-03-09 Thread Christoph Egger

On 03/09/11 16:03, Antti Kantee wrote:

Module Name:src
Committed By:   pooka
Date:   Wed Mar  9 15:03:18 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Add a bunch of process-wide hijack calls.  Among other things, it's
now possible to use unmodified userspace binaries (rpcbind, mountd,
nfsd) to start a rump nfs service and mount file systems from it.

pain-rustique:42:~>  mount
rumpfs on / type rumpfs (local)
10.1.1.1:/export on /mnt type nfs


Cool. Is it possible to have anita booting NetBSD in qemu
with root on nfs?

Christoph


Re: CVS commit: src/lib/librumphijack

2011-03-10 Thread Valeriy E. Ushakov
On Thu, Mar 10, 2011 at 23:02:56 +, Antti Kantee wrote:

> Use rumphijack_dlsym() to figure out where __sysctl() is during
> init.  Otherwise powerpc dlsym() DTWT and returns NULL.
> (now i have no idea why dlsym() it works from rcinit(), but i'll
> opt to not care)

I don't remember if I brought this up here already, but I strongly
suspect suspect that libexec/ld.elf_so/rtld.c

revision 1.121
date: 2008/09/27 03:52:05;  author: macallan;  state: Exp;  lines: +15 -3
avoid usind __builtin_return_address(0) on PowerPC because it fails in
Xorg's module loader.
Should fix PR37812

broke it (hi, Mac!).  IIRC, it tries to work around dlsym in tail call
position (badness!) and "fixes" it only by chance, causing grief
elsewhere.

-uwe


Re: CVS commit: src/lib/librumphijack

2011-03-11 Thread Antti Kantee
On Fri Mar 11 2011 at 03:34:47 +0300, Valeriy E. Ushakov wrote:
> On Thu, Mar 10, 2011 at 23:02:56 +, Antti Kantee wrote:
> 
> > Use rumphijack_dlsym() to figure out where __sysctl() is during
> > init.  Otherwise powerpc dlsym() DTWT and returns NULL.
> > (now i have no idea why dlsym() it works from rcinit(), but i'll
> > opt to not care)
> 
> I don't remember if I brought this up here already, but I strongly
> suspect suspect that libexec/ld.elf_so/rtld.c
> 
> revision 1.121
> date: 2008/09/27 03:52:05;  author: macallan;  state: Exp;  lines: +15 -3
> avoid usind __builtin_return_address(0) on PowerPC because it fails in
> Xorg's module loader.
> Should fix PR37812
> 
> broke it (hi, Mac!).  IIRC, it tries to work around dlsym in tail call
> position (badness!) and "fixes" it only by chance, causing grief
> elsewhere.

If there only were a test, someone could try to fix things without
worrying about reintroducing the original problem again ...

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa