Commit graph

6095 commits

Author SHA1 Message Date
Andreas Kling
197e73ee31 Kernel+LibELF: Enable SMAP protection during non-syscall exec()
When loading a new executable, we now map the ELF image in kernel-only
memory and parse it there. Then we use copy_to_user() when initializing
writable regions with data from the executable.

Note that the exec() syscall still disables SMAP protection and will
require additional work. This patch only affects kernel-originated
process spawns.
2020-01-10 10:57:06 +01:00
Andreas Kling
66b0002acb Base: Let's make home directories 700 to keep things private :^) 2020-01-09 21:57:52 +01:00
Andreas Kling
41d5f5c3b5 ls: Widen the user and group fields a little bit
I didn't like looking at /tmp/portal now that lookup:lookup owns one
of the sockets there :^)
2020-01-09 21:43:21 +01:00
Andreas Kling
f5d9f11e52 Base: Add a "lookup" user+group that runs LookupServer
LookupServer now runs as lookup:lookup, allowing connections from other
members of the "lookup" group.

This is enforced through file system permissions by having the service
socket (/tmp/portal/lookup) be mode 0660.

Now the LookupServer program can't overwrite other people's files if it
starts misbehaving. That's pretty cool :^)
2020-01-09 21:36:17 +01:00
Andreas Kling
7dd03b46ee SystemServer: Allow specifying per-service socket file permissions 2020-01-09 21:35:33 +01:00
Andreas Kling
f3dad64a3b LibC: Fail name lookups immediately if we can't connect to LookupServer 2020-01-09 21:33:03 +01:00
Andreas Kling
a9e3575a18 Kernel: Don't apply process umask to the LocalSocket prebind mode 2020-01-09 21:32:11 +01:00
Andreas Kling
0596ab880e Kernel: connect() should EISCONN on already-connected LocalSocket
This was causing us to try and accept the same client socket multiple
times on the server side, tripping an assertion in Socket::accept().
2020-01-09 21:30:56 +01:00
Dov Alperin
21517f693d Build: Add fast build mode that does not clean everything or run tests
Passing the "-f" or "--fast" option to the ./makeall.sh script will
build everything without cleaning first, and then will skip tests.
2020-01-09 18:07:21 +01:00
Andreas Kling
ff16298b44 Kernel: Removed an unused global variable 2020-01-09 18:02:37 +01:00
Andreas Kling
17ef5bc0ac Kernel: Rename {ss,esp}_if_crossRing to userspace_{ss,esp}
These were always so awkwardly named.
2020-01-09 18:02:01 +01:00
Andreas Kling
f007a63b10 Kernel: Prune a bunch of removed syscalls from the list 2020-01-09 16:25:35 +01:00
Andreas Kling
673d789c39 Kernel: Make some static keyboard data const
This moves it to the kernel's .rodata section which we write protect in
MemoryManager initialization.
2020-01-09 16:23:45 +01:00
Andreas Kling
4b4d369c5d Kernel: Take path+length in the unlink() and umount() syscalls 2020-01-09 16:23:41 +01:00
Andreas Kling
76c20642f0 Kernel: Ignore closed fd's when considering select() unblock
This fixes a null RefPtr deref (which asserts) in the scheduler if a
file descriptor being select()'ed is closed by a second thread while
blocked in select().

Test: Kernel/null-deref-close-during-select.cpp
2020-01-09 12:36:42 +01:00
Andreas Kling
e23f05a157 Kernel: Remove unused variable Thread::m_userspace_stack_region 2020-01-09 12:31:18 +01:00
Andrew Kaster
c21f384d17 LibELF: Remove DynamicSection from ELFImage
Since ELFDynamicObject needs the actual virtual address of the .dynamic
section in the loaded image, and not the file offset like we assumed
before, due to MAP_PRIVATE secretly giving us a MAP_SHARED, we can
remove all of the Dynamic* code from ELFImage.

