Commit Graph

12183 Commits

Author SHA1 Message Date
Andreas Kling
c37dc4ae73 LibC: Add sa_family_t and in_port_t types 2020-08-11 21:13:18 +02:00
Linus Groh
36c738d9bf LibJS: Assert when exception is not cleared before Interpreter::run()
This is to prevent bugs like #3091 (fixed in
9810f8872c21eaf2aefff25347d957cd26f34c2d) in the future; we generally
don't want Interpreter::run() to be called if the interpreter still has
an exception stored. Sure, it could clear those itself but letting users
of the interpreter do it explicitly seems sensible.
2020-08-11 21:08:30 +02:00
Linus Groh
1d728af5c4 LibWeb: Clear exceptions in each Document::run_javascript() call
We don't want to carry over exceptions across multiple
Document::run_javascript() calls as Interpreter::run() and every of its
exception checks will get confused - in this case there would be an
exception, but not because a certain action failed.

Real-life example:

<script>var a = {}; a.test()</script>
<script>alert("It worked!")</script>

The above HTML will invoke Document::run_javascript() twice, the first
call will result in a TypeError, which is still stored during the second
call. The interpreter will eventually call the following functions (in
order) for the alert() invocation:

- Identifier::execute()
- Interpreter::get_variable()
- Object::get() (on the global object)

That last Object::get() call has an exception check which is triggered
as we still carry around the exception from earlier - and eventually
returns an empty value.

Long story short, the second script will wrongly fail with
"ReferenceError, 'alert' is not defined".

Fixes #3091.
2020-08-11 21:08:30 +02:00
Nico Weber
f8084cc083 UserspaceEmulator: Remove some silly semicolons 2020-08-11 21:04:38 +02:00
Andreas Kling
c6ee6c0b42 UserspaceEmulator: Log unimplemented instructions with proper backtrace 2020-08-11 20:29:14 +02:00
Andreas Kling
62ec6e5fe0 Kernel: Make Inode::read_entire() return a KBuffer (not ByteBuffer)
ByteBuffer is backed by kmalloc heap memory which is a scarce resource.
This fixes an OOM panic when traversing a large directory.
2020-08-11 20:29:14 +02:00
Andreas Kling
ec93d6ffdc LibC: Add in6_addr and sockaddr_in6 structs 2020-08-11 20:29:14 +02:00
Andreas Kling
eeb9042b8e LibC: Declare sockaddr_storage
This type is guaranteed to fit the largest sockaddr_foo supported by
the system. In our case, that's sockaddr_un.
2020-08-11 20:29:14 +02:00
Andreas Kling
9ba9228a6b LibC: Make sure assert() expands to *something* in non-DEBUG builds
Sometimes people write strange things like "assert(x), something();"
and this will not work if "assert(x)" expands to "".

So make it expand to ((void)0) instead.
2020-08-11 20:29:14 +02:00
Andreas Kling
797904bafd Kernel: Forward declare struct stat in the syscall API header 2020-08-11 20:29:14 +02:00
Andreas Kling
3a13c749cd LibC: Move stat(), lstat() and fstat() to <sys/stat.h>
Dr. POSIX says that's where they belong.
2020-08-11 20:29:14 +02:00
Andreas Kling
9e55162e9b mv: Accept (but ignore) -f
Many scripts seem to use "mv -f", so let's support that.
2020-08-11 20:29:14 +02:00
Andreas Kling
2a765ad062 rm: Implement a basic -f mode 2020-08-11 20:29:14 +02:00
Andreas Kling
5bca49162c LibELF: Remove unused cruft in ELF::Loader 2020-08-11 20:29:14 +02:00
Nico Weber
8d3d0054ed Crypto: Make AES call malloc much less often
ByteBuffer::slice_view() allocates a new ByteBuffer object,
which as a RefPtr and everything.

Nowadays it should probably return a Bytes / Span<u8>, but AES was only
using slice_view() to extract the pointer again.  So just add ady a
range check at the top, and do pointer arithmetic to do the same thing
faster.

Reduces time to run `disasm /bin/id` by a bit under 40%,
from ~8.3s to ~5s (min-of-3 runs).
2020-08-11 16:25:36 +02:00
Linus Groh
faab8a82cb TextEditor: Show pageview URLs in statusbar on hover 2020-08-11 15:45:02 +02:00
Linus Groh
1353edd090 TextEditor: Open links from Web::PageView using Desktop::Launcher
So far, clicking on a link from the Markdown/HTML preview Web::PageView did
nothing - now we pass that link to Desktop::Launcher, which will then
open it in Browser, FileManager, another TextEditor instance etc.
2020-08-11 15:23:10 +02:00
Tom
49d5232f33 Kernel: Always return from Thread::wait_on
We need to always return from Thread::wait_on, even when a thread
is being killed. This is necessary so that the kernel call stack
can clean up and release references held by it. Then, right before
transitioning back to user mode, we check if the thread is
supposed to die, and at that point change the thread state to
Dying to prevent further scheduling of this thread.

