Commit Graph

15791 Commits

Author SHA1 Message Date
Andreas Kling
f03800cee3 Kernel: Add dedicated "ptrace" pledge promise
The vast majority of programs don't ever need to use sys$ptrace(),
and it seems like a high-value system call to prevent a compromised
process from using.

This patch moves sys$ptrace() from the "proc" promise to its own,
new "ptrace" promise and updates the affected apps.
2021-01-11 22:32:59 +01:00
Andreas Kling
127ce32d9e LibGfx: Adjust margin between window title/stripes by 1px
This makes it symmetrical with the margin between window icon/title.
2021-01-11 22:15:09 +01:00
Andreas Kling
f7435dd95f Kernel: Remove MM_DEBUG debug spam code
This was too spammy to ever actually be used anyway.
2021-01-11 22:09:40 +01:00
Andreas Kling
7c4ddecacb Kernel: Convert a bunch of String::format() => String::formatted() 2021-01-11 22:07:01 +01:00
Andreas Kling
0ae9ae48fa Themes: Tweak "Sunshine" theme colors slightly
Bring them a little closer to the original CDE colors. :^)
2021-01-11 21:49:39 +01:00
asynts
843ebbd2c3 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
asynts
6fa42af567 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.

The modifications in this commit were automatically made using the
following command:

    find . -name '*.h' -exec sed -i -E 's/dbg\(\) << ("[^"{]*");/dbgln\(\1\);/' {} \;
2021-01-11 21:49:29 +01:00
asynts
a410bb8fd5 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:49:29 +01:00
AnotherTest
510030971b LibLine: Handle history across multiple concurrent sessions better
- Store history entries as (timestamp)::(entry)\n\n
- Merge the entries together when saving to avoid loss of history
  entries

To ideally make having two concurrently open shells
(or `js` repls or whatever) not overwrite each others' history entries.
2021-01-11 21:09:36 +01:00
AnotherTest
711ced80c0 LibCore: Add line iterators to IODevice 2021-01-11 21:09:36 +01:00
AnotherTest
7029a8f605 AK: Specialise convert_to_uint<T> and to_uint<T> for 'long' variants 2021-01-11 21:09:36 +01:00
Sahan Fernando
ccf4368ca5 AK: Enable format string warnings for AK printf wrappers 2021-01-11 21:06:32 +01:00
Sahan Fernando
9bf76a85c8 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando
fe2b8906d4 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando
6d97b623cd Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Sahan Fernando
099b83fd28 Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-11 21:06:32 +01:00
Nico Weber
009c753a12 Playground: Show placeholders for unregistered widgets
With this, Playground can be used to interactively edit e.g.
DisplaySettingsWindow.gml.
2021-01-11 20:12:26 +01:00
Lenny Maiorani
1b2364846f SinglyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `SinglyLinkedList`.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
2021-01-11 19:45:05 +01:00
Lenny Maiorani
853cb8af5c DoublyLinkedList: Implement find in terms of AK::find
Problem:
- The implementation of `find` is coupled to the implementation of
  `DoublyLinkedList`.
- `append` and `prepend` are implemented multiple times so that
  r-value references can be moved from into the new node. This is
  probably not called very often because a pr-value or x-value needs
  to be used here.

Solution:
- Decouple the implementation of `find` from the class by using a
  generic `find` algorithm.
- Make `append` and `prepend` be function templates so that they can
  have binding references which can be forwarded.
2021-01-11 19:45:05 +01:00
Lenny Maiorani
f99d1d3bd7 Vector: Implement find, find_if, find_first_matching in terms of AK::find*
Problem:
- The implementation of `find` is coupled to the implementation of `Vector`.
- `Vector::find` takes the predicate by value which might be expensive.

Solution:
- Decouple the implementation of `find` from `Vector` by using a
  generic `find` algorithm.
- Change the name of `find` with a predicate to `find_if` so that a
  binding reference can be used and the predicate can be forwarded to
  avoid copies.
- Change all the `find(pred)` call sites to use `find_if`.
2021-01-11 19:45:05 +01:00
Lenny Maiorani
4333a9a8d6 AK: Find a value in any container offering iterators
Problem:
- `find` is implemented inside of each container. This coupling
  requires that each container needs to individually provide `find`.