ELFDynamicLoader only needs ELFImage to get the Program headers at this
point. More consolidation opportunities seem likely in the future.
2020-01-09 09:29:36 +01:00
Andrew Kaster
2e349337d3 LibELF: Map .text segment with MAP_ANONYMOUS for shared objects
We need to workaround the fact that MAP_PRIVATE when passed a file
descriptor doesn't work the way we expect. We can't change the
permissions on our mmap to PROT_WRITE if the original executable doesn't
have PROT_WRITE.

Because of this, we need to construct our ELFDynamicObject using the
actual virtual address of the .dynamic section, instead of using the
offset into the ELFImage that was actually getting modified by accident
...somehow. Not clear what was going on.
2020-01-09 09:29:36 +01:00
Andrew Kaster
e594724b01 Kernel: mmap(..., MAP_PRIVATE, fd, offset) is not supported
Make mmap return -ENOTSUP in this case to make sure users don't get
confused and think they're using a private mapping when it's actually
shared. It's currenlty not possible to open a file and mmap it
MAP_PRIVATE, and change the perms of the private mapping to ones that
don't match the permissions of the underlying file.
2020-01-09 09:29:36 +01:00
Andreas Kling
56974f76be LibVT: Relayout TerminalWidget on font change
We were not recomputing the internal dimensions after a font changed,
which caused things to look very off.

It's still not perfect as we're always using the same (small) font for
bold text, which obviously sticks out like a sore pinky when the rest
of the terminal text is large.
2020-01-08 21:12:40 +01:00
Andreas Kling
53e204dfb0 Terminal: Put the Font menu items in an action group :^) 2020-01-08 21:12:40 +01:00
Andreas Kling
7ba7d88fba SystemMonitor: Put the Frequency menu items in an action group
This makes them look like radio buttons in the menu, which is a very
nice increase in polish. :^)
2020-01-08 21:12:40 +01:00
Andreas Kling
463ed77024 WindowServer+LibGUI: Paint exclusive actions as radio buttons in menus
Actions that are checkable and members of a GActionGroup will now be
painted with a radio button appearance in menus.
2020-01-08 21:12:40 +01:00
Andreas Kling
cc8c26c39b LibDraw+LibGUI: Move radio button painting into StylePainter
This will allow WindowServer to draw radio buttons :^)
2020-01-08 21:12:40 +01:00
Andreas Kling
6c549959c6 disk_benchmark: Unbreak this utility now that read() of O_WRONLY fails 2020-01-08 21:12:40 +01:00
Dov Alperin
dacec1a7ee Meta: Reference CodingStyle doc in CONTRIBUTING.md 2020-01-08 19:41:20 +01:00
Andreas Kling
aac17fc81a IPv4: Randomize the first TCP sequence number
Fixes #185.
2020-01-08 16:03:01 +01:00
Andreas Kling
03c34cc73f LibC: Don't leave /etc/passwd open in getlogin() 2020-01-08 16:01:51 +01:00
Andreas Kling
e1d4b19461 Kernel: open() and openat() should ignore non-permission bits in mode 2020-01-08 15:21:06 +01:00
Andreas Kling
d310cf3b49 Kernel: Opening a file with O_TRUNC should update mtime 2020-01-08 15:21:06 +01:00
Andreas Kling
e485667201 Kernel: ftruncate() should update mtime 2020-01-08 15:21:06 +01:00
Andreas Kling
1f6c624a1a truncate: Unbreak this utility after ftruncate() syscall fixes 2020-01-08 15:21:06 +01:00
Andreas Kling
532f240f24 Kernel: Remove unused syscall for setting the signal mask 2020-01-08 15:21:06 +01:00
Andreas Kling
200459d644 Kernel: Fix SMAP violation in join_thread() 2020-01-08 15:21:05 +01:00
Dov Alperin
518f469970 LibGUI: clicking and dragging one item will drag other items in selection
Previously if more than one item was selected clicking on one of
them and dragging would de-select everything that is not the one that
was clicked on. Now, if more than one items are selected and there
is a mousedown it goes into a "mightdrag" state.
The user can then perform a drag, if they don't everything that is not
the item being clicked gets unselected in the mouseup event, mimicking
the previous behavior.
2020-01-08 15:20:41 +01:00
Dov Alperin
e0c959ea7f LibGUI: separate file names with commas in the drag operation text 2020-01-08 15:20:41 +01:00
Andreas Kling
8ddd053c2a WindowServer: Detach WSMenuManager from WSWindowManager
You can now get to the WSMenuManager via WSMenuManager::the().
Also note that it's initialized after WSWindowManager.
2020-01-08 13:26:19 +01:00
Andreas Kling
2d75396c94 About: Focus the button on startup 2020-01-08 13:14:39 +01:00
Andreas Kling
50fa759806 Revert "WSWindowServer: Remove uneccessary special casing"
This reverts commit 0c1bc91e88.

