Commit graph

15007 commits

Author SHA1 Message Date
Dan MacDonald 277c44c2dc Meta: Update install guide with link to hardware compatibility list 2020-12-24 11:02:43 +01:00
Lenny Maiorani e4ce485309 CMake: Decouple cmake utility functions from top-level CMakeLists.txt
Problem:
- These utility functions are only used in `AK`, but are being defined
  in the top-level. This clutters the top-level.

Solution:
- Move the utility functions to `Meta/CMake/utils.cmake` and include
  where needed.
- Also, move `all_the_debug_macros.cmake` into `Meta/CMake` directory
  to consolidate the location of `*.cmake` script files.
2020-12-24 11:02:04 +01:00
Andreas Kling 6db224f020 Meta: Add Brendan Coles to the contributors list :^) 2020-12-24 10:47:36 +01:00
Brendan Coles b156c5a8eb ProcFS: pid_vm: Replace duplicated purgeable key with kernel+cacheable
ProcFS /proc/<pid>/vm map info no longer contains two `purgeable` keys.

The second `purgeable` key has been removed and replaced with keys for
`kernel` and `cacheable`.
2020-12-24 10:26:39 +01:00
Linus Groh 0729c8ed65 LaunchServer: Ignore empty FileType / Protocol / [Launcher] config values
"Foo=" should be treated the same as "Foo" being missing.
2020-12-24 10:25:18 +01:00
Linus Groh bed240d4b3 LaunchServer+Base: Stop using Browser as default protocol handler
Browser supports very few protocols (http, https, gemini, file) at the
moment, so there's no point in using it as a catch-all and default
protocol handler. I added an explicit association for gemini to
/bin/Browser instead.

This stops Desktop::Launcher::open() from reporting success for any URL,
which really isn't the case (Browser shows an error page...).
2020-12-24 10:25:18 +01:00
Linus Groh af007ce126 open: Mention full URL in 'Failed to open' error message
Just showing the URL's path is confusing, that would show '/' for
something like foo://bar.
2020-12-24 10:25:18 +01:00
Linus Groh 5bb0bd8c6d open: Handle file:// URLs properly
open(1) was able to handle most URLs as well as paths, but not file://
URLs (which occur when dragging something from the output of ls, for
example). We have to create an URL from the user-supplied argument using
create_with_url_or_path(), check whether it's a file:// URL or not and
*then* use real_path_for() on the URL's path().
2020-12-24 10:25:18 +01:00
Linus Groh 46a12e32d3 open: Remove extraneous newline from error output
This wasn't removed when fprintf was replaced by warnln.
2020-12-24 10:25:18 +01:00
Lenny Maiorani 8e1af483be CMake: Remove file globbing in AK/Tests
Problem:
- File globbing is performed at the time of build system
  generation. Any files which are not there at that time are not
  included. So, when a new file is added it is not built unless the
  build system is recreated.

Solution:
- Remove globbing from AK/Tests directory in favor of explicitly
  listing the files.
2020-12-23 20:51:29 +01:00
Andreas Kling 51713901b1 Kernel: Tweak parameter name in Inode::read_entire()
This is a descriptION, not a descriptOR. :^)
2020-12-23 20:36:14 +01:00
Andreas Kling 1e21d49e86 Kernel: Fix wrong-looking overflow check in sys$execve()
This was harmless since sizeof(length) and sizeof(strings) are both 4
on x86 but let's check the right things regardless.
2020-12-23 20:34:22 +01:00
Andreas Kling c6a0694f50 Kernel: Don't assert when reading from a listening-mode local socket
Instead just fail with EINVAL as a listening socket is never suitable
for reading from.

