Commit Graph

6533 Commits

Author SHA1 Message Date
Andreas Kling
f4302b58fb Kernel: Remove SmapDisablers in sys$getsockname() and sys$getpeername()
Instead use the user/kernel copy helpers to only copy the minimum stuff
needed from to/from userspace.

Based on work started by Brian Gianforcaro.
2020-01-27 21:11:36 +01:00
Andreas Kling
7454926765 Shell: If a command process is stopped, print the stop signal to stderr 2020-01-27 20:48:42 +01:00
Andreas Kling
65961d3ffc LibC: Add WSTOPSIG macro
This macro can be used on the "status" output from sys$waitpid() to
find out which signal caused the waitee process to stop.

Fixes #794.
2020-01-27 20:47:56 +01:00
Andreas Kling
5163c5cc63 Kernel: Expose the signal that stopped a thread via sys$waitpid() 2020-01-27 20:47:10 +01:00
Andreas Kling
638fe6f84a Kernel: Disable interrupts while looking into the thread table
There was a race window in a bunch of syscalls between calling
Thread::from_tid() and checking if the found thread was in the same
process as the calling thread.

If the found thread object was destroyed at that point, there was a
use-after-free that could be exploited by filling the kernel heap with
something that looked like a thread object.
2020-01-27 14:04:57 +01:00
Andreas Kling
17210a39e4 Kernel: Remove ancient hack that put the current PID in TSS.SS2
While I was bringing up multitasking, I put the current PID in the SS2
(ring 2 stack segment) slot of the TSS. This was so I could see which
PID was currently running when just inspecting the CPU state.
2020-01-27 13:10:24 +01:00
Andreas Kling
ae0f92a0a1 Kernel: Simplify kernel thread stack allocation
We had two identical code paths doing this for some reason.
2020-01-27 12:52:45 +01:00
Andreas Kling
c1f74bf327 Kernel: Never validate access to the kmalloc memory range
Memory validation is used to verify that user syscalls are allowed to
access a given memory range. Ring 0 threads never make syscalls, and
so will never end up in validation anyway.

The reason we were allowing kmalloc memory accesses is because kernel
thread stacks used to be allocated in kmalloc memory. Since that's no
longer the case, we can stop making exceptions for kmalloc in the
validation code.
2020-01-27 12:43:21 +01:00
Andreas Kling
23ffd6c319 Kernel+LibC+Userland: Switch to 64-bit time_t
Let's not have that 2038 problem people are talking about. :^)
2020-01-27 10:59:29 +01:00
Andreas Kling
6906edee9a LibGUI: Add 64-bit signed integer support to GVariant
What was previously the "Int" type is now "Int32" and "Int64".
2020-01-27 10:55:10 +01:00
Andreas Kling
137a45dff2 Kernel: read()/write() should respect timeouts when used on a sockets
Move timeout management to the ReadBlocker and WriteBlocker classes.
Also get rid of the specialized ReceiveBlocker since it no longer does
anything that ReadBlocker can't do.
2020-01-26 17:54:23 +01:00
Andreas Kling
d1721c761e LookupServer: Don't cache already-expired DNS answers 2020-01-26 16:25:12 +01:00
Linus Groh
174583cda5 LibVT: Add parameter names in function signatures for clarity 2020-01-26 15:58:06 +01:00
Linus Groh
3549623dc6 LibVT: Rename escape$r to DECSTBM (Set Top and Bottom Margins) 2020-01-26 15:58:06 +01:00
Linus Groh
79f88db6fb LibVT: Remove empty line 2020-01-26 15:58:06 +01:00
Linus Groh
fd8c250866 LibVT: Replace escape$h_l with SM (Set Mode) / RM (Reset Mode) 2020-01-26 15:58:06 +01:00
Linus Groh
be57b81336 LibVT: Rename escape$f to HVP (Horizontal and Vertical Position) 2020-01-26 15:58:06 +01:00
Linus Groh
2edd8e37ae LibVT: Rename escape$c to DA (Device Attributes) 2020-01-26 15:58:06 +01:00
Linus Groh
dcb5bf9e50 LibVT: Rename escape$m to SGR (Select Graphic Rendition) 2020-01-26 15:58:06 +01:00
Linus Groh
296afbe624 LibVT: Rename escape$H to CUP (Cursor Position) 2020-01-26 15:58:06 +01:00
Linus Groh
5cdfc58242 LibVT: Rename escape$D to CUB (Cursor Backward) 2020-01-26 15:58:06 +01:00
Linus Groh
428a55a196 LibVT: Rename escape$C to CUF (Cursor Forward) 2020-01-26 15:58:06 +01:00
Linus Groh
35310dbd22 LibVT: Rename escape$B to CUD (Cursor Down) 2020-01-26 15:58:06 +01:00
Linus Groh
cc73284c64 LibVT: Rename escape$A to CUU (Cursor Up) 2020-01-26 15:58:06 +01:00
Andreas Kling
5e47508672 LookupServer: Cache DNS answers for TTL seconds
We now keep DNS answers around in a cache for TTL seconds after getting
them the first time. The cache is capped at 256 responses for now.

