Live data from Hacker News

Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

github.com

11–20 of 31 posts

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#11
post #10

Nice Implementation! I built something similar a while ago to warp time in video games (for training reinforcement learning agents). Some issues off the top of my head (that I ran into): VDSO censoring is a lot harder than just symbol overriding, it has to actually be removed from the aux vector (third thing on the process stack when the process launches after arguments and environment variables. The EHDR entry is wh…

And the most foolproof way would be to run in a virtual machine or a prepared container. Pretty fast too.

Having a clock cgroup would be easier and more useful than you'd think. Also, you can play tricks like ntpd does in a container. (e.g. adjtime)

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#12
post #2

It's worth mentioning that libfaketime [1] is a more mature alternative with macOS support and more complete coverage of the relevant system calls. Nothing against the current project but that might be a better choice for many people. [1] - https://github.com/wolfcw/libfaketime

Libfaketime is great, especially if you have a good idea what time calls your target process is using.

If they're inspecting EHDR and calling VDSO directly, though, or they've statically compiled in their libc, then it won't help though.

I've also had a lot of issues getting it into tightly sandboxed contexts (e.g. the flash runtime in chrome).

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#13
post #7

There's also fluxcapacitor: https://github.com/majek/fluxcapacitor

fluxcapacitor autor here.

Fluxcapacitor is focused on speeding up complex programs - most notably test suites (that do fork/execve). The idea is to cheat on time, to allow testing timeout-related branches in code. You can spin out a server and a client, write a test that needs to wait 60 seconds for completion and see it pass in 0.6 seconds.

Tardis on the other hand seems single-threaded, which makes it useful for... not really sure. I guess a demo how to use ptrace.

The problem with syscall interception with ptrace is that it doesn't work for golang. Golang doesn't use libc. This means there is no way to hook into the VDSO[1] - based syscalls. They are just a jump from userspace to special userspace memory region, so ptrace won't ever see it.

So, this approach, using ptrace, as used in tardis and fluxcapacitor will not work for golang.

[1] http://man7.org/linux/man-pages/man7/vdso.7.html

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#14
post #10

Nice Implementation! I built something similar a while ago to warp time in video games (for training reinforcement learning agents). Some issues off the top of my head (that I ran into): VDSO censoring is a lot harder than just symbol overriding, it has to actually be removed from the aux vector (third thing on the process stack when the process launches after arguments and environment variables. The EHDR entry is wh…

And the most foolproof way would be to run in a virtual machine or a prepared container. Pretty fast too. Having a clock cgroup would be easier and more useful than you'd think. Also, you can play tricks like ntpd does in a container. (e.g. adjtime)

This depends on the virtual machine or container!

Ironically, because the folks working on containers/VMs are _really_ good at what they do, time access calls in particular have been really optimized (they get called a lot). This makes it very hard to intercept time calls at this layer! e.g. KVM and LXC both essentially hand time calls straight to the host.

This means time intercepts at the VM/container layer need fundamental support (I mentioned affine time transformation in the linux kernel in another comment) which doesn't work for people who need to deploy on current hosted container.

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#15
post #13
post #7

There's also fluxcapacitor: https://github.com/majek/fluxcapacitor

fluxcapacitor autor here. Fluxcapacitor is focused on speeding up complex programs - most notably test suites (that do fork/execve). The idea is to cheat on time, to allow testing timeout-related branches in code. You can spin out a server and a client, write a test that needs to wait 60 seconds for completion and see it pass in 0.6 seconds. Tardis on the other hand seems single-threaded, which makes it useful for...…

Syscall interception works for _every_ program, it's just a matter of doing it correctly.

VDSO is a small set of (3) calls which are not syscalls but direct calls (for speed/efficiency). Our goal is to remove this functionality to force libs to call through the (slower) syscall route instead.

I mention in another comment how EHDR censoring is needed for robust VDSO removal.

I've not run into a libc where censoring EHDR breaks time calls (i.e. it doesn't fallback to syscalls) but possibly golang has this.

In this case it's straightforward to setup a fake VDSO and then instead of EHDR censoring you just replace it with your fake VDSO address and you're golden!

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#17
post #2

It's worth mentioning that libfaketime [1] is a more mature alternative with macOS support and more complete coverage of the relevant system calls. Nothing against the current project but that might be a better choice for many people. [1] - https://github.com/wolfcw/libfaketime

Sadly, the license is GPL rather than the expected LGPL.

Re: Show HN: TARDIS – Warp a process's perspective of time by hooking syscalls

#19
post #5

I designed something similar for general fault injection [1] (and to learn rust). There's no intercept written for time syscalls yet, but it's on the issues list. [1] https://github.com/androm3da/libfaultinj

How does it compare to libfiu?

https://blitiri.com.ar/p/libfiu/

Post reply on HN