Commit graph

20230 commits

Author SHA1 Message Date
Jean-Baptiste Boric
eecf7a2097 LibC: Move mman.h to sys/mman.h
POSIX mandates that it is placed there.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
e16894af5a LibC: Do not include errno.h inside unistd.h
POSIX does not mandate this, therefore let's not do it.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
7f498769ac LibThread: Port Lock to foreign environments 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
9853a4393c IPCCompiler: Fix declaration of static functions 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
090936e424 Userland: Replace arc4random() with get_random<u32>() 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
5a0468c21f Userland: Migrate from arc4random_uniform() to get_random_uniform() 2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
069bf988ed AK: Introduce get_random_uniform()
This is arc4random_uniform(), but inside AK.
2021-05-14 22:24:02 +02:00
Jean-Baptiste Boric
ad7cd05fc1 AK: Fix redefinition of macro inside AK/Platform.h 2021-05-14 22:24:02 +02:00
Stephan Unverwerth
2b9ad11bd8 LibGL: Implement glFlush() and glFinish() 2021-05-14 22:15:50 +02:00
Andreas Kling
3429b44161 LibCore: Never connect to InspectorServer if getuid() == 0
Let's just stay on the safe side with this.
2021-05-14 22:12:52 +02:00
Linus Groh
5c05dfecb5 Meta: Remove accidentally committed 'js.js' file 2021-05-14 20:19:59 +01:00
Linus Groh
f512b24b21 AnalogClock: Use YYYY-MM-DD format for window title 2021-05-14 20:17:09 +01:00
Andreas Kling
212e1ba0d4 ImageViewer: Sandbox image decoding using the ImageDecoder service :^)
Instead of parsing untrusted and potentially malicious image files in
the ImageViewer GUI process, take advantage of the ImageDecoder service
that we already have on the system to sandbox the decode.

This prevents bugs in our image decoding libraries from being used as
an exploitation vector when viewing files in ImageViewer.
2021-05-14 21:02:18 +02:00
Andreas Kling
fa0e23009a LibImageDecoderClient: Decoded images with 0 frames are not successful
Previously you could pass anything (e.g a text file) to ImageDecoder and
it would "succeed" in decoding it and give you back a 0-frame result.