Fixes #4511.
2020-12-23 20:25:29 +01:00
Andreas Kling 80ae407d73 LibGfx: Always compute the DIB mask shifts and sizes if needed
The pixel decoding logic later on assumes that if we have DIB masks,
we also have shifts and sizes, so we should make sure they are
always computed.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28237
2020-12-23 20:16:53 +01:00
Andreas Kling cd046fae44 LibGfx: Fail JPEG decode instead of asserting on bogus start-of-scan
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28628
2020-12-23 19:22:15 +01:00
Andreas Kling 0fc8561029 LibGfx: Catch integer overflows in PNG decoder and fail the decode
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28134&sort=reported&q=serenity
2020-12-23 19:04:12 +01:00
Andreas Kling 491a5f5e34 LibGfx: Avoid a ByteBuffer heap allocation in PNG filtering 2020-12-23 18:06:25 +01:00
Andreas Kling 068615fe5e LibGfx: Reject PNG files with invalid filter/interlace methods
Might as well reject these when parsing the IHDR chunk instead of
continuing to load something invalid.
2020-12-23 15:45:59 +01:00
Andreas Kling 5f182746b6 LibCore: Stop logging that a Core::Socket has disconnected in receive()
This is perfectly normal and nothing we need to inform about.
2020-12-23 15:45:59 +01:00
Xavier Cooney 5f58fe1643 Spreadsheet: Prompt user before closing with unsaved changes 2020-12-23 15:41:49 +01:00
Andreas Kling 23febb9d8e Kernel: Ptrace::handle_syscall() should return errors as KResult 2020-12-23 14:55:24 +01:00
Andreas Kling eaa63fdda5 Kernel: Don't assert on PT_PEEK with kernelspace address
We were casting the address to Userspace<T> without validating it first
which is no good and will trap an assertion soon after.

Let's catch this sooner with an ASSERT in the Userspace<T> constructor
and update the PT_PEEK and PT_POKE handlers to avoid it.

Fixes #4505.
2020-12-23 14:50:20 +01:00
Andreas Kling c25cf5fb56 Kernel: Panic if we're about to switch to a user thread with IOPL!=0
This is a crude protection against IOPL elevation attacks. If for
any reason we find ourselves about to switch to a user mode thread
with IOPL != 0, we'll now simply panic the kernel.