It turns out this is what made it possible to hover "between" different
menus after opening one of them with a click.
2020-01-08 13:13:36 +01:00
Andreas Kling
fe1bf067b8 ProcFS: Reads past the end of a generated file should be zero-length 2020-01-08 12:59:06 +01:00
Andreas Kling
28ee5b0e98 TmpFS: Reads past the end of a file should be zero-length 2020-01-08 12:47:41 +01:00
Andreas Kling
50056d1d84 Kernel: mmap() should fail with ENODEV for directories 2020-01-08 12:47:37 +01:00
Shannon Booth
3f35cd2f7d WSWindowServer: Only close menubar on a mouse down
This allows you to click on the menu, then use the menu keys to browse
the menu. Beforehand, you would click the window, release the button,
and the menu would close :(
2020-01-08 11:36:49 +01:00
Shannon Booth
7fb7b399a3 WSWindowManager: Use early return to limit nesting
Let's be a little nicer on the eyes :^)
2020-01-08 11:36:49 +01:00
Shannon Booth
4683424e7a WSMenu: Support menu navigation through key presses
Add event handling for key presses for navigating a menu. The currently
hovered menu item is tracked through an index which is either
incremented or decremented on up or down arrow key presses, changing the
hovered item.

Whenever there is a mouse move event, we ensure that the current index
matches the currently hovered item so that the mouse and keyboard do not
get out of sync.

If the right key is pressed, and we are on a submenu menu item, we
'enter' that submenu. While we are currently in a submenu, we forward
all keypress events to that submenu for handling. This allows us to
traverse the heirachy of a menu. While in a submenu, if the left key is
pressed, we leave that submenu and start handling the keypresses
ourselves again.

There is currently a small issue where the mouse hover and key hover can
get out of sync. The mouse can be traversing a submenu, but the parent
menu has no idea that the mouse has 'entered' a submenu, so will handle
the key presses itself, instead of forwarding them to the submenu. One
potential fix for this is for a menu to tell its menu parent that the
submenu is being traversed.
2020-01-08 11:36:49 +01:00
Shannon Booth
27cb91e3e0 WSMenuManager: On menu close, close the currently hovered menu item
Ensure that the current hover is not still hovered when the menu is
opened again.
2020-01-08 11:36:49 +01:00
Shannon Booth
0c1bc91e88 WSWindowServer: Remove uneccessary special casing
From my testing I could not see this code doing anything. Listen the
FIXME, and remove this.
2020-01-08 11:36:49 +01:00
Andreas Kling
372f9e9a11 Kernel: Enable SMAP protection on IRQ and exception entry
It would be nice to do this in the assembly code, but we have to check
if the feature is available before doing a CLAC, so I've put this in
the C++ code for now.
2020-01-08 10:37:53 +01:00
Andreas Kling
fe9680f0a4 Kernel: Validate PROT_READ and PROT_WRITE against underlying file
This patch fixes some issues with the mmap() and mprotect() syscalls,
neither of whom were checking the permission bits of the underlying
files when mapping an inode MAP_SHARED.

This made it possible to subvert execution of any running program
by simply memory-mapping its executable and replacing some of the code.

Test: Kernel/mmap-write-into-running-programs-executable-file.cpp
2020-01-07 19:32:32 +01:00
Andreas Kling
faf32153f6 Kernel: Take const Process& in InodeMetadata::may_{read,write,execute} 2020-01-07 19:24:06 +01:00