summaryrefslogtreecommitdiff
path: root/Kernel
AgeCommit message (Collapse)Author
2021-05-07Kernel: Allow Ext2FSInode::write_bytes calls with a byte count of zeroMart G
write_bytes is called with a count of 0 bytes if a directory is being deleted, because in that case even the . and .. pseudo directories are getting removed. In this case write_bytes is now a no-op. Before write_bytes would fail because it would check to see if there were any blocks available to write in (even though it wasn't going to write in them anyway). This behaviour was uncovered because of a recent change where directories are correctly reduced in size. Which in this case results in all the blocks being removed from the inode, whereas previously there would be some stale blocks around to pass the check.
2021-05-07Kernel: Set unused block pointers in ext2 inodes to zeroMart G
e2fsck considers all blocks reachable through any of the pointers in m_raw_inode.i_block as part of this inode regardless of the value in m_raw_inode.i_size. When it finds more blocks than the amount that is indicated by i_size or i_blocks it offers to repair the filesystem by changing those values. That will actually cause further corruption. So we must zero all pointers to blocks that are now unused.
2021-05-07Kernel: Limit the number of in-flight packet buffersGunnar Beutner
This fixes an OOM when hitting the VM with lots of UDP packets. fixes #6907
2021-05-07Kernel: Move cpu sample perf event to PerformanceManagerBrian Gianforcaro
2021-05-07Kernel: Move process exit perf events to PerformanceManagerBrian Gianforcaro
2021-05-07Kernel: Move process creation perf events to PerformanceManagerBrian Gianforcaro
2021-05-07Kernel: Add PerformanceManager static class, move perf event APIs thereBrian Gianforcaro
The current method of emitting performance events requires a bit of boiler plate at every invocation, as well as having to ignore the return code which isn't used outside of the perf event syscall. This change attempts to clean that up by exposing high level API's that can be used around the code base.
2021-05-06Kernel: Resize Ext2FSInode when writing directory contents (#6897)Mart G
Ext2 directory contents are stored in a linked list of ext2_dir_entry structs. There is no sentinel value to determine where the list ends. Instead the list fills the entirety of the allocated space for the inode. Previously the inode was not correctly resized when it became smaller. This resulted in stale data being interpreted as part of the linked list of directory entries.
2021-05-06Kernel: Truncate UDP packets on readGunnar Beutner
When reading UDP packets from userspace with recvmsg()/recv() we would hit a VERIFY() if the supplied buffer is smaller than the received UDP packet. Instead we should just return truncated data to the caller. This can be reproduced with: $ dd if=/dev/zero bs=1k count=1 | nc -u 192.168.3.190 68
2021-05-05Kernel: Allow remapping Caps Lock to Control (#6883)Spencer Dixon
We use a global setting to determine if Caps Lock should be remapped to Control because we don't care how keyboard events come in, just that they should be massaged into different scan codes. The `proc` filesystem is able to manipulate this global variable using the `sysctl` utility like so: ``` # sysctl caps_lock_to_ctrl=1 ```
2021-05-05Kernel: Implement IP multicast supportSergey Bugaev
An IP socket can now join a multicast group by using the IP_ADD_MEMBERSHIP sockopt, which will cause it to start receiving packets sent to the multicast address, even though this address does not belong to this host.
2021-05-05Kernel: Fix `write`s to `ProcFS` (#6879)Spencer Dixon
When using `sysctl` you can enable/disable values by writing to the ProcFS. Some drift must have occured where writing was failing due to a missing `set_mtime` call. Whenever one `write`'s a file the modified time (mtime) will be updated so we need to implement this interface in ProcFS.
2021-05-05Kernel: Modify TimeManagement::current_time(..) API so it can't fail. (#6869)Brian Gianforcaro
The fact that current_time can "fail" makes its use a bit awkward. All callers in the Kernel are trusted besides syscalls, so assert that they never get there, and make sure all current callers perform validation of the clock_id with TimeManagement::is_valid_clock_id(). I have fuzzed this change locally for a bit to make sure I didn't miss any obvious regression.
2021-05-05Kernel: Add Processor::is_bootstrap_processor() function, and use it. (#6871)Brian Gianforcaro
The variety of checks for Processor::id() == 0 could use some assistance in the readability department. This change adds a new function to represent this check, and replaces the comparison everywhere it's used.
2021-05-05Kernel: Remove shadowing member variable from FileDescriptionBlockerTom
FileDescriptionBlocker::m_should_block was shadowing the parent's FileBlocker::m_should_block variable, which would cause should_block() to return the wrong value. Found by @gunnarbeutner
2021-05-04Kernel: Store whether a thread is the idle thread in Thread directlyTom
This solves a problem where checking whether a thread is an idle thread may require iterating all processors if it is not the idle thread of the current processor.
2021-05-04Kernel: Return one kernel frame from procfs$tid_stack for normal users.Brian Gianforcaro
Previously we would return a 0xdeadc0de frame for every kernel frame in the real kernel stack when an non super-user issued the request. This isn't useful, and just produces visual clutter in tools which attempt to symbolize stacks.
2021-05-04Kernel: Remove unused function ProcFS::add_sys_stringBrian Gianforcaro
2021-05-04Kernel: Remove unused header includes from ProcFS.cppBrian Gianforcaro
2021-05-03Kernel: Remove unused header includes from various files.Brian Gianforcaro
Found while browsing code with CLion.
2021-05-03Kernel: Mark AsyncBlockDeviceRequest + AnonymousVMObject as finalBrian Gianforcaro
Mark final to aid in de-virtualization since they are not currently derived from.
2021-05-03Kernel: Fix some 64-bit portability issuesGunnar Beutner
2021-05-02Kernel: Fix ProcFS for non-process backed sub dirsSpencer Dixon
While hacking on `sysctl` an issue in ProcFS was making me unable to read/write from `/proc/sys/XXX`. Some directories in the ProcFS are not actually backed by a process and need to return `nullptr` so callbacks get properly set. We now do an explicit check for the parent to ensure it's one that is PID-based.
2021-05-02Kernel: Remove outdated UBSan commentsHendiadyoin1
The triple-fault issue has long been fixed
2021-05-02Kernel: Change Inode::{read/write}_bytes interface to KResultOr<ssize_t>Brian Gianforcaro
The error handling in all these cases was still using the old style negative values to indicate errors. We have a nicer solution for this now with KResultOr<T>. This change switches the interface and then all implementers to use the new style.
2021-05-01Kernel: Don't use ref_count() in MasterPTY::close()Gunnar Beutner
With the recent fixes to how close() gets called this is not necessary anymore.
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-05-01Kernel: Handle both shift keys being pressed and then releasedIdan Horowitz
Our current implementation does not work in the special case in which both shift keys are pressed, and then only one of the keys is released, as this would result in writing lower case letters, instead of the expected upper case letters. This commit fixes that by keeping track of the amount of shift keys that are pressed (instead of if any are at all), and only switching to the unshifted keymap once all of them are released.
2021-05-01Kernel: Make processes start with a 16-byte-aligned stackSahan Fernando
2021-05-01Kernel: Make sure we read all packetsGunnar Beutner
The previous patch already helped with this, however my idea of only reading a few packets didn't work and we'd still sometimes end up not receiving any more packets from the E1000 interface. With this patch applied my NIC seems to receive packets just fine, at least for now.
2021-05-01Kernel: Expose minor device numbers for keyboard and mouseValtteri Koskivuori
A fix for two FIXMEs, and paving the way for multi-keyboard/mouse support, I guess.
2021-05-01Kernel: Harden Ext2FileSystem Vector usage against OOM.Brian Gianforcaro
2021-05-01Kernel: Harden Process Vector usage against OOM.Brian Gianforcaro
2021-05-01Kernel: Harden DevFS Vector usage against OOM.Brian Gianforcaro
The dance here is not complicated, but it is something that should be taken note of. Since we append to both lists, we don't want to orphan the new Inode in the m_links/m_subfolders Vector in the event that the append to m_parent_fs.m_nodes fails.
2021-05-01Kernel: Harden sys$setgroups Vector usage against OOMBrian Gianforcaro
2021-05-01Kernel: Harden Socket Vector usage against OOMBrian Gianforcaro
2021-05-01Kernel: Harden LocalSocket Vector usage against OOM.Brian Gianforcaro
2021-05-01Kernel/IPv4: Unbreak raw socket (port allocation failing is OK)Andreas Kling
Raw sockets don't need a local port, so we shouldn't fail operations if allocation yields an ENOPROTOOPT. I'm not in love with the factoring here, just patching up the bug.
2021-04-30Kernel: Tear down connections when we receive an RST packetGunnar Beutner
2021-04-30Kernel: Record MAC addresses for incoming IPv4 packetsGunnar Beutner
This way we don't have to do ARP just to send packets back to an address which just sent us a packet.
2021-04-30Kernel: Remove socket from the listener's accept list when it is closedGunnar Beutner
Without this patch we end up with sockets in the listener's accept queue with state 'closed' when doing stealth SYN scans: Client -> Server: SYN for port 22 Server -> Client: SYN/ACK Client -> Server: RST (i.e. don't complete the TCP handshake)
2021-04-30Kernel: Don't put closed/listener sockets into the closing_sockets listGunnar Beutner
2021-04-30Kernel: Avoid deadlock when trying to send packets from the NetworkTaskGunnar Beutner
fixes #6758
2021-04-30Kernel: chmod()/chown() for PTYs should return EROFSGunnar Beutner
All the other methods already do this and this is also what OpenSSH expects when trying to change modes/ownership for devpts files.
2021-04-30Kernel: Implement support for PTY flags ICRNL, OPOST and ONLCRGunnar Beutner
These are used by OpenSSH. Without those flags new-lines are all jumbled in the output.
2021-04-30Kernel+LibELF: Support initializing values of TLS dataItamar
Previously, TLS data was always zero-initialized. To support initializing the values of TLS data, sys$allocate_tls now receives a buffer with the desired initial data, and copies it to the master TLS region of the process. The DynamicLinker gathers the initial TLS image and passes it to sys$allocate_tls. We also now require the size passed to sys$allocate_tls to be page-aligned, to make things easier. Note that this doesn't waste memory as the TLS data has to be allocated in separate pages anyway.
2021-04-30Kernel: Give a name to the Master TLS region allocationItamar
2021-04-30Kernel: Make Inode::set_{a,c,m}time return KResultAndreas Kling
This exposed some missing error propagation, which this patch also takes care of.
2021-04-30Kernel: Fix bogus error codes from raw socket protocol_{send,receive}Andreas Kling
Since these return KResultOr, we should not negate the error code.
2021-04-30Kernel/IPv4: Propagate errors from local port allocationAndreas Kling
Remove hacks and assumptions and make the EADDRINUSE propagate all the way from the point of failure to the syscall layer.