Solution:
- Decouple the `find` functionality from the container. This allows
  provides a `find` algorithm which can work with all
  containers. Containers can still provide their own `find` in the
  case where it can be optimized.
- This also allows for searching sub-ranges of a container rather than
  the entire container as some of the container-specific member
  functions enforced.

Note:
- @davidstone's talk from 2015 C++Now conference entitled "Functions
  Want to be Free" encourages this style:
  (https://www.youtube.com/watch?v=_lVlC0xzXDc), but it does come at
  the cost of composability.
- A logical follow-on to this is to provide a mechanism to use a
  short-hand function which automatically searches the entire
  container. This could automatically use the container-provided
  version if available so that functions which provide their own
  optimized version get the benefit.
2021-01-11 19:45:05 +01:00
Andreas Kling
04c6245fe8 LibGfx: Fail PBM decode if there isn't enough color data in image
Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29417
2021-01-11 19:24:54 +01:00
Andreas Kling
e1cc2acded CrashDaemon: Use pledge 2021-01-11 19:03:09 +01:00
Andreas Kling
5c73c1bff8 Kernel: Don't dump perfcore for non-dumpable processes
Fixes #4904
2021-01-11 18:53:45 +01:00
Andreas Kling
cf3d2411fa UserspaceEmulator: Implement the ftruncate and umask syscalls
It's now possible to copy files with FileManager running in UE. :^)
2021-01-11 12:01:42 +01:00
asynts
723effd051 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
5931758dbc Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
dca6f1f49b Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
872f2a3b90 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
asynts
11d651d447 Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.Everything:
2021-01-11 11:55:47 +01:00
campital
c7fc9d185d
LibGUI: Update TextEditor after triple-click to select (#4897)
Previously, it was "relying" on the cursor blink timer to update
the visual selection.

This caused some delay after the whole line was selected by
triple-clicking specifically the last word in a line.

Now, the widget is updated after triple-clicking.
2021-01-11 11:42:06 +01:00
Andreas Kling
603147f47a Kernel: Fix perfcore filename generation build error 2021-01-11 11:37:14 +01:00
Andreas Kling
5dafb72370 Kernel+Profiler: Make profiling per-process and without core dumps
This patch merges the profiling functionality in the kernel with the
performance events mechanism. A profiler sample is now just another
perf event, rather than a dedicated thing.

Since perf events were already per-process, this now makes profiling
per-process as well.

Processes with perf events would already write out a perfcore.PID file
to the current directory on death, but since we may want to profile
a process and then let it continue running, recorded perf events can
now be accessed at any time via /proc/PID/perf_events.

This patch also adds information about process memory regions to the
perfcore JSON format. This removes the need to supply a core dump to
the Profiler app for symbolication, and so the "profiler coredump"
mechanism is removed entirely.

There's still a hard limit of 4MB worth of perf events per process,
so this is by no means a perfect final design, but it's a nice step
forward for both simplicity and stability.

Fixes #4848
Fixes #4849
2021-01-11 11:36:00 +01:00
Itamar
f259d96871 Kernel: Avoid collision between dynamic loader and main program
When loading non position-independent programs, we now take care not to
load the dynamic loader at an address that collides with the location
the main program wants to load at.

Fixes #4847.
2021-01-10 22:04:43 +01:00
Itamar
40a8159c62 Kernel: Plumb the elf header of the main program down to Process::load
This will enable us to take the desired load address of non-position
independent programs into account when randomizing the load address
of the dynamic loader.
2021-01-10 22:04:43 +01:00
Linus Groh
f369229770 LibJS: Replace all uses of to_size_t() and remove it :^)
Yay for more spec compliance! This is pretty easy as everything using
to_size_t() should just be using one of the other abstract operations we
already have implemented.
This allows us to get rid of get_length() in ArrayPrototype, which is
basically a slightly incorrect implementation of length_of_array_like(),
and then finally remove to_size_t()!
Also fixes a couple of "argument is undefined" vs "argument isn't given"
issues along the way.
2021-01-10 21:57:03 +01:00
Linus Groh
9be0b664e3 LibJS: Make length_of_array_like() take an Object rather than Value
The pseudo-code from the spec says "Assert: Type(obj) is Object.", so we
can just enforce this at compile time rather than taking it literally
and doing "ASSERT(value.is_object())".

Also fix an issue where the absence of a "length" property on the object
would cause a crash (to_number() on empty value).
2021-01-10 21:57:03 +01:00
Andrew Kaster
a5e557472c Kernel: Defer handling of key press events in VirtualConsole
Trying to pass these onto the Terminal while handling an IRQ is a recipe
for disaster. Use Processor::deferred_call_queue to create an ad-hoc
"second half" of the interrupt handler.

Fixes #4889
2021-01-10 21:50:08 +01:00
Andrew Kaster
d8aed14dba SystemServer: Allow /dev/fb0 to not exist, for text mode support. 2021-01-10 21:50:08 +01:00
Marcin Gasperowicz
b24ce0b5ee LibJS: Implement String.prototype.split
This adds a String.prototype.split implementation modelled after 
ECMA262 specification. 

Additionally, `Value::to_u32` was added as an implementation of
the standard `ToUint32` abstract operation.

There is a tiny kludge for when the separator is an empty string. 
Basic tests and visiting google.com prove that this is working.
2021-01-10 21:27:59 +01:00
Brendan Coles
b53664a8ef UserspaceEmulator: Implement clock_settime syscall 2021-01-10 18:20:29 +01:00
Lenny Maiorani
700f213011 TestTypeTraits: Fix incorrectly namespaced nullptr_t
Problem:
- Clang ToT fails to build `AK/Tests/TestTypeTraits.cpp` because
  `nullptr_t` is missing the `std` namespace qualifier.

Solution:
- Prepend the namespace qualifier.
2021-01-10 18:20:14 +01:00
AnotherTest
43199e5613 LibLine: Implement support for C-V<key>
This commit adds support for inserting in a "verbatim" mode where a
single uninterpreted key is appended to the buffer.
As this allows the user to input control characters, all control
characters except \n (^M) are rendered in their caret form, with
reverse video (SGR 7) applied to it.
To not break cursor movement, the concept of "masked" characters is
introduced to the StringMetrics interface, which can be mostly ignored
by the rest of the system.

It should be noted that unlike some other line editing libraries,
LibLine does _not_ render a hard tab as a tab, but rather as '^I',
which greatly simplifies cursor handling.
2021-01-10 16:58:08 +01:00
AnotherTest
44305ea214 LibVT: Respect the Negative attribute when drawing text
This makes the "reverse video" SGR actually work.
2021-01-10 16:58:08 +01:00
Andreas Kling
2f3b901f7f AK: Make MappedFile heap-allocated and ref-counted
Let's adapt this class a bit better to how it's actually being used.

Instead of having valid/invalid states and storing an error in case
it's invalid, a MappedFile is now always valid, and the factory
function that creates it will return an OSError if mapping fails.
2021-01-10 16:49:13 +01:00
Andreas Kling
70fce5c4c7 LibCore: Use OSError in get_password() return type 2021-01-10 16:48:43 +01:00
Andreas Kling
a8681da4bf AK: Add AK::OSError, a wrapper for errno codes
This is a strongly typed carrier for "errno" error codes, intended for
use in return types, e.g Result<String, OSError>.
2021-01-10 16:46:13 +01:00
Emanuele Torre
a330f37f06 Base: Change anon's default password from "foo\n" to just "foo". 2021-01-10 16:40:05 +01:00
Emanuele Torre
91222a67c8 LibCore: get_password() now removes the trailing '\n' read by getline()
This avoids unintentionally adding a newline character at the end of
user passwords when they are set using passwd(1).

I also fixed these two issues:

- The return value of getline() was being saved in an `int` variable
instead of in a `ssize_t` variable; I replaced the `int` keyword with
`auto` to fix this issue.

- Prior to this patch, get_password() could potentially return
tcsetattr()'s errno instead of getline()'s errno in case of an error.
We now make sure it always returns the right errno in case of an error.
2021-01-10 16:40:05 +01:00
Andrew Kaster
9e5aa6f794 Meta: Only complain about linter tools if relevant files have changed 2021-01-10 16:39:21 +01:00