Commit Graph

6342 Commits

Author SHA1 Message Date
Sergey Bugaev
064cd2278c Kernel: Remove the use of FileSystemPath in sys$realpath()
Now that VFS::resolve_path() canonicalizes paths automatically, we don't need to
do that here anymore.
2020-01-17 21:49:58 +01:00
Sergey Bugaev
68aeefa49b ProcFS: Implement symlink magic 2020-01-17 21:49:58 +01:00
Sergey Bugaev
8642a7046c Kernel: Let inodes provide pre-open file descriptions
Some magical inodes, such as /proc/pid/fd/fileno, are going to want to open() to
a custom FileDescription, so add a hook for that.
2020-01-17 21:49:58 +01:00
Sergey Bugaev
ae64fd1b27 Kernel: Let symlinks resolve themselves
Symlink resolution is now a virtual method on an inode,
Inode::resolve_as_symlink(). The default implementation just reads the stored
inode contents, treats them as a path and calls through to VFS::resolve_path().

This will let us support other, magical files that appear to be plain old
symlinks but resolve to something else. This is particularly useful for ProcFS.
2020-01-17 21:49:58 +01:00
Sergey Bugaev
e0013a6b4c Kernel+LibC: Unify sys$open() and sys$openat()
The syscall is now called sys$open(), but it behaves like the old sys$openat().
In userspace, open_with_path_length() is made a wrapper over openat_with_path_length().
2020-01-17 21:49:58 +01:00
Sergey Bugaev
d6184afcae Kernel: Simplify VFS::resolve_path() further
It turns out we don't even need to store the whole custody chain, as we only
ever access its last element. So we can just store one custody. This also fixes
a performance FIXME :^)

Also, rename parent_custody to out_parent.
2020-01-17 21:49:58 +01:00
Andreas Kling
4d4d5e1c07 Kernel: Drop futex queues/state on exec()
This state is not meaningful to the new process image so just drop it.
2020-01-17 16:08:00 +01:00
Andreas Kling
26a31c7efb Kernel: Add "accept" pledge promise for accepting incoming connections
This patch adds a new "accept" promise that allows you to call accept()
on an already listening socket. This lets programs set up a socket for
for listening and then dropping "inet" and/or "unix" so that only
incoming (and existing) connections are allowed from that point on.
No new outgoing connections or listening server sockets can be created.

In addition to accept() it also allows getsockopt() with SOL_SOCKET
and SO_PEERCRED, which is used to find the PID/UID/GID of the socket
peer. This is used by our IPC library when creating shared buffers that
should only be accessible to a specific peer process.

This allows us to drop "unix" in WindowServer and LookupServer. :^)

It also makes the debugging/introspection RPC sockets in CEventLoop
based programs work again.
2020-01-17 11:19:06 +01:00
Andreas Kling
a9b24ebbe8 Kernel: Reindent linker script 2020-01-17 11:07:02 +01:00
rhin123
0f3880ec4a Userland: Stop id command accepting -n in default format 2020-01-17 09:39:11 +01:00
Andreas Kling
c6e552ac8f Kernel+LibELF: Don't blindly trust ELF symbol offsets in symbolication
It was possible to craft a custom ELF executable that when symbolicated
would cause the kernel to read from user-controlled addresses anywhere
in memory. You could then fetch this memory via /proc/PID/stack

We fix this by making ELFImage hand out StringView rather than raw
const char* for symbol names. In case a symbol offset is outside the
ELF image, you get a null StringView. :^)