Let's consider that state a failure instead.
2021-05-14 21:02:14 +02:00
Andreas Kling
3168a4afe8 ImageViewer: Rename QSWidget => ImageViewer::ViewWidget 2021-05-14 18:37:08 +02:00
Andreas Kling
58d73ea36c Userland: Rename QuickShow => Image Viewer
The old name was a bit too ambiguous. This one is crystal clear. :^)
2021-05-14 18:34:44 +02:00
Andreas Kling
d039542c7c AK: Remove unused STRINGIMPL_DEBUG instrumentation 2021-05-14 17:17:32 +02:00
Andreas Kling
5fd65adb19 Browser: Don't spawn RequestServer and WebSocket in multi-process mode
Single-process Browser forces a connection to these services early on,
to avoid having to unveil their paths. I'm suspicious of the benefits
of this (and the comment about it wasn't even accurate) but let's keep
it for now.

In multi-process mode, there's no need to do this, and in fact it was
causing us to spawn two extra totally unused processes.
2021-05-14 17:17:30 +02:00
Andreas Kling
3ed5a73ede Profiler: Mark model columns as non-sortable
This removes the ability to click on the column headers to resort.
Resorting didn't do anything anyway.
2021-05-14 17:17:17 +02:00
Gunnar Beutner
c22296505c Kernel: Merge do_retransmit_packets() into retransmit_packets() 2021-05-14 16:50:00 +02:00
Gunnar Beutner
08aa3a91e3 Kernel: Try to retransmit lost TCP packets
Previously we didn't retransmit lost TCP packets which would cause
connections to hang if packets were lost. Also we now time out
TCP connections after a number of retransmission attempts.
2021-05-14 16:50:00 +02:00
Gunnar Beutner
9daec809b7 Kernel: Wake up NetworkTask every 500 milliseconds
This wakes up NetworkTask every 500 milliseconds so that it can send
pending delayed TCP ACKs and isn't forced to send all of them early
when it goes to sleep like it did before.
2021-05-14 16:50:00 +02:00
Gunnar Beutner
990b2d0989 Kernel: Don't use delayed ACKs when establishing the connection
When establishing the connection we should send ACKs right away so
as to not delay the connection process. This didn't previously
matter because we'd flush all delayed ACKs when NetworkTask waits
for incoming packets.
2021-05-14 16:50:00 +02:00
Andreas Kling
aea709de31 Meta: Add note about writing commit subjects in the imperative mood 2021-05-14 16:45:27 +02:00
Andreas Kling
3e603b2f32 AK: Make StringView::hash() constexpr
This required moving string_hash() to its own header so that everyone
can see it.
2021-05-14 15:24:32 +02:00
Brian Gianforcaro
9c38475608 Kernel: Add the ability to verify we don't kmalloc under spinlock.
Ideally we would never allocate under a spinlock, as it has many
performance and potentially functionality (deadlock) pitfalls.

We violate that rule in many places today, but we need a tool to track
them all down and fix them. This change introduces a new macro option
named `KMALLOC_VERIFY_NO_SPINLOCK_HELD` which can catch these
situations at runtime via an assert.
2021-05-14 13:28:21 +02:00
Itamar
6329e9fce6 LanguageServer/Cpp: Add tests
The Cpp LanguageServer tests can be run with: CppLanguageServer -t

The tests now only cover some very simple autocomplete and
"find declaration" use cases, but it's a start :)
2021-05-14 13:27:47 +02:00
Itamar
e9fc5d6cc3 LanguageServers: Allow set_declarations_of_document callback to be null 2021-05-14 13:27:47 +02:00
Itamar
545b6af305 LanguageServers/FileDB: Allow m_project_root to be null 2021-05-14 13:27:47 +02:00
Itamar
c49cf23a86 LanguageServers: Remove ClientConnection dependency
We now no longer need to provide a ClientConnection object to construct
AutoCompleteEngine.
2021-05-14 13:27:47 +02:00
Idan Horowitz
687efe6dd6 Documentation: Add a note about enabling the console iPXE command
This command is used in the given script, and in the latest version of
iPXE its disabled by default
2021-05-14 13:25:19 +02:00
Andreas Kling
89febfcd30 Meta: Specify that we use ISO 8601 dates and the metric system 2021-05-14 13:21:47 +02:00
Gunnar Beutner
a8e6cdc0d8 AK: Avoid allocations in ByteBuffer
Creating a ByteBuffer involves two allocations:

-One for the ByteBufferImpl object
-Another one for the actual byte buffer

This changes the ByteBuffer and ByteBufferImpl classes
so only one allocation is necessary.
2021-05-14 12:51:13 +02:00
Andreas Kling
fccfc33dfb AK: Use move semantics to avoid copying in JSON parser
The JSON parser was deep-copying JsonValues left and right, and it was
all totally avoidable. :^)
2021-05-14 11:54:43 +02:00
Andreas Kling
6210d2612e Profiler: Avoid JsonArray copying during perfcore parsing
Use JsonObject::get_ptr() to access array values without copying them.
2021-05-14 11:38:35 +02:00
Andreas Kling
8360079cac LibGUI: Fix logic typo in AbstractTableView::update_row_sizes()
We should skip over non-visible *rows*, not *columns*.
2021-05-14 11:37:24 +02:00
DexesTTP
36a56871c0 LibCrypto: Prevent a signed overflow during BigInt Modular Power
The algorithm isn't explicit about what type this needs to be. But this
passes all of the tests, so that's probably fine.
2021-05-14 11:36:39 +02:00
Brian Gianforcaro
4728f2af80 Kernel: Avoid unnecessary time under lock in TCPSocket::create
Avoid holding the sockets_by_tuple lock while allocating the TCPSocket.
While checking if the list contains the item we can also hold the lock
in shared mode, as we are only reading the hash table.

