Commit Graph
67938 Commits
Author SHA1 Message Date
Augustin Cavalier 2b79f7b494 kernel/team: Add permissions checks in get_extended_team_info. 2025-07-15 18:08:00 -04:00
Augustin Cavalier 9626cf86ec fdinfo: Print the application current working directory.
Would have helped immensely with diagnosing #19684.
2025-07-15 18:02:21 -04:00
Augustin Cavalier bdda979744 Terminal: Don't chdir() but pass the working directory down to _Spawn().
If we change our current directory, it will be retained as a reference
down inside the VFS, preventing filesystems from being unmounted,
among other things.

Fixes #19684.
2025-07-15 17:32:07 -04:00
Augustin Cavalier 38e619c671 Terminal: Delete some dead code.
We have a different way of launching hyperlinks now.
2025-07-15 17:14:01 -04:00
Augustin Cavalier 496b2dd5a2 kernel/fs: Fix some minor coding style issues. 2025-07-15 17:13:23 -04:00
Augustin Cavalier 0e32637090 poke: Add missing IS_USER_ADDRESS checks. 2025-07-12 16:46:05 -04:00
Augustin Cavalier 801c025d7b file_systems/QueryParser: Invoke ConvertValue in CalculateScore.
We need fSize to be set for operator scoring.

Also, use operator scoring for GREATER_THAN and GREATER_THAN_OR_EQUAL.

Fixes a KDL reported in #19677.
2025-07-12 15:48:14 -04:00
Augustin Cavalier 5d6b495d6a kernel/guarded_heap: Implement ctors/dtors in the fake object_cache.
Part of #19677.
2025-07-12 15:43:34 -04:00
Augustin Cavalier beed129dc2 kernel/vm: Use vm_page_num_pages() to compute heap size.
sAvailableMemory is now initialized later.

Part of #19677.
2025-07-12 15:42:59 -04:00
PulkoMandy 95c611518f listarea: show area locking and protection
Also tweak the header to stay better aligned with the values

Change-Id: I74a44ecb8e62ece75b43b75a32a0bf9f8a910309
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9457
Reviewed-by: Adrien Destugues <[email protected]>
2025-07-12 19:14:07 +00:00
Augustin Cavalier 87079731d3 kernel/vm: Don't invoke compute_area_page_commitment in map_backing_store.
It seems this is still too early and not enough fields in the VMArea
have been initialized. Instead just check the protection manually.

Also fix some more locking behavior in the error path.
2025-07-12 15:13:41 -04:00
Augustin Cavalier 3978032551 kernel/vm: Areas without source caches need commitments for READ protections.
May fix #19678.
2025-07-12 14:27:13 -04:00
Augustin Cavalier 6bb82d2942 kernel/events: Fix incorrect sizeof in user_memcpy.
The field has 4 bytes of padding after it on 64-bit architectures,
so in the end this doesn't make much difference.
2025-07-12 13:16:09 -04:00
PulkoMandy 9fce28cfb3 Haiku book: Tweak some section titles
Just the library name in parentheses doesn't look so great in the book
index (in particular for libroot in the "special topics" list). So include
a short description there.

