Commit Graph

2619 Commits

Author SHA1 Message Date
Xiao NuoFu
7fd77e9ffe Kernel/Net: make setsockopt pretend it understands SO_KEEPALIVE. 2020-04-06 11:44:13 +02:00
nimelehin
c0a4cf5e8d Kernel: Support best fit allocation policy in kmalloc()
Add find_best_fit() which implements best fit allocation algorithm.
Kmalloc now uses a best fit allocation policy for large allocations.
2020-04-06 08:33:13 +02:00
nimelehin
0d08ed2693 Kernel: Implement kmalloc() using AK::Bitmap
kmalloc's bitmap is wrapped with AK::Bitmap to access AK::Bitmap's
functions.
2020-04-06 08:31:48 +02:00
Liav A
a7d708e47d Kernel: Don't enumerate blocks of ext2 symlinks by default
Also, we assert if we encounter a block that is bigger than blocks
count in the superblock.

Fixes #1608.
2020-04-05 15:27:31 +02:00
Andreas Kling
1d468ed6d3 AK: Stop allowing implicit downcast with RefPtr and NonnullRefPtr
We were allowing this dangerous kind of thing:

RefPtr<Base> base;
RefPtr<Derived> derived = base;

This patch changes the {Nonnull,}RefPtr constructors so this is no
longer possible.

To downcast one of these pointers, there is now static_ptr_cast<T>:

RefPtr<Derived> derived = static_ptr_cast<Derived>(base);

Fixing this exposed a ton of cowboy-downcasts in various places,
which we're now forced to fix. :^)
2020-04-05 11:19:00 +02:00
AnotherTest
3e8cf79efa Servers: Add a new DHCP client
This adds a DHCPClient...Server that leases IPv4s.
2020-04-05 09:50:48 +02:00
AnotherTest
77191d82dc Kernel: Add the SO_BINDTODEVICE socket option
This patch adds a way for a socket to ask to be routed through a
specific interface.
Currently, this option only applies to sending, however, it should also
apply to receiving...somehow :^)
2020-04-05 09:50:48 +02:00
AnotherTest
7d0bf9b5a9 Kernel+AK: Separate out MACAddress and move it into AK 2020-04-05 09:50:48 +02:00
Andreas Kling
53d0ca2ad8 Kernel: Strip SUID+SGID bits from file when written to or chowned
Fixes #1624.
2020-04-04 19:46:55 +02:00
Andreas Kling
54cb1e36b6 Kernel: Enforce file system veil on file creation
Fixes #1621.
2020-04-04 16:41:39 +02:00
AnotherTest
2ea934bcfd Kernel: Do not reject broadcast UDP packets right away
This patch relaxes how we think about UDP packets being "for us" a bit;
the proper way to handle this would be to also check if the matched
socket has SO_BROADCAST set, but we don't have that :)
2020-04-04 12:23:46 +02:00
Andreas Kling
c2a8bbcb59 Revert "Kernel: Change Ext2FS to be backed by a file instead of a block device"
This reverts commit 6b59311d4b.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:29:03 +02:00
Andreas Kling
9ae3cced76 Revert "Kernel & Userland: Allow to mount image files formatted with Ext2FS"
This reverts commit a60ea79a41.

Reverting these changes since they broke things.
Fixes #1608.
2020-04-03 21:28:57 +02:00
Andreas Kling
522d8c5d71 Kernel: Non-readable-but-writable regions should still be mapped
Fixes #1436.
2020-04-03 10:10:56 +02:00
Marco Wang
3fae4cb054 Kernel: Prepend missing license 2020-04-03 09:12:29 +02:00
AnotherTest
b3d7c5d9de Kernel: Send Fragmented IPv4 packets if payload size > mtu
This adds IPv4 fragmentation, so now we can send huuuuuuge packets
properly.
2020-04-02 14:38:28 +02:00
Liav A
a60ea79a41 Kernel & Userland: Allow to mount image files formatted with Ext2FS 2020-04-02 12:03:08 +02:00
Liav A
6b59311d4b Kernel: Change Ext2FS to be backed by a file instead of a block device
This ensures that we can mount image files as virtual disks without the
need of implementing gross hacks like loopback devices :)
2020-04-02 12:03:08 +02:00
Liav A
2f2016f51d Kernel: Remove unnecessary printf specifier 2020-04-02 12:03:08 +02:00
Liav A
b1365d94f4 Kernel: Align read operation in HPET registers' block 2020-04-01 18:35:57 +02:00
Brendan Coles
e8b17c42bb Base: Change root user home directory from / to /root 2020-03-31 11:43:46 +02:00
Itamar
6b74d38aab Kernel: Add 'ptrace' syscall
This commit adds a basic implementation of
the ptrace syscall, which allows one process
(the tracer) to control another process (the tracee).