In addition the call to from_tuple appears to be superfluous, as we
created the socket, so we should be able to just return it directly.
This avoids the recursive lock acquisition, as well as the unnecessary
hash table lookups.
2021-05-14 11:32:50 +02:00
Brian Gianforcaro
879eec6aa8 Kernel: Remove dead TCPSocket::from_endpoints method 2021-05-14 11:32:50 +02:00
Andreas Kling
6387f65f87 LibGUI: Resize GUI::HeaderView section vector to final size immediately
When computing row & column sizes in AbstractTableView, it iterates
across both axes starting from 0.

This caused us to grow the corresponding HeaderView's internal section
vector by 1 entry for each step, leading to Vector::resize() thrashing.

Since we already know the final size, just resize to that immediately,
and the thrashing goes away.

This gives a huge speedup when loading large files into Profiler. :^)
2021-05-14 10:32:44 +02:00
Brian Gianforcaro
c63761a341
Profiler: Avoid copies / String construction when parsing profile (#7096)
Use sv literal suffix to construct StringViews at compile time,
and make sure to reference array items by const reference.
2021-05-14 10:21:25 +02:00
Ali Mohammad Pur
5a7db74c52 LibTLS: Actually verify the certificats
This was likely commented out at some point to debug something.
2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
df515e1d85 LibCrypto+LibTLS: Avoid unaligned reads and writes
This adds an `AK::ByteReader` to help with that so we don't duplicate
the logic all over the place.
No more `*(const u16*)` and `*(const u32*)` for anyone.
This should help a little with #7060.
2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
bfd4c7a16c AK: Avoid passing nullptr to __buitin_memcpy() in ByteBuffer::grow() 2021-05-14 08:39:29 +01:00
Ali Mohammad Pur
a4e20a87d5 LibCrypto: Do not assume that the passed in IV is as long as a block
Just take ReadonlyBytes instead of a raw pointer.
Fixes #7072 (tested with the ASAN build fixed by #7060).
2021-05-14 08:39:29 +01:00
Andrew Kaster
e96451edc9 Tests: Don't use TestRunners after their scope ends in test-js
The TestRunner objects at the end of test-js are destroyed after the
if/else that chooses whether to run the 262 parser tests or the standard
tests. Accessing TestRunner::the() after the lifetime of the TestRunners
ends is UB, so return the Test::Counts from run() instead. Also, fix the
destructor of TestRunner to set s_the to nullptr so that if anyone tries
this type of shenanigains again, they'll get a crash :^).
2021-05-14 08:34:00 +01:00
Andrew Kaster
f90a19ba4c LibJS: Make sure all allocators are 8-byte aligned
Absolutely massive allocations > 1024 bytes would go into the size
class which was 3172 bytes. 3172 happens to not be 8 byte aligned, and
so made UBSAN very sad on x86_64. Change the largest allocator to be
3072 bytes, which is in fact a multiple of 8 :^)
2021-05-14 08:34:00 +01:00
Andrew Kaster
e1b8a2e517 Tests: Mark use-after-scope NeverDestroyed test NO_SANITIZE_ADDRESS
The should_not_destroy test case intentionally performs an invalid stack
access on a NeverDestroyed to confirm that the destructor for the held
type was not called.
2021-05-14 08:34:00 +01:00
Andrew Kaster
55d338b66f Tests: Free all memory allocated with regcomp in RegexLibC tests
The C interface (posix interface?) for regexes has no "initialize"
function, only a free function. The comment in regcomp in
LibRegex/C/Regex.cpp notes that calling regcomp without a regfree is an
error, and will leak memory. Every single time regcomp is called on a
regex_t*, it will allocate new memory.

Make sure that all the regcomp calls are paired with a regfree in the
tests program
2021-05-14 08:34:00 +01:00
Andrew Kaster
09fe9f4542 Tests: Fix use-after-free in TestRefPtr.self_observers
We can't unref an object to destruction while there's still a live
RefPtr to the object, otherwise the RefPtr destructor will try to
destroy it again, accessing the refcount of a destroyed object (before
realizing that oops! the object is already dead)
2021-05-14 08:34:00 +01:00