/* * Known security issues * * Userspace can jump to this address to execute *any* syscall that is * permitted by the stub. As we will return afterwards, it can do * whatever it likes, including: * - Tricking the kernel into handing out the memory FD * - Using this memory FD to read/write all physical memory * - Running in parallel to the kernel processing a syscall * (possibly creating data races?) * - Blocking e.g. SIGALRM to avoid time based scheduling * * To avoid this, the permitted location for each syscall needs to be * checked for in the SECCOMP filter (which is reasonably simple). Also, * more care will need to go into considerations how the code might be * tricked by using a prepared stack (or even modifying the stack from * another thread in case SMP support is added). * * As for the SIGALRM, the best counter measure will be to check in the * kernel that the process is reporting back the SIGALRM in a timely * fashion.
*/ static __always_inline int syscall_handler(int fd_map[STUB_MAX_FDS])
{ struct stub_data *d = get_stub_data(); int i; unsignedlong res; int fd;
for (i = 0; i < d->syscall_data_len; i++) { struct stub_syscall *sc = &d->syscall_data[i];
switch (sc->syscall) { case STUB_SYSCALL_MMAP: if (fd_map)
fd = fd_map[sc->mem.fd]; else
fd = sc->mem.fd;
/* Try running queued syscalls. */
res = syscall_handler(fd_map);
while (num_fds)
stub_syscall2(__NR_close, fd_map[--num_fds], 0);
} else {
res = 0;
}
if (res < 0 || d->restart_wait) { /* Report SIGSYS if we restart. */
d->signal = SIGSYS;
d->restart_wait = 0;
goto restart_wait;
}
/* Restore arch dependent state that is not part of the mcontext */
stub_seccomp_restore_state(&d->arch_data);
/* Return so that the host modified mcontext is restored. */
}
void __section(".__syscall_stub")
stub_signal_restorer(void)
{ /* We must not have anything on the stack when doing rt_sigreturn */
stub_syscall0(__NR_rt_sigreturn);
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.