If this happens, it basically means that something tricked the kernel
into incorrectly modifying the IOPL of a thread, so it's no longer
safe to trust the kernel anyway.
2020-12-23 14:30:10 +01:00
Linus Groh 488a613858 TextEditor: Rename {Main => TextEditor}Window.gml
Calling the file MainWindow.gml (and subsequently using MainWindowGML.h
for the generated file's name) suggests that's possible for every
application, but having a second one anywhere results in the following
CMake error:

    add_custom_target cannot create target "generate_MainWindowGML.h"
    because another target with the same name already exists. The
    existing target is a custom target created in source directory [...]

It's now also more consistent with the other applications already using
GML, namely "BrowserWindow.gml" and "FileManagerWindow.gml".
2020-12-23 01:33:43 +01:00
Andreas Kling 8653128ca8 cp: Don't copy the set-uid or set-gid bits
Also simplify the file copying logic a bit to avoid two syscalls
per file. We now create the file with the right mode right away
instead of creating it first, and then fchmod'ing it later.

Fixes #4479.
2020-12-23 01:03:32 +01:00
Andreas Kling 75da835ffb LibDebug: Allow DWARF compilation unit header version <= 4
I think this is okay, the main thing to protect against is new versions
of the format that we don't know about yet.

This happens because an .S file compiled into libc.so has version 2
instead of version 4 like everything else.

Fixes #4491.
2020-12-23 00:53:27 +01:00
Andreas Kling c77dda6827 Kernel: Make KBuffer::try_create_with_bytes() actually copy the bytes
KBuffers created with this API were actually just zero-filled instead
of being populated with the provided bytes.

Fixes #4493.
2020-12-23 00:40:11 +01:00
Tom 99d6b3b80b Chess: Use the hourglass cursor while waiting for the ChessEngine 2020-12-22 23:37:25 +01:00
Érico Nogueira Rolim a8f0e489a4
LibCore: Rename identifiers that can clash with libc macros (#4127)
POSIX allows the default streams (stdin, stdout and stderr) to be
macros, which means that on such systems (musl libc is one) building
Lagom will fail due to the File::std*() names.

Also fix any files that use these identifiers.
2020-12-22 23:37:11 +01:00
Alex McGrath abc98dea09 FileManager: Allow creating desktop shortcut from FileManager 2020-12-22 23:35:41 +01:00
AnotherTest ca2e7b6746 Spreadsheet: Fix invalid check in SheetGlobalObject::column_index() 2020-12-22 23:35:29 +01:00
AnotherTest 8f05e4e765 Spreadsheet: Improve sheet update efficiency
There's no need to leave the cell dirty when not updating it, and
there's definitely no need to update the cells as we're selecting them.
This makes navigating a sheet and selecting cells significantly faster
as we no longer update unrelated cells just because they appear to have
a cyclic update dependency :^)
2020-12-22 23:35:29 +01:00
AnotherTest bfb25855cb Spreadsheet: Do not attempt to create columns with "negative" indices 2020-12-22 23:35:29 +01:00
AnotherTest 7c8d35600c Spreadsheet: Override visit_edges() and visit stored JS objects
...and don't let them leak out of their evaluation contexts.
Also keep the exceptions separate from the actual values.
This greatly reduces the number of assertions hit while entering random
data into a sheet.
2020-12-22 23:35:29 +01:00
AnotherTest b3a9a25416 Spreadsheet: Make it possible to rename sheets 2020-12-22 23:35:29 +01:00
AnotherTest f1f9fd1c60 Spreadsheet: struct Cell => class Cell
Hide private members, and make the odd update() -> sheet->update(cell)
-> update(Badge<Sheet>) -> update_data() less odd by removing the
update(Badge<Sheet>) step.
2020-12-22 23:35:29 +01:00
AnotherTest 28428beb5c Spreadsheet: Accept (and ignore) invalid 'columns' in json
The save functionality omits these when the names are standard, so just
ignore them if they don't exist (or are not valid).
2020-12-22 23:35:29 +01:00
Brendan Coles e8e8d3caf5 LibC: __generate_unique_filename(): Replace rand() with arc4random()
LibC stdlib `arc4random()` uses the `getrandom` system call which
uses `KernelRng::get_good_random_bytes`.

This ensures that filenames generated using functions such as
`mkstemp()` are suitably randomised and are no longer predictable.
2020-12-22 23:25:26 +01:00
Lenny Maiorani cef6b7b2e4 CMake: Use built-in add_compile_definitions for *_DEBUG macros
Problem:
- Modifying CXXFLAGS directly is an old CMake style.
- The giant and ever-growing list of `*_DEBUG` macros clutters the
  top-level CMakeLists.txt.

Solution:
- Use the more current `add_compile_definitions` function.
- Sort all the debug options so that they are easy to view.
- Move the `*_DEBUG` macros to their own file which can be included
  directly.
2020-12-22 21:01:51 +01:00
Ben Wiederhake 32210802ac Meta: Use the correct clang-format
After all the work of determining the correct name for clang-format-10,
we forgot to actually use it. How silly!
2020-12-22 20:41:35 +01:00
Andreas Kling 6bfbc5f5f5 Kernel: Don't allow modifying IOPL via sys$ptrace() or sys$sigreturn()
It was possible to overwrite the entire EFLAGS register since we didn't
do any masking in the ptrace and sigreturn syscalls.

This made it trivial to gain IO privileges by raising IOPL to 3 and
then you could talk to hardware to do all kinds of nasty things.

Thanks to @allesctf for finding these issues! :^)