This addresses some possible resource leaks similar to #3073
2020-08-11 14:54:36 +02:00
Andrew Mbugua
1f7190d3bd
Meta: Fix typo in NotesOnWSL.md (#3086) 2020-08-11 14:27:00 +02:00
Andreas Kling
8d73355c38 LibELF: Set ELF::Loader::m_symbol_count in constructor
Setting it in load() excludes users of ELF::Loader that don't actually
call load() but only use the Loader for symbolication purposes.

Perhaps the factoring here is not ideal.
2020-08-11 12:23:43 +02:00
Andreas Kling
c3b6df60b7 Help: Spruce up the UI with some tasteful layout margins 2020-08-10 21:20:28 +02:00
Andreas Kling
ae0ff13f66 LibGfx: Correct copyright years for {Classic,}WindowTheme.{cpp,h} 2020-08-10 21:20:28 +02:00
Andreas Kling
015c8d0eb6 Userland: Add a simple dirname(1) utility 2020-08-10 21:20:28 +02:00
Tom
8ffa4131ce WindowServer: Limit maximizing windows to top window in modal stack
When maximizing a window that is blocked by a modal window, only
maximize the top window in the stack. However, if the stack is
minimized, restore all of them in addition.

Fixes #3074
2020-08-10 21:02:11 +02:00
Nico Weber
37d5e3e0df Shell: Fix fd leak with pipes
Fixes the problem reported in #3073. While trying to write a test
for this, I thought I'd use

    Shell -c 'for i in $(seq 100) { echo $i }' | head -n 1

but that makes the cpu spin at 100% and doesn't terminate even
with this fix here. But at least piping disasm into head now works.
2020-08-10 20:57:38 +02:00
AnotherTest
69fc91d974 Shell: Cancel a running for loop upon receiving any non-SIGINT signal
And keep the old behaviour of needing two interruptions on SIGINT.
2020-08-10 20:50:06 +02:00
Andreas Kling
d777583e28 FileManager: Make the desktop process show as "FileManager (Desktop)" 2020-08-10 20:29:08 +02:00
Tom
fcaa45f97b Kernel: Include the 128 byte slab allocator in for_each_allocator 2020-08-10 20:05:18 +02:00
Tom
08ff25f4ef Kernel: Invoke heap constructors separately early on
By having a separate list of constructors for the kernel heap
code, we can properly use constructors without re-running them
after the heap was already initialized. This solves some problems
where values were wiped out because they were overwritten by
running their constructors later in the initialization process.
2020-08-10 20:05:18 +02:00
Muhammad Zahalqa
de5e542930 LibCore: remove redundant UDPSocket constructor
The comment claims it is for use from UDPServer::accept
Which is not a real function.
2020-08-10 20:03:18 +02:00
Muhammad Zahalqa
eb77568d8c LibCore: update m_bound on socket bind 2020-08-10 20:03:18 +02:00
Nico Weber
00f658b984
Lagom+LibELF: Add an ELF fuzzer, and tweak the code to survive a few minutes of fuzzing (#3071)
If a buffer smaller than Elf32_Ehdr was passed to Image, header()
would do an out-of-bounds read.

Make parse() check for that. Make most Image methods assert that the image
is_valid(). For that to work, set m_valid early in Image::parse()
instead of only at its end.

Also reorder a few things so that the fuzzer doesn't hit (valid)
assertions, which were harmless from a security PoV but which still
allowed userspace to crash the kernel with an invalid ELF file.

Make dbgprintf()s configurable at run time so that the fuzzer doesn't
produce lots of logspam.
2020-08-10 15:55:17 +02:00
Andreas Kling
eaf7e68408 LibWeb: Move tree iteration helpers from Node/LayoutNode to TreeNode
Since these are generally useful in our trees, let's just keep them
in TreeNode instead of duplicating the helpers in subclasses.
2020-08-10 15:21:23 +02:00
Linus Groh
62ea2c5437 AK: Add test case for duplicate JsonObject keys 2020-08-10 14:48:45 +02:00
Linus Groh
f649009887 AK: Don't keep equal JsonObject keys in the order vector twice
Fixes #3069.
2020-08-10 14:48:45 +02:00
Andreas Kling
ecc8a42cd2 WindowServer: Use to_theme_window_type() a bit more 2020-08-10 13:05:02 +02:00
Andreas Kling
de1a54c378 WindowServer+LibGfx: Move window frame rect calculation to WindowTheme 2020-08-10 13:03:44 +02:00
Brian Gianforcaro
0e627b0273 Kernel: Use Userspace<T> for the exit_thread syscall
Userspace<void*> is a bit strange here, as it would appear to the
user that we intend to de-refrence the pointer in kernel mode.

However I think it does a good join of illustrating that we are
treating the void* as a value type,  instead of a pointer type.
2020-08-10 12:52:15 +02:00
Brian Gianforcaro
d3847b3489 Kernel: Use Userspace<T> for the join_thread syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
e8917cc5f3 Kernel: Use Userspace<T> for the chroot syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
20e2a5c111 Kernel: Use Userspace<T> for the module_unload syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
c4927ceb08 Kernel: Use Userspace<T> for the module_load syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
b5a2a215f6 Kernel: Use Userspace<T> for the getrandom syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
c8ae244ab8 Kernel: Use Userspace<T> for the shbuf_get syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
e073f2b59e Kernel: Use Userspace<T> for the get_thread_name syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
9652b0ae2b Kernel: Use Userspace<T> for the set_thread_name syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
0e20a6df0a Kernel: Use Userspace<T> for the connect syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
8bd9dbc220 Kernel: Use Userspace<T> for the accept syscall 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
02660b5d60 Kernel: Use Userspace<T> for the bind syscall, and implementation 2020-08-10 12:52:15 +02:00
Brian Gianforcaro
2bac7190c8 Kernel: Use Userspace<T> for the chmod syscall 2020-08-10 12:52:15 +02:00