aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeebs <seebs@seebs.net>2018-03-31 16:20:04 -0500
committerSeebs <seebs@seebs.net>2018-03-31 16:20:04 -0500
commit19f18124f16c4c85405b140a1fb8cb3b31d865bf (patch)
treecb33ff14c35c1ea40a8d40e314fb94ad032f4ae5
parent4057859ec03ac04a31eb28d2275961f6019c8ae1 (diff)
downloadpseudo-19f18124f16c4c85405b140a1fb8cb3b31d865bf.tar.gz
pseudo-19f18124f16c4c85405b140a1fb8cb3b31d865bf.tar.bz2
pseudo-19f18124f16c4c85405b140a1fb8cb3b31d865bf.zip
initialize wrappers in syscall wrapper
But what if syscall(2) was the *first* function with a wrapper that you called? Also reduced amount of argument-copying in syscall(2), on further study, anything with off_t arguments has less than 6 arguments by enough to keep the total argument count down. Signed-off-by: Seebs <seebs@seebs.net>
-rw-r--r--ChangeLog.txt4
-rw-r--r--ports/linux/pseudo_wrappers.c17
2 files changed, 12 insertions, 9 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index f984820..41aeb9f 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -4,6 +4,10 @@
whether an error occurred, even if no call has returned
a status indicating an error, and this is completely wrong
but we can't fix them all.
+ * (seebs) check for wrapper initialization in syscall wrapper,
+ because what if it was the *first* call someone made. (Thanks
+ to Joshua Watt <jpewhacker@gmail.com> for diagnosing this
+ before I got a chance.)
2018-03-30:
* (seebs) fix path stuff more thoroughly.
diff --git a/ports/linux/pseudo_wrappers.c b/ports/linux/pseudo_wrappers.c
index 229b1d9..6a76632 100644
--- a/ports/linux/pseudo_wrappers.c
+++ b/ports/linux/pseudo_wrappers.c
@@ -52,14 +52,13 @@ int pseudo_capset(cap_user_header_t hdrp, const cap_user_data_t datap) {
long
syscall(long number, ...) {
- /* In a fit of optimism, I imagine that if we didn't get at least 7
- * arguments, reading past the ones we did get will read into this
- * space and maybe not clash with or overlap with any later-declared
- * values. This isn't really a guarantee, and is probably just
- * superstition.
- */
- unsigned long long padding[7];
- (void) padding;
+ long rc = -1;
+
+ if (!pseudo_check_wrappers() || !real_syscall) {
+ /* rc was initialized to the "failure" value */
+ pseudo_enosys("syscall");
+ return rc;
+ }
#ifdef SYS_renameat2
/* concerns exist about trying to parse arguments because syscall(2)
@@ -78,7 +77,7 @@ syscall(long number, ...) {
* guess about the number of args; the docs discuss calling conventions
* up to 7, so let's try that?
*/
- void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long long) * 7);
+ void *res = __builtin_apply((void (*)()) real_syscall, __builtin_apply_args(), sizeof(long) * 7);
__builtin_return(res);
}