Suggested by @zecke in #10.
2020-01-26 15:44:51 +01:00
Andreas Kling
90a5907b44 LookupServer: Rename "custom_hosts" => "etc_hosts"
This makes it more obvious that these mappings come from /etc/hosts.
2020-01-26 15:44:51 +01:00
Andreas Kling
c26560ec26 LookupServer: Rename setting "DNS/IPAddress" => "DNS/Nameserver" 2020-01-26 15:44:51 +01:00
MWGuy
0c544052a5 Ports+OpenSSL: Fix RAND_poll patch 2020-01-26 15:27:12 +01:00
Andreas Kling
e335d730d6 LookupServer: Use CUdpSocket instead of the POSIX API
LibCore's UDP socket is a bit more comfortable to work with. :^)
2020-01-26 14:47:03 +01:00
Andreas Kling
3c129172d4 LibCore: Add UDP socket and server classes 2020-01-26 14:45:07 +01:00
Andreas Kling
2ce9a705e3 IPv4: Mark UDP sockets as connected immediately upon connect()
This makes it possible to write() to a blocking UDPSocket. Previously
this was not possible since can_write() depends on is_connected().
2020-01-26 14:43:08 +01:00
Andreas Kling
388d40d755 IPv4: Fix bitrot in IPv4Socket debug logging 2020-01-26 14:42:44 +01:00
Andreas Kling
8e7e502f37 LibCore: CSocket::set_blocking() was backwards 2020-01-26 14:29:33 +01:00
Andreas Kling
537a1d31c5 LookupServer: Add missing copyright headers 2020-01-26 13:53:36 +01:00
Andreas Kling
a9ec2225a5 LookupServer: Retry with 0x20 randomization turned off on EREFUSED
Apparently some authoritative servers don't handle 0x20 randomization
well and may send EREFUSED. Retry with randomization turned off then.

Reference: https://github.com/dns-violations/dns-violations/blob/master/2017/DVE-2017-0006.md

More work towards #10.
2020-01-26 13:49:46 +01:00
Andreas Kling
00be9b33b1 LookupServer: Verify that DNS response questions match the request
To protect against DNS spoof attacks, we now check that the questions
in incoming responses match the questions in the request we sent out.

Suggested by @zecke in #10.
2020-01-26 13:07:43 +01:00
Andreas Kling
b4d55b16b6 LookupServer: Randomize the 0x20 bit in DNS request ASCII characters
This adds a bit of extra entropy to DNS requests, making it harder to
spoof a valid response.

Suggested by @zecke in #10.
2020-01-26 13:07:21 +01:00
Andreas Kling
02be23cf81 LookupServer: Randomize DNS request ID's
Suggested by @zecke in #10.
2020-01-26 12:38:49 +01:00
Andreas Kling
871b6b4e1a LookupServer: Minor overhaul
- Break out request building into a DNSRequest class.
- Break out response parsing into a DNSResponse class.

A DNSRequest contains one or more DNSQuestion objects.
A DNSResponse contains all the DNSQuestions asked, and a DNSAnswer
object for each answer.
2020-01-26 12:37:08 +01:00
Andreas Kling
f24173b0f1 LibC: Only accept the first response from LookupServer in netdb code
If a DNS server responds with multiple answers for a question, we will
get a newline-separated sequence of answers from LookupServer.

However, we don't handle this properly yet in LibC, so just split the
response by line and only care about the first answer for now.
2020-01-26 12:23:37 +01:00
Andreas Kling
8fb9dc7425 Ports: Fix zlib build
We only support static linking at the moment, and zlib was trying to
build itself as a shared library.

Fixes #1135.
2020-01-26 10:33:43 +01:00
Andreas Kling
22d563b1aa IPv4: Don't hold IPv4Socket lock when blocking on byte-buffered receive 2020-01-26 10:26:27 +01:00
Andreas Kling
1d506a935c Ext2FS: Give names to some KBuffers
The more we give names to KBuffers, the easier it gets to understand
what's what in a kernel region dump. :^)
2020-01-26 10:18:18 +01:00
Andreas Kling
b011857e4f Kernel: Make writev() work again
Vector::ensure_capacity() makes sure the underlying vector buffer can
contain all the data, but it doesn't update the Vector::size().

As a result, writev() would simply collect all the buffers to write,
and then do nothing.
2020-01-26 10:10:15 +01:00
Andreas Kling
b93f6b07c2 Kernel: Make sched_setparam() and sched_getparam() operate on threads
Instead of operating on "some random thread in PID", these now operate
on the thread with a specific TID. This matches other systems better.
2020-01-26 09:58:58 +01:00
Andreas Kling
67950c80c8 Kernel: Zero-initialize LocalSocket::m_address
It was possible to read uninitialized kernel memory via getsockname().
Of course, kmalloc() is a good boy and scrubs new allocations with 0xBB
so all you got was a bunch of 0xBB.
2020-01-26 09:48:53 +01:00
Marios Prokopakis
da296f5865 Ext2FS: allocate_blocks allocates contiguous blocks (#1095)
This implementation uses the new helper method of Bitmap called
find_longest_range_of_unset_bits. This method looks for the biggest 
range of contiguous bits unset in the bitmap and returns the start of
the range back to the caller.
2020-01-26 09:48:24 +01:00
Brian Callahan
d847368c88 Ports: Add grep port 2020-01-26 09:46:41 +01:00
Brian Callahan
78ddf2e048 Ports: Add mandoc port 2020-01-26 09:10:37 +01:00
Brian Callahan
77ed943275 Ports: Add diffutils port 2020-01-26 08:48:19 +01:00