Their exploit/write-up: https://github.com/allesctf/writeups/blob/master/2020/hxpctf/wisdom2/writeup.md
2020-12-22 19:38:25 +01:00
Andreas Kling b452dd13b6 Kernel: Allow sys$chmod() to modify the set-gid bit
We were incorrectly masking off the set-gid bit.

Fixes #4060.
2020-12-22 17:48:42 +01:00
Luke 72ce4abb99 Kernel/Net: Support all E1000 devices in the spec sheet
Since they're all covered by the same spec sheet, we can expect
the same code to cover most of the devices.

It can't currently differentiate between them, which would be nice to
add for determining what registers we can access.
2020-12-22 14:44:11 +01:00
Andreas Kling 2dfe5751f3 Kernel: Abort core dump generation if any substep fails
And make an effort to propagate errors out from the inner parts.
This fixes an issue where the kernel would infinitely loop in coredump
generation if the TmpFS filled up.
2020-12-22 10:09:41 +01:00
Andreas Kling 531c3fe72e LibGfx: Fix OOB access in GIF deinterlacing
It was possible to go outside the interlacing row strid/offset arrays.
Just fail the decode if this is about to happen. I've added a FIXME
about rejecting such images earlier, since it's a bit sad to only do
this once we realize the pass index is about to overflow.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28239
2020-12-22 10:09:41 +01:00
Luke 69d7a34bc2 Kernel/PCI: Add a bunch of debug output to accessors
This was useful for debugging this issue.
2020-12-22 09:24:48 +01:00
Luke 9ab9e548f4 Kernel/PCI: Create device configuration space mapping before creating a physical ID
When enumerating the hardware using MMIO mode, it would attempt to
create a physical ID first. To create a physical ID, it needs to
retrieve the capabilities of the device.

When enumerating the first device, there would be no device
configuration space mappings. Access::get_capabilities_pointer
calls PCI::read16, which in turn goes to MMIOAccess::read16_field.

MMIOAccess::read16_field attempts to get a device configuration space
and fully expects to get one. However, since this is the first device,
there are none and it crashes with an m_has_value assertion failure.

This fixes this by creating the device configuration space mapping
before creating the physical ID.

Testing with VMware Player 16.1.0.
2020-12-22 09:24:48 +01:00
Lenny Maiorani a95d230a3e LibGfx: Commonize functions in P*MLoader class implementations
Problem:
- Functions are duplicated in [PBM,PGM,PPM]Loader class
  implementations. They are functionally equivalent. This does not
  follow the DRY (Don't Repeat Yourself) principle.

Solution:
- Factor out the common functions into a separate file.
- Refactor common code to generic functions.
- Change `PPM_DEBUG` macro to be `PORTABLE_IMAGE_LOADER_DEBUG` to work
  with all the supported types. This requires adding the image type to
  the debug log messages for easier debugging.
2020-12-22 09:24:12 +01:00
Lenny Maiorani 6fac1abac4 CMake: Use add_compile_options instead of appending to CMAKE_CXX_FLAGS
Problem:
- Appending to CMAKE_CXX_FLAGS for everything is cumbersome.

Solution:
- Use the `add_compile_options` built-in function to handle adding
  compiler options (and even de-duplicating).
2020-12-22 09:22:04 +01:00
Lenny Maiorani ded0b5a93c CMake: Set C++20 mode in canonical cmake
Problem:
- Setting `CMAKE_CXX_FLAGS` directly to effect the version of the C++
  standard being used is no longer the recommended best practice.

Solution:
- Set C++20 mode in the compiler by setting `CMAKE_CXX_STANDARD`.
- Force the build system generator not to fallback to the latest
  standard supported by the compiler by enabling
  `CMAKE_CXX_STANDARD_REQUIRED`. This shouldn't ever be a problem
  though since the toolchain is tightly controlled.
- Disable GNU compiler extensions by disabling `CMAKE_CXX_EXTENSIONS`
  to preserve the previous flags.
2020-12-22 09:22:04 +01:00