Fredrik Fornwall
9 years ago
6 changed files with 37 additions and 144 deletions
@ -1,15 +0,0 @@ |
|||
From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113 |
|||
|
|||
diff -u -r ../PRoot-5.1.0/src/arch.h ./src/arch.h
|
|||
--- ../PRoot-5.1.0/src/arch.h 2014-12-15 09:18:11.000000000 -0500
|
|||
+++ ./src/arch.h 2016-01-08 19:53:23.789378336 -0500
|
|||
@@ -125,6 +125,9 @@
|
|||
#define OFFSETOF_STAT_UID_32 0 |
|||
#define OFFSETOF_STAT_GID_32 0 |
|||
|
|||
+ #define EXEC_PIC_ADDRESS 0x500000000000
|
|||
+ #define INTERP_PIC_ADDRESS 0x6f0000000000
|
|||
+
|
|||
#elif defined(ARCH_X86) |
|||
|
|||
#define SYSNUMS_HEADER1 "syscall/sysnums-i386.h" |
@ -1,99 +0,0 @@ |
|||
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113 |
|||
|
|||
diff -N -u -r ../PRoot-5.1.0/src/loader/assemble-arm64.h ./src/loader/assemble-arm64.h
|
|||
--- ../PRoot-5.1.0/src/loader/assembly-arm64.h 1969-12-31 19:00:00.000000000 -0500
|
|||
+++ ./src/loader/assembly-arm64.h 2016-01-08 20:12:46.494779723 -0500
|
|||
@@ -0,0 +1,93 @@
|
|||
+/* -*- c-set-style: "K&R"; c-basic-offset: 8 -*-
|
|||
+ *
|
|||
+ * This file is part of PRoot.
|
|||
+ *
|
|||
+ * Copyright (C) 2014 STMicroelectronics
|
|||
+ *
|
|||
+ * This program is free software; you can redistribute it and/or
|
|||
+ * modify it under the terms of the GNU General Public License as
|
|||
+ * published by the Free Software Foundation; either version 2 of the
|
|||
+ * License, or (at your option) any later version.
|
|||
+ *
|
|||
+ * This program is distributed in the hope that it will be useful, but
|
|||
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|||
+ * General Public License for more details.
|
|||
+ *
|
|||
+ * You should have received a copy of the GNU General Public License
|
|||
+ * along with this program; if not, write to the Free Software
|
|||
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|||
+ * 02110-1301 USA.
|
|||
+ */
|
|||
+
|
|||
+#define BRANCH(stack_pointer, destination) do { \
|
|||
+ asm volatile ( \
|
|||
+ "// Restore initial stack pointer. \n\t" \
|
|||
+ "mov sp, %0 \n\t" \
|
|||
+ " \n\t" \
|
|||
+ "// Clear rtld_fini. \n\t" \
|
|||
+ "mov x0, #0 \n\t" \
|
|||
+ " \n\t" \
|
|||
+ "// Start the program. \n\t" \
|
|||
+ "br %1 \n" \
|
|||
+ : /* no output */ \
|
|||
+ : "r" (stack_pointer), "r" (destination) \
|
|||
+ : "memory", "sp", "x0"); \
|
|||
+ __builtin_unreachable(); \
|
|||
+ } while (0)
|
|||
+
|
|||
+#define PREPARE_ARGS_1(arg1_) \
|
|||
+ register word_t arg1 asm("x0") = arg1_; \
|
|||
+
|
|||
+#define PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
|
|||
+ PREPARE_ARGS_1(arg1_) \
|
|||
+ register word_t arg2 asm("x1") = arg2_; \
|
|||
+ register word_t arg3 asm("x2") = arg3_; \
|
|||
+
|
|||
+#define PREPARE_ARGS_4(arg1_, arg2_, arg3_, arg4_) \
|
|||
+ PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
|
|||
+ register word_t arg4 asm("x3") = arg4_;
|
|||
+
|
|||
+#define PREPARE_ARGS_6(arg1_, arg2_, arg3_, arg4_, arg5_, arg6_) \
|
|||
+ PREPARE_ARGS_3(arg1_, arg2_, arg3_) \
|
|||
+ register word_t arg4 asm("x3") = arg4_; \
|
|||
+ register word_t arg5 asm("x4") = arg5_; \
|
|||
+ register word_t arg6 asm("x5") = arg6_;
|
|||
+
|
|||
+#define OUTPUT_CONTRAINTS_1 \
|
|||
+ "r" (arg1)
|
|||
+
|
|||
+#define OUTPUT_CONTRAINTS_3 \
|
|||
+ OUTPUT_CONTRAINTS_1, \
|
|||
+ "r" (arg2), "r" (arg3)
|
|||
+
|
|||
+#define OUTPUT_CONTRAINTS_4 \
|
|||
+ OUTPUT_CONTRAINTS_3, \
|
|||
+ "r" (arg4)
|
|||
+
|
|||
+#define OUTPUT_CONTRAINTS_6 \
|
|||
+ OUTPUT_CONTRAINTS_3, \
|
|||
+ "r" (arg4), "r" (arg5), "r" (arg6)
|
|||
+
|
|||
+#define SYSCALL(number_, nb_args, args...) \
|
|||
+ ({ \
|
|||
+ register word_t number asm("w8") = number_; \
|
|||
+ register word_t result asm("x0"); \
|
|||
+ PREPARE_ARGS_##nb_args(args) \
|
|||
+ asm volatile ( \
|
|||
+ "svc #0x00000000 \n\t" \
|
|||
+ : "=r" (result) \
|
|||
+ : "r" (number), \
|
|||
+ OUTPUT_CONTRAINTS_##nb_args \
|
|||
+ : "memory"); \
|
|||
+ result; \
|
|||
+ })
|
|||
+
|
|||
+#define OPENAT 56
|
|||
+#define CLOSE 57
|
|||
+#define MMAP 222
|
|||
+#define MMAP_OFFSET_SHIFT 0
|
|||
+#define EXECVE 221
|
|||
+#define EXIT 93
|
|||
+#define PRCTL 167
|
|||
+
|
@ -1,26 +0,0 @@ |
|||
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=788113 |
|||
|
|||
diff -N -u -r ../PRoot-5.1.0/src/loader/loader.c ./src/loader/loader.c
|
|||
--- ../PRoot-5.1.0/src/loader/loader.c 2014-12-15 09:18:11.000000000 -0500
|
|||
+++ ./src/loader/loader.c 2016-01-08 20:16:54.746809929 -0500
|
|||
@@ -39,6 +39,8 @@
|
|||
# include "loader/assembly-x86_64.h" |
|||
#elif defined(ARCH_ARM_EABI) |
|||
# include "loader/assembly-arm.h" |
|||
+#elif defined(ARCH_ARM64)
|
|||
+# include "loader/assembly-arm64.h"
|
|||
#elif defined(ARCH_X86) |
|||
# include "loader/assembly-x86.h" |
|||
#else |
|||
@@ -134,7 +136,11 @@
|
|||
/* Fall through. */ |
|||
|
|||
case LOAD_ACTION_OPEN: |
|||
+#ifdef OPENAT
|
|||
+ fd = SYSCALL(OPENAT, 4, AT_FDCWD, stmt->open.string_address, O_RDONLY, 0);
|
|||
+#else
|
|||
fd = SYSCALL(OPEN, 3, stmt->open.string_address, O_RDONLY, 0); |
|||
+#endif
|
|||
if (unlikely((int) fd < 0)) |
|||
FATAL(); |
|||
|
@ -0,0 +1,32 @@ |
|||
On 32-bit prlimit() does not exist. prlimit64 however exists on both. |
|||
|
|||
diff -u -r ../PRoot-next/src/syscall/rlimit.c ./src/syscall/rlimit.c
|
|||
--- ../PRoot-next/src/syscall/rlimit.c 2015-07-23 15:50:10.000000000 -0400
|
|||
+++ ./src/syscall/rlimit.c 2016-03-21 20:29:49.544175830 -0400
|
|||
@@ -58,7 +58,7 @@
|
|||
*/ |
|||
int translate_setrlimit_exit(const Tracee *tracee, bool is_prlimit) |
|||
{ |
|||
- struct rlimit proot_stack;
|
|||
+ struct rlimit64 proot_stack;
|
|||
word_t resource; |
|||
word_t address; |
|||
word_t tracee_stack_limit; |
|||
@@ -94,7 +94,7 @@
|
|||
return -errno; |
|||
|
|||
/* Get current PRoot's stack limit. */ |
|||
- status = prlimit(0, RLIMIT_STACK, NULL, &proot_stack);
|
|||
+ status = prlimit64(0, RLIMIT_STACK, NULL, &proot_stack);
|
|||
if (status < 0) { |
|||
VERBOSE(tracee, 1, "can't get stack limit."); |
|||
return 0; /* Not fatal. */ |
|||
@@ -107,7 +107,7 @@
|
|||
proot_stack.rlim_cur = tracee_stack_limit; |
|||
|
|||
/* Increase current PRoot's stack limit. */ |
|||
- status = prlimit(0, RLIMIT_STACK, &proot_stack, NULL);
|
|||
+ status = prlimit64(0, RLIMIT_STACK, &proot_stack, NULL);
|
|||
if (status < 0) |
|||
VERBOSE(tracee, 1, "can't set stack limit."); |
|||
return 0; /* Not fatal. */ |
Loading…
Reference in new issue