Change-Id: I99ea8f85b042c5606b078aca906a0717aff6d46f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9452
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-07-11 06:56:43 +00:00
PulkoMandy b57c6ae0f4 Haiku book: Add documentation for dlfcn.h
Change-Id: I72da1e84dd31ee3fe923a55163da10a37de8b207
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9451
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-07-11 06:56:43 +00:00
PulkoMandy d27a926578 runtime_loader: implement RTLD_GROUP
The RTLD_GROUP flag to dlopen comes from Solaris. It makes the symbol
resolution for dlopen not use the global symbols from the current team
(anything that's already loaded). The loaded object must be explicitly
linked against any symbol it needs to use (or it can use dlsym to search
symbols in the global scope explicitly).

This is also how symbol resolution worked in BeOS, meaning we already
have the code to do this, and just need to enable it.

This can be used in dosemu, where DOS-like executable are linked against
their own C library and should not use symbols from libroot.

Fixes #19674.

Change-Id: I8d127c7812a31e231edb1e44edf70b868c2670e7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9450
Reviewed-by: waddlesplash <[email protected]>
2025-07-11 06:56:43 +00:00
Jérôme Duval aa31f66532 ext2: fix htree first splitting and checksumming
fix #19665

Change-Id: Id4bba3541f750a7b4756a80ee0234f34c25dcf98
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9449
Reviewed-by: waddlesplash <[email protected]>
2025-07-09 18:46:01 +00:00
Jim906 d0b07ec244 nfs4: Disable file cache to invalidate it
* When resetting the file cache, use file_cache_disable() to remove
  all pages, instead of calling file_cache_delete().
* Possible fix for #19656.

file_cache_delete doesn't actually delete the VMCache object, so when
file_cache_create() is called the returned file_cache_ref just points
to the same VMCache as before.

Change-Id: Ifba42b51c52f11980fd97212d0c3bdfdc1e55085
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9448
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-07-09 17:57:29 +00:00
Augustin Cavalier ceec330bbb kernel/vm: Numerous fixes to area cutting and commitment logic.
* Split the "is only cache user" logic from cut_area into
   a helper routine.

 * If we can't modify a cache in cut_area, then we can't modify
   its commitment either, so add that to the check.

 * If we didn't split the areas, then modifying the commitments
   doesn't make sense and will cause problems, so move that logic
   into the "modify cache" branch.

 * Use the new helper routine in set_memory_protection rather than
   checking only cache->temporary.

Combined with the previous commit, seems to fix #19624.
2025-07-07 17:20:34 -04:00
Augustin Cavalier 92f73a4e2c RAMFS: Use cache types of 0 (invalid) rather than "RAM".
Otherwise, various parts of the VM think it's safe to modify
such caches and/or their commitments in ways that it's not.
2025-07-07 17:08:37 -04:00
Augustin Cavalier 687e76e3f9 kernel/vm: Make the first CACHE_TYPE be 1 instead of 0.
We store this value in a bitfield, so we can't use -1 to mean
invalid/unknown. Move the first value up so that 0 can be used
for that instead.
2025-07-07 17:05:11 -04:00
Augustin Cavalier 34e38174eb RAMFS: Use the new check_write_stat_permissions. 2025-07-07 15:19:11 -04:00
Augustin Cavalier 15b255904d BFS & EXTFS: Use the new check_write_stat_permissions in write_stat hooks. 2025-07-07 15:11:21 -04:00
Augustin Cavalier 9ea1065b16 kernel/fs: Introduce check_write_stat_permissions utility method.
Like check_access_permissions() but for write_stat() hook instead
of access().

Basic logic copied from BFS, but with the UID/GID logic rewritten
to better conform to behavior on other OSes: notably, we allow
chown() requests that keep the UID the same to go through, same
as Linux seems to, which should fix #19666. We now also validate
that the GID is one of the current team's groups.
2025-07-07 15:10:01 -04:00
Augustin Cavalier 7ed202f9ed kernel: Add is_in_group(Team*) private utility method and use it in the VFS.
Slightly more efficient than using getegid() and getgroups().

While at it, make the user-group utility methods C++-only.
2025-07-07 15:02:17 -04:00
Pascal Abresch 8e086795b2 implement fdatasync
Change-Id: I2aefc1acebce93a2c53a6d3be5eef3b9e69480ec
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8507
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: nephele nephele <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-07-07 15:20:18 +00:00
Jim906 258fce50e0 nfs4: Check for stale nodes when reload dir cache
* When the DirectoryCache is updated, compare the new contents with
  the old.  If any of the old entries are obsolete, treat the
  respective node as stale.
* Create FileSystem::TrashStaleNode() to avoid duplicating code.
* Possible fix for #19656.

This helps the client keep current with changes made to server files
by other users.

While the comparison will be slow for a large directory, it won't be
executed unless another user has changed the contents of a directory
since the last time the Haiku client read the directory.

Change-Id: I03e65aaaad5027c66b10265f2b4a21ed9d2b6744
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9445
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-07-07 15:16:10 +00:00
Augustin Cavalier d9048aa4fc libroot/malloc: Increase address space reservation to 1GB.
Similar to the debug malloc and the old hoard2.

May help with #19592 a bit more.
2025-07-02 17:41:23 -04:00
Augustin Cavalier e6de99eb01 multiuser: Change all groups in setup_environment.
We need to change all groups, not just the primary group.
Otherwise, other groups will be left intact, which may
include groups the new user doesn't have permissions for.
2025-07-02 17:20:01 -04:00
Augustin Cavalier 27e99e3a64 su: Don't ask root for passwords.
root can su to any user without needing any password.
Same behavior as passwd for changing passwords.
2025-07-02 17:20:01 -04:00
John Scipione b58c23c7c6 Menu docs: fix typo
Change-Id: Icc789b5d2652dca3a64c3bbc5572821747efa75d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9438
Reviewed-by: waddlesplash <[email protected]>
2025-07-02 19:12:03 +00:00
Augustin Cavalier 987a07492e BMenu: Automatically invoke _Install and _Uninstall in Attached/Detached.
This way, we can't inadvertently end up in a state where the
window is deleted but some things are still attached to it.

Fixes #19662.

Change-Id: I3ce7b5ccffc8cf12670209f3023613b32e31c41c

Reviewed-on: https://review.haiku-os.org/c/haiku/+/9437
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2025-07-02 18:39:25 +00:00
Máximo Castañeda 45f3d65457 Storage Kit: do what the method says in InstalledTypes::_AddSupertype
That is, just add the supertype if it does not exist. Leave getting it
to the callers that need it.

Fixes: #19653
Change-Id: I79d804161d28684e16a0d84ec3a2fb6788c0b506
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9436
Reviewed-by: waddlesplash <[email protected]>
2025-07-01 18:07:08 +00:00
Augustin Cavalier 8f149016fb kernel/arch: Put KERNEL_USER_DATA_BASE at USER_STACK_REGION.
x86_64 already does this and it seems to work fine. Since stack areas
grow downwards and should always have a guard page, overruns shouldn't
be too much of a concern (for that matter, randomization still makes
a difference here also, it seems.)

This allows us to regain another ~256 MB or so of contiguous address
space (areas smaller than that could still be inserted in the 0x6.. to
0x7.. block, but if you had 10MB of free address space below 0x6..,
and 246MB above it, you couldn't allocate a 256MB block.)

Part of #19592.
2025-07-01 00:26:29 -04:00
Augustin Cavalier e16d28419f kernel/vm: Ignore insertion hints when the address space is over half full.
We ideally want to avoid further fragmentation and just insert in the
smallest possible slot in that case.

Part of #19592. With DISABLE_ASLR=1, seems to save about 120 MB or so
of address space, which is a lot on 32-bit.
2025-07-01 00:22:32 -04:00
Augustin Cavalier da5a0edd02 kernel/vm: Adjust next-insert hint on area removal.
This doesn't matter so much because the hint's used for
an AVL tree lookup both for next and previous, but it
probably does at least a bit because the new area's size
is used in the tree lookups.
2025-07-01 00:19:50 -04:00
Augustin Cavalier be1a714a52 libroot/malloc: Increase address space reservation size to 512 MB.
The kernel will ignore the reservations if there's not enough space
left in the address space anyway.

It seems using larger reservations prevents address space fragmentation,
and so this by itself may be enough to fix #19592.
2025-07-01 00:18:32 -04:00
Augustin Cavalier df18fd7ab6 libroot/malloc: Add a free maximum to PagesAllocator.
128 MB should be more than enough memory in the global cache
for most applications (this limit's hit once the application
has 512 MB of live allocations, based on the current free
percentage of 25%.)
2025-07-01 00:17:35 -04:00
Augustin Cavalier c582c91f05 iprowifi3945: Add missing if_free_inplace.
Fixes the new KDL in #14265.
2025-06-30 21:30:12 -04:00
Augustin Cavalier 944c5ed17d NFS4: Handle B_MOUNT_READ_ONLY.
Should fix #19658.
2025-06-30 15:43:27 -04:00
Augustin Cavalier 9b0788bdc8 kernel/file_cache: Invoke VMCache::ReleaseStoreRef without a lock held.
Otherwise we might get lock-order inversion in the VFS (see comment in
VMCache::RemoveArea) and deadlock the system, which indeed I observed
while testing some things today.
2025-06-30 15:06:45 -04:00
Augustin Cavalier 7415ce0639 kernel/slab: Fix potential memory leak in HashedObjectCache.
If the resize-needed amount changed while we were allocating memory,
then we'd leak the new buffer.

In testing, I added an ASSERT() to check if this case actually happened,
and it didn't seem to fire when using the system (with a debug kernel
though, admittedly.)

Inspired by a change suggested on GitHub, but implemented in a
completely different way (that cleans up the code at the same time.)
2025-06-30 15:02:05 -04:00
John Scipione e362f604f4 Revert Interface Kit: BWindow owns (and deletes) menu sem and friends
This reverts commits:
39083dd0f7
0f430ba35c
ac55439364

Fixes #19553

Change-Id: I40f9a694079d4376221099e1d1b99208aeb207b7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9416
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-30 17:43:51 +00:00
John Scipione b515400884 BButton: Document AdoptSystemColors() and HasSystemColors() in the Haiku Book.
Change-Id: Ibe72cc796738e90beee9388eaba95342ab48640d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8898
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-30 14:57:07 +00:00
John Scipione 15c87be3ea ColorListView: Handle color dropped on unselected
Remove shared message handling from ColorListView,
you are expected to implement this yourself and these
message constants were not actually being used by
the message target.

Do color drop handling in Appearance and Terminal.
Handle all color drops in WasDropped().

Allow current selection to remain, only update color.
TODO Changing selection on external drops should be
fixed in BListView. Work-around in BColorListView.

Fixes #19562

Change-Id: Ic99bbb1288fd736778eac831d38e453122815abc
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9296
Reviewed-by: John Scipione <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2025-06-30 14:56:42 +00:00
John Scipione 0d91cd6464 Tracker: Add Paste item to volume window context menu
Change-Id: Iaa8b992011510364cf1eb9a3f0e6a6e749eefe5f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8955
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
2025-06-30 14:55:52 +00:00
John Scipione 76f3ceaadc Deskbar: Reduce window height by 1 in mini-mode
Adjust tray icons and clock to fit accordingly. Leaf menu height is
reduced by 1 in vertical mode to match.

This makes the overlap of maximized windows and Deskbar less noticeable,
especially in horizontal mini-mode.

Fixes #16231

Change-Id: I622d008ee093e018ebcb46e3c45647577f46184f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8833
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: John Scipione <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
2025-06-30 14:54:49 +00:00
Augustin Cavalier 83aa27ada6 netinet/in.h: Add IP_DONTFRAG socket option, and implement for IPv4.
To allow consumers to cause the "don't fragment" bit to be set in
all IPv4 packet headers.

There is no standard way of doing this, and different OSes expose
this option in different ways. Linux has "IP_MTU_DISCOVER", but it
takes an enum, not a boolean. NetBSD and OpenBSD appear to have
no socket option, instead they have "IP_MTUDISC", an option for
the "ip_output()" kernel-level network stack method.

"IP_DONTFRAG" sockopt originates on FreeBSD, and it seems macOS now
also supports it in version 11+. Windows has "IP_DONTFRAGMENT",
which, at a glance, appears to do the same thing. So this looks
like the one that makes the most sense to adopt.

This doesn't add any code to process MTU changes yet, though.

Change-Id: I492d22dbd0ee5f4ab35c600396ad3d3ec9f4f200
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9401
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier d31febdefa ICMP: Pass FRAGMENTATION_NEEDED and REDIRECT info up the stack.
Using the new net_error_data parameter to error_received.
Move the "update routing table" TODO into the IPv4 module,
since the ICMP module doesn't deal with the routing table
at all, while the IPv4 module already does.

Also add a missing endian swap in ICMP error_reply.

Change-Id: I1135eaa442f515d656143c76ab130be19cdcbaf2
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9400
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
Tested-by: Commit checker robot <[email protected]>
2025-06-28 17:22:47 +00:00
Augustin Cavalier f9a86ebeab network: Add net_error_data parameter to error_received.
Same structure as used for error_reply, to contain information
(like path MTU or redirect gateway) from the original error packet,
so that upper layers don't have to re-parse it.

Nothing uses or passes it around at present, but it will be used
in the next commits.

Change-Id: I38a3dec5506bdcb77a7850294082db7be74dd80f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9399
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Jérôme Duval <[email protected]>
2025-06-28 17:22:47 +00:00