#include <sys/signal.h>
#include <sys/sysinfo.h>
#include <sys/resource.h>
+#include <sys/utsname.h>
#include <linux/ptrace.h>
#if defined(CONFIG_BOX_KERNEL_AMD64) && !defined(CONFIG_BOX_USER_AMD64)
die("ptrace(PTRACE_SETREGS): %m");
}
+static void
+sanity_check(void)
+{
+}
+
#else
static void
die("ptrace(PTRACE_SETREGS): %m");
}
+static void
+sanity_check(void)
+{
+#if !defined(CONFIG_BOX_ALLOW_INSECURE)
+ struct utsname uts;
+ if (uname(&uts) < 0)
+ die("uname() failed: %m");
+
+ if (!strcmp(uts.machine, "x86_64"))
+ die("Running 32-bit sandbox on 64-bit kernels is inherently unsafe. Please get a 64-bit version.");
+#endif
+}
+
#endif
/*** Syscall checks ***/
if (optind >= argc)
usage();
+ sanity_check();
uid = geteuid();
if (setreuid(uid, uid) < 0)
die("setreuid: %m");