Test: Kernel/elf-symbolication-kernel-read-exploit.cpp
2020-01-16 22:11:31 +01:00
Andreas Kling
60143c8d4e LibC: Add strnlen() 2020-01-16 22:11:31 +01:00
joshua stein
376fece51e HackStudio: add exec pledge 2020-01-16 12:42:25 +01:00
joshua stein
d063a4ccf3 HackStudio: set sane $PATH early to include /usr/local/bin
Launching from the terminal inherits $PATH which includes
/usr/local/bin, but launching from the system menubar doesn't, so
HackStudio wasn't finding make installed from ports.
2020-01-16 12:42:25 +01:00
joshua stein
5c25983844 LibVT: enforce a minimum size of 1 column and 1 row
Fixes #829
2020-01-16 12:41:09 +01:00
Andreas Kling
d9385d7d62 SystemMonitor: Unbreak the memory stats graph
It was never updating because we'd just seek the start of /proc/memstat
over and over, which didn't generate new contents. Instead, open the
file on every iteration.
2020-01-15 23:14:20 +01:00
Andreas Kling
806f19d647 run: Bump default RAM size from 128 MB to 256 MB 2020-01-15 23:14:20 +01:00
joshua stein
d7e8431cdb Userland/ls: escape non-printable characters
Fixes #1044
2020-01-15 23:13:15 +01:00
joshua stein
24b8a27190 LibVT: only use default bold font if it's the same size as our font
When the new font is a different size, just use that font for bold
glyphs as well.  It would be nice to find a matching bold version of
the new font automatically in the future.
2020-01-15 22:30:34 +01:00
Andreas Kling
d4d17ce423 Kernel: Trying to sys$link() a directory should fail with EPERM 2020-01-15 22:11:44 +01:00
Andreas Kling
e91f03cb39 Ext2FS: Assert that inline symlink read/write always uses offset=0 2020-01-15 22:11:44 +01:00
Andreas Kling
5a13a5416e Kernel: Avoid an extra call to read_bytes() in Inode::read_entire()
If we slurp up the entire inode in a single read_bytes(), no need to
call read_bytes() again.
2020-01-15 22:11:44 +01:00
Andreas Kling
09fd59a1b5 LibC: Add INADDR_LOOPBACK 2020-01-15 22:11:44 +01:00
Andreas Kling
9e54c7c17f Ext2FS: Don't allow creating new files in removed directories
Also don't uncache inodes when they reach i_links_count==0 unless they
also have no ref counts other than the +1 from the inode cache.
This prevents the FS from deleting the on-disk inode too soon.
2020-01-15 22:11:44 +01:00
joshua stein
0fa38e4a4a Build: use $SUDO_[UG]ID in build-image-* instead of relying on makeall 2020-01-15 21:52:09 +01:00
joshua stein
c6c7e40bd1 Build: more IPCCompiler-generated dependencies 2020-01-15 21:52:09 +01:00
Andreas Kling
d79de38bd2 Kernel: Don't allow userspace to sys$open() literal symlinks
The O_NOFOLLOW_NOERROR is an internal kernel mechanism used for the
implementation of sys$readlink() and sys$lstat().

There is no reason to allow userspace to open symlinks directly.
2020-01-15 21:19:26 +01:00
Andreas Kling
e23536d682 Kernel: Use Vector::unstable_remove() in a couple of places 2020-01-15 19:26:41 +01:00
Andreas Kling
575664cda3 AK: Add Vector::unstable_remove(index)
This removes an item at an index without preserving the sort order of
the Vector.

This enables constant-time removal from unsorted Vectors, as it avoids
shifting all of the entries following the removed one.
2020-01-15 19:25:58 +01:00
Emanuel Sprung
542098d90d Build: Fix helloworld2's form compiler dependency 2020-01-15 09:39:44 +01:00
Shannon Booth
e455b1095a WindowServer: Do not open system menu after window tiling 2020-01-15 09:38:43 +01:00
Liav A
bd3b64efb7 Kernel: Fix run script to enable networking on Q35 machines
Also, we enable KVM to accelerate the execution when booting with
q35_cmd or qcmd options in the run script.
2020-01-14 15:38:58 +01:00
Liav A
2da8aba48d Kernel: Change ACPI & DMI definitions a bit
Structures declarations changed __attribute__((__packed__))
to [[gnu::packed]] in ACPI & DMI definitions.
Also, declarations of array of pointers in ACPI RSDT/XSDT are correct
now. In addition to that, now we have a declaration of the ACPI MADT
table & the table entries.
2020-01-14 15:38:58 +01:00
Liav A
c2ef7f740b Kernel: Move DMI decoder initialization method to init_stage2
Also, PCI Initializer dismiss() now deletes the object correctly, and
the PCI initialization process no longer use the DMI decoder to
determine if PCI is supported.
grub configuration files include an entry to boot the OS without
ACPI support.
2020-01-14 15:38:58 +01:00
Liav A
918097ae94 Kernel: Fixing E1000 MMIO access
Now E1000 driver no longer use identity-mapping to do IO operations.
Also, print messages were fixed, and debug messages were added for IO
methods.
2020-01-14 15:38:58 +01:00
Liav A
a9884fbbe5 Kernel: Remove problematic memory mapping methods
mmap() & mmap_region() methods are removed from ACPI & DMI components,
and we replace them with the new MM.allocate_kernel_region() helper.