While a process is being traced, it is stopped whenever a signal is
received (other than SIGCONT).

The tracer can start tracing another thread with PT_ATTACH,
which causes the tracee to stop.

From there, the tracer can use PT_CONTINUE
to continue the execution of the tracee,
or use other request codes (which haven't been implemented yet)
to modify the state of the tracee.

Additional request codes are PT_SYSCALL, which causes the tracee to
continue exection but stop at the next entry or exit from a syscall,
and PT_GETREGS which fethces the last saved register set of the tracee
(can be used to inspect syscall arguments and return value).

A special request code is PT_TRACE_ME, which is issued by the tracee
and causes it to stop when it calls execve and wait for the
tracer to attach.
2020-03-28 18:27:18 +01:00
Itamar
c9396be83f WaitBlocker: don't unblock if thread has pending SIGCONT
Previosuly, if we sent a SIGCONT to a stopped thread
and then waitpid() with WSTOPPED on that thread before
the signal was dispatched,
then the WaitBlocker would first unblock (because the thread is stopped)
and only after that the thread would get the SIGCONT signal.
This would mean that when waitpid returns
the waitee is not stopped.

To fix this, we do not unblock the waiting thread
if the waitee thread has a pending SIGCONT.
2020-03-28 18:27:18 +01:00
Andreas Kling
c50fbf6da0 Kernel: Remove the floppy driver
Nobody was using this code, and it was not actively worked on, so let's
just not have it. Press F.
2020-03-28 10:09:48 +01:00
Andreas Kling
f3c245fb96 Kernel: Make ^W and ^U actually erase characters
This is quite hackish but it makes using the js REPL a lot nicer. :^)
2020-03-26 08:18:47 +01:00
Andreas Kling
fac6f62cf7 Build: Oops, LibJS tests were meant to go in /home/anon/js-tests 2020-03-25 16:16:04 +01:00
Andreas Kling
202055a72a Build: Copy LibJS/Tests into /home/anon/js-tests
The test runner currently depends on the bash port being installed.
If you have it, you can run the LibJS test suite inside Serenity
by simply entering /home/anon/js-tests and doing ./run-tests :^)
2020-03-25 15:53:47 +01:00
Liav A
5f579904c1 Interrupts: Handle spurious IRQs from eoi() method 2020-03-24 16:15:33 +01:00
Liav A
8d9b6c57b5 Interrupts: Use Optional container in IOAPIC
We return the Optional container in find_redirection_entry_by_vector()
method instead of a raw integer. This makes the code more readable and
correct.
2020-03-24 16:15:33 +01:00
Liav A
0b7fc525e1 Interrupts: Simplify IRQ disabling & enabling in IRQController(s)
Instead of blindly setting masks, if we want to disable an IRQ and it's
already masked, we just return. The same happens if we want to enable an
IRQ and it's unmasked.
2020-03-24 16:15:33 +01:00
Liav A
3f98a67d75 Interrupts: Remove unused methods 2020-03-24 16:15:33 +01:00
Liav A
8b38be3072 Kernel: Simplify disable_irq() and enable_irq() methods in IRQHandler
Setting the m_enabled variable to true or false can help
with monitoring the IRQHandler object(s) later, and there's no good
reason to have an if-else statement in those methods anyway.
2020-03-24 16:15:33 +01:00
Liav A
cb676f1211 Interrupts: Do a specific EOI when using the PIC
Before this change, we did a non-specific EOI, which could lead to
problems with other IRQs that are handled in the PIC. Since the original
8259A datasheet permits such functionality and we are not losing any
functionality, this change is acceptable even though we don't experience
problems with the EOI currently.
2020-03-24 16:15:33 +01:00
Liav A
06e7fc9dee Kernel: Limit IRQ rate within E1000 network adapter
This is not a complete fix, since spurious IRQs under heavy loads can
still occur. However, this fix limits the amount of spurious IRQs.

