Commit graph

682 commits

Author SHA1 Message Date
Brian Gianforcaro
0f42463eab Kernel: Use Userspace<T> for the execve syscall 2020-08-10 12:52:15 +02:00
AnotherTest
1222be7e3a HackStudio: Set the pgrp of the pseudoterminal to the child pid
This fixes #3046.
2020-08-09 11:33:15 +02:00
Andreas Kling
fae9c9f81f UserspaceEmulator: Add the dup2 syscall 2020-08-07 18:46:56 +02:00
Andreas Kling
5dce5fa7c2 UserspaceEmulator: Add the chdir syscall 2020-08-07 18:44:51 +02:00
Andreas Kling
ee5e8081da UserspaceEmulator: Pass full path to new UE instance in virt$execve()
Don't just pass argv[0] to the new UE, pass the full program path.
2020-08-07 17:28:00 +02:00
Andreas Kling
5a5b687014 UserspaceEmulator: Add the getpgid() and waitid() syscalls
With this, you can now kinda sorta run the shell in UserspaceEmulator!
2020-08-07 16:51:08 +02:00
Andreas Kling
93b1e54237 UserspaceEmulator: Add the setpgid syscall 2020-08-07 16:34:50 +02:00
Andreas Kling
2b3b83801b UserspaceEmulator: Make the "unimplemented syscall" output look nicer 2020-08-07 16:34:50 +02:00
Andreas Kling
5ba2022b8e UserspaceEmulator: Result is initialized after OR with all-1 immediate
When compiling with "-Os", GCC produces the following pattern for
atomic decrement (which is used by our RefCounted template):

    or eax, -1
    lock xadd [destination], eax

Since or-ing with -1 will always produce the same output (-1), we can
mark the result of these operations as initialized. This stops us from
complaining about false positives when running the shell in UE. :^)
2020-08-07 15:41:53 +02:00
Andreas Kling
2f1d596dd3 UserspaceEmulator: Fix bad rc check in ttyname and getcwd syscalls
Errors here are (rc < 0), not (rc < 1).
2020-08-06 11:45:52 +02:00
Andreas Kling
d608d714b9 UserspaceEmulator: Support ioctl(TCGETS) and ioctl(TCSETS) 2020-08-05 22:34:50 +02:00
Andreas Kling
e0e3e5b9b1 UserspaceEmulator: Add the access syscall 2020-08-05 22:34:50 +02:00
Andreas Kling
c497603177 UserspaceEmulator: Add the getcwd syscall 2020-08-05 22:34:50 +02:00
Andreas Kling
b187a42e53 UserspaceEmulator: Add the ttyname syscall 2020-08-05 22:34:50 +02:00
Andreas Kling
9d93e208ac UserspaceEmulator: Support ioctl(TIOCSPGRP) 2020-08-05 22:34:50 +02:00
Andreas Kling
3717a00290 UserspaceEmulator: Add the getpgrp syscall 2020-08-05 22:34:50 +02:00
Andreas Kling
8dea25d974 UserspaceEmulator: Add support for UNIX signals :^)
The emulator will now register signal handlers for all possible signals
and act as a translation layer between the kernel and the emulated
process.

To get an accurate simulation of signal handling, we duplicate the same
trampoline mechanism used by the kernel's signal delivery system, and
also use the "sigreturn" syscall to return from a signal handler.

Signal masking is not fully implemented yet, but this is pretty cool!
2020-08-05 22:34:50 +02:00
Andreas Kling
db450dbc44 Base: Move "js" and "little" HackStudio projects into ~/Source/ 2020-08-05 17:40:47 +02:00
Linus Groh
a8d7cd5a15 HackStudio: Open project or file from argv[1] if given
When HackStudio is invoked with one or more arguments it will attempt to
treat the first argument as a project or source file and open it
accordingly.
2020-08-05 16:54:23 +02:00
Linus Groh
0d493c1879 HackStudio: Rename project file format from .files to .hackstudio 2020-08-05 16:54:23 +02:00
Andreas Kling
dff8305138 UserspaceEmulator: Don't print backtrace offsets if we have file/line
File/line is way more interesting than offsets, so let's only do the
offsets if we don't have file/line information.
2020-08-01 09:49:03 +02:00
Andreas Kling
80eef2c014 UserspaceEmulator: Report heap buffer overflows :^) 2020-08-01 09:44:19 +02:00
Andreas Kling
030edbd513 UserspaceEmulator: Mark mmap regions as malloc blocks when mallocing
We don't have to be clever at all to figure out which MmapRegions are
malloc blocks, we can just mark the containing region as such when
the emulated process performs a malloc! :^)
2020-08-01 09:13:45 +02:00
Andreas Kling
5de7bae383 UserspaceEmulator: Forward errors from fork() correctly 2020-08-01 09:11:18 +02:00
Andreas Kling
c7e4c0734b UserspaceEmulator: Use a report() function instead of dbgprintf()
Ultimately we'll want to make it a bit easier to add more reporting.
This at least makes it easier to redirect the logging.
2020-07-31 20:56:48 +02:00
Nico Weber
8593bdb711 LibX86: Disassemble most remaining FPU instructions
Some of the remaining instructions have different behavior for
register and non-register ops.  Since we already have the
two-level flags tables, model this by setting all handlers in
the two-level table to the register op handler, while the
first-level flags table stores the action for the non-reg handler.
2020-07-30 16:53:33 +02:00
Andreas Kling
c46439f240 LibWeb: Move HTML classes into the Web::HTML namespace 2020-07-28 18:55:48 +02:00
Nico Weber
c99a3efc5b LibX86: Disassemble most FPU instructions starting with D9
Some of these don't just use the REG bits of the mod/rm byte
as slashes, but also the R/M bits to have up to 9 different
instructions per opcode/slash combination (1 opcode requires
that MOD is != 11, the other 8 have MODE == 11).