Instead of doing a raw calculation for each VM address, from now on we
can use helper functions to do perform those calculations in a neat,
reusable and readable way.
2020-01-14 15:38:58 +01:00
Liav A
d2b41010c5 Kernel: Change Region allocation helpers
We now can create a cacheable Region, so when map() is called, if a
Region is cacheable then all the virtual memory space being allocated
to it will be marked as not cache disabled.

In addition to that, OS components can create a Region that will be
mapped to a specific physical address by using the appropriate helper
method.
2020-01-14 15:38:58 +01:00
Sergey Bugaev
b913e30011 Kernel: Refactor/rewrite VFS::resolve_path()
This makes the implementation easier to follow, but also fixes multiple issues
with the old implementation. In particular, it now deals properly with . and ..
in paths, including around mount points.

Hopefully there aren't many new bugs this introduces :^)
2020-01-14 12:24:19 +01:00
Sergey Bugaev
499612482b AK: Fix String[View]::split_view() returning an extra empty part
If the last character was the separator and keep_empty is true, the
previous if statement would have already appended the last empty part,
so no need to do this again.

This was even more problematic, because the result of split_view() is
expected to consist of true substrings that are usable with the
StringView::substring_view_starting_*_substring() methods, not of
equal strings located elsewhere.

Fixes https://github.com/SerenityOS/serenity/issues/970
See https://github.com/SerenityOS/serenity/pull/938
2020-01-14 12:24:19 +01:00
Sergey Bugaev
7ad9bfbc68 AK: Don't return null from String[View]::substring_view()
We expect the result to be usable with the
StringView::substring_view_starting_*_substring() methods.

See https://github.com/SerenityOS/serenity/pull/938
2020-01-14 12:24:19 +01:00
Brian Gianforcaro
b553a86048 man: Fix minor inconsistencies in pledge(2) man page
- tty promise was listed twice.

- Fix a few typos
2020-01-14 08:00:35 +01:00
Andreas Kling
fd64e97c8a LibDraw+LibHTML: Make link colors themeable
Add "Link", "ActiveLink" and "VisitedLink" colors to the system theme
definition, and implement support for them in LibHTML.

Note that <body link="foo" alink="bar" vlink="baz"> takes precedence
over the system colors. Author style also takes precedence, since we
only fetch the system color in case the CSS color is -libhtml-link.
2020-01-13 20:33:15 +01:00
Andreas Kling
3b2f20ed4d LibM: Implement some naive functionality to make VVVVVV run 2020-01-13 19:01:44 +01:00
Andreas Kling
65cb406327 Kernel: Allow unlocking a held Lock with interrupts disabled
This is needed to eliminate a race in Thread::wait_on() where we'd
otherwise have to wait until after unlocking the process lock before
we can disable interrupts.
2020-01-13 18:56:46 +01:00
DrewStratford
2a8de4cdec LibCore: Fix segfault in CArgsParser (#1072)
CArgsParser::parse_next_param did not properly ensure that, when
a param required a following argument, there were enough parameters left to
complete the parse. This meant that params_left could become negative,
avoiding parse_next_param's termination condition, and cause a segfault
when reading from argv with an out of bounds index.

This fixes the check to ensure that we do in fact have the right amount
of parameters and also adds an assertion to ensure that params_left does
not become negative.
2020-01-13 14:52:25 +01:00
Andreas Kling
ad5ee27ea9 mv: Use pledge() 2020-01-13 14:51:35 +01:00
Andreas Kling
8ccc2b25c2 cp: Use pledge() 2020-01-13 14:51:18 +01:00
Andreas Kling
56428e764e Applications: Use pledge()
Add some basic pledges to the following apps:

- Calculator
- DisplayProperties
- FontEditor
- HexEditor
- PaintBrush
2020-01-13 14:41:15 +01:00
Andreas Kling
6182a1a71c About: Drop "unix" pledge after connecting to WindowServer 2020-01-13 14:41:15 +01:00
Andreas Kling
6f89557ffc WindowServer: Add "thread" pledge since we need it for wallpapers
Longer-term we should come up with a design where WindowServer doesn't
have to decode untrusted image files.
2020-01-13 14:41:15 +01:00