It is encouraged to provide a better fix in the future, probably
something that takes into account handling of PCI level-triggered
interrupts.
2020-03-24 16:15:33 +01:00
Liav A
dbc536e917 Interrupts: Assert if trying to install an handler on syscall vector
Installing an interrupt handler on the syscall IDT vector can lead to
fatal results, so we must assert if that happens.
2020-03-24 16:15:33 +01:00
Liav A
f86be46c98 Kernel: Abstract IRQ controller handling from Interrupt handlers
Now we don't send raw numbers, but we let the IRQController object to
figure out the correct IRQ number.
This helps in a situation when we have 2 or more IOAPICs, so if IOAPIC
1 is assigned for IRQs 0-23 and IOAPIC 2 is assigned for IRQs 24-47,
if an IRQHandler of IRQ 25 invokes disable() for example, it will call
his responsible IRQController (IOAPIC 2), and the IRQController will
subtract the IRQ number with his assigned offset, and the result is that
the second redirection entry in IOAPIC 2 will be masked.
2020-03-24 16:15:33 +01:00
Liav A
666990fbcb Kernel: Correct Spurious Interrupt handlers' controller model() method
We don't return blindly the IRQ controller's model(), if the Spurious
IRQ handler is installed in IOAPIC environment, it's misleading to
return "IOAPIC" string since IOAPIC doesn't really handle Spurious
IRQs, therefore we return a "" string.
2020-03-24 16:15:33 +01:00
Liav A
4cc96a7aa9 Kernel: Create an interface for conversion between IRQs and interrupts 2020-03-24 16:15:33 +01:00
Liav A
c2c0e9fb04 Kernel: Ensure that we don't use a hard-disabled IRQController 2020-03-24 16:15:33 +01:00
Liav A
893d4a41c2 Kernel: Enable IRQs before sending commands to the E1000 adapter
This change prevents a race condition, in which case we send a command
and we are losing an interrupt.
2020-03-24 16:15:33 +01:00
Liav A
7c859efa85 Kernel: Change the Spurious Interrupt Handler offset in the APIC
The Spurious Interrupt Handler number that is written to
APIC_REG_SIV is correct now.
2020-03-24 16:15:33 +01:00
Liav A
f7b207c7ae CPU: Move EOI call to the end of handle_interrupt() 2020-03-24 16:15:33 +01:00
Liav A
1bc7ba8df8 Kernel: Run QEMU machine with two virtual processors 2020-03-24 16:15:33 +01:00
Liav A
c55d5eeef9 Kernel: Change noacpi GRUB entry to use the right boot argument 2020-03-24 16:15:33 +01:00
Andreas Kling
7d862dd5fc AK: Reduce header dependency graph of String.h
String.h no longer pulls in StringView.h. We do this by moving a bunch
of String functions out-of-line.
2020-03-23 13:48:44 +01:00
Shannon Booth
c47ef61ed8 Toolchain/Ports: Update gcc to 9.3.0
Ever closer to C++20! Also fix up some of those pesky "'s
2020-03-23 08:22:41 +01:00
Andreas Kling
4f72f6b886 AK: Add FlyString, a simple flyweight string class
FlyString is a flyweight string class that wraps a RefPtr<StringImpl>
known to be unique among the set of FlyStrings. The class is very
unoptimized at the moment.

When to use FlyString:

- When you want O(1) string comparison
- When you want to deduplicate a lot of identical strings

When not to use FlyString:

- For strings that don't need either of the above features
- For strings that are likely to be unique
2020-03-22 13:03:43 +01:00
Shannon Booth
d7133ea326 Kernel: Fix compilation error with ACPI_DEBUG enabled 2020-03-22 08:51:40 +01:00
Shannon Booth
757c14650f Kernel: Simplify process assertion checking if region is in range
Let's use the helper function for this :)
2020-03-22 08:51:40 +01:00
Shannon Booth
81adefef27 Kernel: Run clang-format on files
Let's rip off the band-aid
2020-03-22 01:22:32 +01:00