summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
AgeCommit message (Collapse)Author
2021-02-15Meta: Make it possible to (somewhat) build the system inside SerenityAnotherTest
This removes some hard references to the toolchain, some unnecessary uses of an external install command, and disables a -Werror flag (for the time being) - only if run inside serenity. With this, we can build and link the kernel :^)
2021-02-15CMake: Add 'setup-and-run' target to perform all prereqs and run the imageBrian Gianforcaro
Running 'ninja install && ninja image && ninja run` is kind of annoying. I got tired, and came up with this instead, which does the right thing and I don't have to type out the incantation.
2021-02-15Kernel: Initial integration of Kernel Address Sanitizer (KASAN)Brian Gianforcaro
KASAN is a dynamic analysis tool that finds memory errors. It focuses mostly on finding use-after-free and out-of-bound read/writes bugs. KASAN works by allocating a "shadow memory" region which is used to store whether each byte of memory is safe to access. The compiler then instruments the kernel code and a check is inserted which validates the state of the shadow memory region on every memory access (load or store). To fully integrate KASAN into the SerenityOS kernel we need to: a) Implement the KASAN interface to intercept the injected loads/stores. void __asan_load*(address); void __asan_store(address); b) Setup KASAN region and determine the shadow memory offset + translation. This might be challenging since Serenity is only 32bit at this time. Ex: Linux implements kernel address -> shadow address translation like: static inline void *kasan_mem_to_shadow(const void *addr) { return ((unsigned long)addr >> KASAN_SHADOW_SCALE_SHIFT) + KASAN_SHADOW_OFFSET; } c) Integrating KASAN with Kernel allocators. The kernel allocators need to be taught how to record allocation state in the shadow memory region. This commit only implements the initial steps of this long process: - A new (default OFF) CMake build flag `ENABLE_KERNEL_ADDRESS_SANITIZER` - Stubs out enough of the KASAN interface to allow the Kernel to link clean. Currently the KASAN kernel crashes on boot (triple fault because of the crash in strlen other sanitizer are seeing) but the goal here is to just get started, and this should help others jump in and continue making progress on KASAN. References: * ASAN Paper: https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37752.pdf * KASAN Docs: https://github.com/google/kasan * NetBSD KASAN Blog: https://blog.netbsd.org/tnf/entry/kernel_address_sanitizer_part_3 * LWN KASAN Article: https://lwn.net/Articles/612153/ * Tracking Issue #5351
2021-02-08Build: Allow setting DBGLN_NO_COMPILETIME_FORMAT_CHECK via CMake flagAndreas Kling
2021-02-07Base: Remove /res/pci.ids and download at build time insteadLinus Groh
This is an external file from https://pci-ids.ucw.cz that's being updated daily, which was imported a while ago but probably shouldn't live in the SerenityOS repository in the first place (or else would need manual maintenance). The legal aspects of redistributing this file as we currently do are not quite clear to me, they require either GPL (version 2 or later) or 3-clause BSD - Serenity is 2-clause BSD... The current version we use is 2019.08.08, so quite outdated - and while most of these devices are obviously not supported, we're still capable of *listing* them, so having an up-to-date version with recent additions and fixes would be nice. This updates the root CMakeLists.txt to check for existence of the file and download it if not found - effectively on every fresh build. Do note that this is not a critical file, and the system runs just fine should this ever fail. :^)
2021-02-05Userland: Add LibSystem and funnel all syscalls through itAndreas Kling
This achieves two things: - Programs can now intentionally perform arbitrary syscalls by calling syscall(). This allows us to work on things like syscall fuzzing. - It restricts the ability of userspace to make syscalls to a single 4KB page of code. In order to call the kernel directly, an attacker must now locate this page and call through it.
2021-01-26Meta: Split debug defines into multiple headers.asynts
The following script was used to make these changes: #!/bin/bash set -e tmp=$(mktemp -d) echo "tmp=$tmp" find Kernel \( -name '*.cpp' -o -name '*.h' \) | sort > $tmp/Kernel.files find . \( -path ./Toolchain -prune -o -path ./Build -prune -o -path ./Kernel -prune \) -o \( -name '*.cpp' -o -name '*.h' \) -print | sort > $tmp/EverythingExceptKernel.files cat $tmp/Kernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/Kernel.macros cat $tmp/EverythingExceptKernel.files | xargs grep -Eho '[A-Z0-9_]+_DEBUG' | sort | uniq > $tmp/EverythingExceptKernel.macros comm -23 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/Kernel.unique comm -1 $tmp/Kernel.macros $tmp/EverythingExceptKernel.macros > $tmp/EverythingExceptKernel.unique cat $tmp/Kernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/Kernel.header cat $tmp/EverythingExceptKernel.unique | awk '{ print "#cmakedefine01 "$1 }' > $tmp/EverythingExceptKernel.header for macro in $(cat $tmp/Kernel.unique) do cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.new-includes ||: done cat $tmp/Kernel.new-includes | sort > $tmp/Kernel.new-includes.sorted for macro in $(cat $tmp/EverythingExceptKernel.unique) do cat $tmp/Kernel.files | xargs grep -l $macro >> $tmp/Kernel.old-includes ||: done cat $tmp/Kernel.old-includes | sort > $tmp/Kernel.old-includes.sorted comm -23 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.new comm -13 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.old comm -12 $tmp/Kernel.new-includes.sorted $tmp/Kernel.old-includes.sorted > $tmp/Kernel.includes.mixed for file in $(cat $tmp/Kernel.includes.new) do sed -i -E 's/#include <AK\/Debug\.h>/#include <Kernel\/Debug\.h>/' $file done for file in $(cat $tmp/Kernel.includes.mixed) do echo "mixed include in $file, requires manual editing." done
2021-01-25Everywhere: Use CMake to generate AK/Debug.h.asynts
This was done with the help of several scripts, I dump them here to easily find them later: awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in) do find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \; done # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list. awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-12Services: Move to Userland/Services/Andreas Kling
2021-01-12DevTools: Move to Userland/DevTools/Andreas Kling
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling
2021-01-12Applications: Move to Userland/Applications/Andreas Kling
2021-01-12Games: Move to Userland/Games/Andreas Kling
2021-01-12MenuApplets: Move to Userland/MenuApplets/Andreas Kling
2021-01-12Demos: Move to Userland/Demos/Andreas Kling
2021-01-12Shell: Move to Userland/Shell/Andreas Kling
2021-01-07CMake: Only enable "MacOS workaround" on MacOSAndreas Kling
This was preventing ports from building on Linux.
2021-01-07CMake: set CMAKE_SKIP_RPATH everywhereNico Weber
Else, there's tons of "-- Set runtime path of" spam at build time, with apparently no way of disabling the build noise other than turning of rpaths. If the dynamic loader uses them at some point, we probably want to set them through cflags/ldflags instead of through cmake's built-in thing anyways, for that reason.
2021-01-06Everywhere: Force linker hash style to be gnuSahan Fernando
2021-01-02Build + LibC: Enable -fstack-protector-strong in user spaceBrian Gianforcaro
Modify the user mode runtime to insert stack canaries to find stack corruptions. The `-fstack-protector-strong` variant was chosen because it catches more issues than vanilla `-fstack-protector`, but doesn't have substantial performance impact like `-fstack-protector-all`. Details: -fstack-protector enables stack protection for vulnerable functions that contain: * A character array larger than 8 bytes. * An 8-bit integer array larger than 8 bytes. * A call to alloca() with either a variable size or a constant size bigger than 8 bytes. -fstack-protector-strong enables stack protection for vulnerable functions that contain: * An array of any size and type. * A call to alloca(). * A local variable that has its address taken. Example of it catching corrupting in the `stack-smash` test: ``` courage ~ $ ./user/Tests/LibC/stack-smash [+] Starting the stack smash ... Error: Stack protector failure, stack smashing detected! Shell: Job 1 (/usr/Tests/LibC/stack-smash) Aborted ```
2021-01-01Meta: Enable RTTI for Userspace programsAndrew Kaster
RTTI is still disabled for the Kernel, and for the Dynamic Loader. This allows for much less awkward navigation of class heirarchies in LibCore, LibGUI, LibWeb, and LibJS (eventually). Measured RootFS size increase was < 1%, and libgui.so binary size was ~3.3%. The small binary size increase here seems worth it :^)
2021-01-01CMake: Add public cmake option to document BUILD_LAGOMBrian Gianforcaro
- Making this an option makes this option visible to users and tooling.
2021-01-01CMake: Add public cmake option to document ENABLE_ALL_THE_DEBUG_MACROSBrian Gianforcaro
- Making this an option makes this option visible to users and tooling. - Rename `ALL_THE_DEBUG_MACROS` -> `ENABLE_ALL_THE_DEBUG_MACROS`.
2021-01-01CMake: Remove some trailing whitespace from a few CMakeLists.txt filesBrian Gianforcaro
2021-01-01CMake: Consolidate all options to the root of the projectBrian Gianforcaro
2020-12-29Build: Support non-i686 toolchainsmeme
* Add SERENITY_ARCH option to CMake for selecting the target toolchain * Port all build scripts but continue to use i686 * Update GitHub Actions cache to include BuildIt.sh
2020-12-28Meta: Disable rpath generation for MacOSAndrew Kaster
2020-12-26CMake: Generate SONAME attribute for shared objectsItamar
Previosuly, generation of the SONAME attribute was disabled. This caused libraries to have relative paths in DT_NEEDED attributes (e.g "Libraries/libcore.so" instead of just "libcore.so"), which caused build errors when the working directory during build was not $SERENITY_ROOT/Build. This caused the build of ports that use libraries other than libc.so to fail (e.g the nesalizer port). Closes #4457
2020-12-26Everywhere: Add -Wformat=2 to buildSahan Fernando
2020-12-24Toolchain+LibC: Fix usage of crt filesItamar
We now configure the gcc spec files to use a different crt files for static & PIE binaries. This relieves us from the need to explicitly specify the desired crt0 file in cmake scripts.
2020-12-24CMake: Decouple cmake utility functions from top-level CMakeLists.txtLenny Maiorani
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-22CMake: Use built-in add_compile_definitions for *_DEBUG macrosLenny Maiorani
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-22LibGfx: Commonize functions in P*MLoader class implementationsLenny Maiorani
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-22CMake: Use add_compile_options instead of appending to CMAKE_CXX_FLAGSLenny Maiorani
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-22CMake: Set C++20 mode in canonical cmakeLenny Maiorani
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-21Kernel: Introduce the new Storage subsystemLiav A
This new subsystem is somewhat replacing the IDE disk code we had with a new flexible design. StorageDevice is a generic class that represent a generic storage device. It is meant that specific storage hardware will override the interface. StorageController is a generic class that represent a storage controller that can be found in a machine. The IDEController class governs two IDEChannels. An IDEChannel is responsible to manage the master & slave devices of the channel, therefore an IDEChannel is an IRQHandler.
2020-12-21Build: Embed application icons directly in the executables.William Marlow
New serenity_app() targets can be defined which allows application icons to be emedded directly into the executable. The embedded icons will then be used when creating an icon for that file in LibGUI.
2020-12-20LibGUI: Introduce GML - a simple GUI Markup Language :^)Andreas Kling
This patch replaces the UI-from-JSON mechanism with a more human-friendly DSL. The current implementation simply converts the GML into a JSON object that can be consumed by GUI::Widget::load_from_json(). The parser is not very helpful if you make a mistake. The language offers a very simple way to instantiate any registered Core::Object class by simply saying @ClassName @GUI::Label { text: "Hello friends!" tooltip: ":^)" } Layouts are Core::Objects and can be assigned to the "layout" property: @GUI::Widget { layout: @GUI::VerticalBoxLayout { spacing: 2 margins: [8, 8, 8, 8] } } And finally, child objects are simply nested within their parent: @GUI::Widget { layout: @GUI::HorizontalBoxLayout { } @GUI::Button { text: "OK" } @GUI::Button { text: "Cancel" } } This feels a *lot* more pleasant to write than the JSON we had. The fact that no new code was being written with the JSON mechanism was pretty telling, so let's approach this with developer convenience in mind. :^)
2020-12-16Kernel: Fix Lock race causing infinite spinning between two threadsTom
We need to account for how many shared lock instances the current thread owns, so that we can properly release such references when yielding execution. We also need to release the process lock when donating.
2020-12-14Toolchain: Fix usage of libgcc_s & build PIE executables by defaultItamar
We can now build the porst with the shared libraries toolchain.
2020-12-14LibC: Also build a static version of libcItamar
2020-12-14Loader: Stabilize loader & Use shared libraries everywhere :^)Itamar
The dynamic loader is now stable enough to be used everywhere in the system - so this commit does just that. No More .a Files, Long Live .so's!
2020-12-14LibC: Add libc.soItamar
We now compile everything with -static flag so libc.a would be use
2020-12-14Loader: Add dynamic loader programItamar
The dynamic loader exists as /usr/lib/Loader.so and is loaded by the kernel when ET_DYN programs are executed. The dynamic loader is responsible for loading the dependencies of the main program, allocating TLS storage, preparing all loaded objects for execution and finally jumping to the entry of the main program.
2020-12-12Kernel: Change wait blocking to Process-only blockingTom
This prevents zombies created by multi-threaded applications and brings our model back to closer to what other OSs do. This also means that SIGSTOP needs to halt all threads, and SIGCONT needs to resume those threads.
2020-12-06LibJS: Remove unused {INTERPRETER,VM}_DEBUGLinus Groh
2020-12-06LookupServer: Put debug spam behind a macroAndreas Kling
2020-12-01Meta: Refresh ALL_THE_DEBUG_MACROS setBen Wiederhake
2020-12-01Meta: Fix BMP_DEBUG, and always build on CIBen Wiederhake
2020-12-01Meta: Fix ACPI_DEBUG, and always build on CIBen Wiederhake