This is done by making the slashes table two levels deep for
these cases.

Some of this is cosmetic (e.g "FST st0" has no effect already,
but its bit pattern gets disassembled as "FNOP"), but for
most uses it isn't.

FSTENV and FSTCW have an extraordinary 0x9b prefix. This is
not yet handled in this patch.
2020-07-28 18:55:29 +02:00
thankyouverycool
8248c74d88 DevTools: Let Inspector use ProcessChooser and new icons.
Inspector now opens ProcessChooser when no PID is supplied.
2020-07-28 16:29:36 +02:00
thankyouverycool
6448f94372 DevTools+LibGUI: Make ProcessChooser a general Dialog in LibGUI
Moves ProcessChooser and RunningProcessesModel to LibGUI and
generalizes their construction for use by other apps. Updates
Profiler to reflect the change and use its new icons.
2020-07-28 16:29:36 +02:00
Andreas Kling
b8d3dbcf2d UserspaceEmulator: Add syscalls: stat(), realpath(), gethostname()
This is enough to run /bin/ls :^)
2020-07-28 00:03:25 +02:00
Andreas Kling
9def88e08d UserspaceEmulator: Don't just return "EMULATED" in get_process_name()
Now that emulated processes have their real name (with a "(UE)" prefix)
we can actually let them know their name.
2020-07-28 00:03:25 +02:00
Andreas Kling
2ac5c2278d UserspaceEmulator: Support ioctl(TIOCGWINSZ)
This is very commonly used by terminal programs, and easy to support.
2020-07-28 00:03:25 +02:00
Andreas Kling
db1b67e88a UserspaceEmulator: Set the process and thread name to "(UE) Executable"
This makes it much easier to see who's who when running multiple
emulators at the same time. :^)
2020-07-27 19:10:18 +02:00
Andreas Kling
0b287c18b9 UserspaceEmulator: Implement the execve() syscall :^)
This virtual syscall works by exec'ing the UserspaceEmulator itself,
with the emulated program's provided arguments as the arguments to the
new UserspaceEmulator instance.

This means that we "follow" exec'ed programs and emulate them as well.
In the future we might want to make this an opt-in (or opt-out, idk)
behavior, but for now it's what we do.

This is really quite cool, I think! :^)
2020-07-27 19:10:18 +02:00
Andreas Kling
b9b74e355a UserspaceEmulator: Implement the fork() syscall :^) 2020-07-27 19:10:18 +02:00
Andreas Kling
d9f933df7b UserspaceEmulator: Implement the setuid() and setgid() syscalls
Note that running a setuid program (e.g /bin/ping) in UE does not
actually run uid=0. You'll have to run UE itself as uid=0 if you want
to test programs that do setuid/setgid.
2020-07-27 16:32:30 +02:00
Andreas Kling
368cea4094 UserspaceEmulator: Implement the accept() and setsockopt() syscalls
It's now possible to run LookupServer in UE (by setting up SystemServer
to run the service inside UE.) No bugs found, but very cool! :^)
2020-07-27 16:28:40 +02:00
Andreas Kling
f097ed6ada UserspaceEmulator: Transfer the environment to the emulated process 2020-07-27 15:57:12 +02:00
Andreas Kling
272dbb82ff UserspaceEmulator: Mark SimpleRegions as initialized up front for now
This prevents some false positives since the initial stack is expected
to be zero-initialized.
2020-07-27 13:40:36 +02:00
Andreas Kling
31b94114c0 UserspaceEmulator: Recognize xor/sub zeroing idioms and don't taint
"xor reg,reg" or "sub reg,reg" both zero out the register, which means
we know for sure the result is 0. So mark the value as initialized,
and make sure we don't taint the CPU flags.

This removes some false positives from the uninitialized memory use
detection mechanism.

Fixes #2850.
2020-07-27 13:20:23 +02:00
Andreas Kling
e0b8b4ac67 LibCore+LibGUI: Switch to using AK::is and AK::downcast 2020-07-26 17:51:00 +02:00
Andreas Kling
a565121793 LibWeb: Move HTML object model stuff into LibWeb/HTML/
Take a hint from SVG and more all the HTML classes into HTML instead of
mixing them with the DOM classes.
2020-07-26 17:51:00 +02:00
Nico Weber
f6db97b8a9 LibX86: Support disassembling a few FPU opcodes better 2020-07-26 11:29:03 +02:00
Andreas Kling
9fc00d5d12 UserspaceEmulator: XLAT BX should not check full EBX shadow bits
Thanks to Rick van Schijndel for pointing this out. :^)
2020-07-22 00:07:15 +02:00
Andreas Kling
9c155c8f35 UserspaceEmulator: Tweak some output strings 2020-07-21 23:35:09 +02:00
Andreas Kling
a819c35904 UserspaceEmulator: Include flag taint state in dump output 2020-07-21 19:21:52 +02:00
Andreas Kling
abebec0e04 UserspaceEmulator: Use the base address of instructions in backtraces
Instead of using SoftCPU::eip() which points at the *next* instruction
most of the time, stash away a "base EIP" so we can use it when making
backtraces. This makes the correct line number show up! :^)
2020-07-21 19:08:01 +02:00
Andreas Kling
5c29f4e326 UserspaceEmulator: Add a newline before uninitialized op warnings 2020-07-21 19:08:01 +02:00
Andreas Kling
0f91dfa139 UserspaceEmulator: Show file and line numbers in backtraces :^)
This was super easy thanks to the awesome LibDebug work by @itamar8910!
2020-07-21 19:08:01 +02:00