Commit Graph

325 Commits

Author SHA1 Message Date
Ariel Abreu
cd6d3e1402
Actually destroy uthreads and prevent a false panic in procs.c 2020-09-22 12:21:55 -04:00
Ariel Abreu
334e1d6cd6
Don't access NULL if the klist has been destroyed 2020-09-22 08:24:30 -04:00
Ariel Abreu
1a163b5f24
Forgot to unlock task in thread_deallocate_complete!
That function is a sort of paraphrase of and glued-together-mess of XNU's `thread_deallocate_complete` and `thread_terminate_queue_invoke`, and I guess I accidentally deleted the `task_unlock` part.
2020-09-21 21:17:01 -04:00
Ariel Abreu
17628ac35e
Prevent a crash in ipc_port.c on shutdown 2020-09-21 19:57:32 -04:00
Ariel Abreu
c1202e5114
Add back a few more fixes I forgot about 2020-09-20 18:31:40 -04:00
Ariel Abreu
59d9424d8d
Move some stuff out of task_registry.c
(It doesn't really belong there)
2020-09-20 18:31:21 -04:00
Ariel Abreu
69d5db8e39
A few more fixes that allow binaries to load (again)
`vchroot` segfaults when running dyld, but let's take things one step at a time ;)
2020-09-18 15:32:21 -04:00
Ariel Abreu
cc21f7d3c0
Fix various issues with the updated kernel
It now runs! `darling shell` still doesn't run successfully, but it doesn't crash :)
2020-09-18 09:39:43 -04:00
Ariel Abreu
23f90472c3
Temporary workaround to build with Clang
This is only temporary so I can build everything for testing purposes; I'll look into removing the usage of blocks so we can use GCC later
2020-09-17 07:26:34 -04:00
Ariel Abreu
93c52c0986
It links! (with Clang); definitely check the description...
Major changes:
  * We now use BSD `proc` and `uthread` structures
  * We now use XNU's own pthread interface
    * This is done to increase compatibility with XNU code and make it easier to include XNU code that depends on it
    * This is pretty easy due to Apple having modularized the pthread implementation into a kext: all we have to do is pretend to be that kext
  * We compile the Blocks runtime (libclosure)
    * GCC doesn't support blocks, so the LKM only compiles with Clang at the moment
    * Unfortunately, Apple has decided to use them in the Mach code of XNU now.
      I didn't look into just how much they use them and how easy/difficult it would be to remove them,
      but that's the current situation.
  * We compile and use(?) IPC importance code

Other than that, there were many more small changes that needed to be made (which was to be expected; we jumped from XNU-3000-ish to XNU-6153).

This code has *not* been tested to run yet, and probably won't run successfully without further modifications.
2020-09-16 16:46:27 -04:00
Ariel Abreu
8f105c7be5
It compiles! (with Clang); plus: Makefile overhaul
All the files that were building with the previous version of XNU are now building again (with Clang), however, the module does not link yet (due to missing symbols; *lots* of them). A lot of them are probably new additions to XNU, but some of them are probably from me not knowing the `ifdef` certain things that should be.

Also, I completely overhauled the Makefile to make it simpler to manage settings and flags across files, folders, modules, and Linux/KBuild versions. I didn't add this feature (because I don't need it yet), but it can be easily extended to easily allow per-compiler flags

Full list of all missing symbols reported by `MODPOST`:

task_is_driver
thread_get_state_to_user
machine_exception
catch_mach_exception_raise_state_identity
turnstile_has_waiters
mach_vm_allocate_kernel
processor_start_from_user
catch_mach_exception_raise_state
task_violated_guard
hw_atomic_test_and_set32
task_is_importance_donor
catch_mach_exception_raise
ipc_importance_task_reference
work_interval_port_notify
random_bool_init
os_ref_retain_try_internal
mach_zone_info_for_zone
processor_exit_from_user
pqueue_pair_meld
mach_vm_page_range_query
turnstile_complete
mach_vm_wire_external
mach_vm_allocate_external
vm_allocate_kernel
ux_handler_init
uext_server
turnstile_waitq_add_thread_priority_queue
thread_depress_abort_from_user
turnstile_deallocate
_Block_object_assign
turnstile_cleanup
turnstile_kernel_update_inheritor_on_wake_locked
_pthread_priority_normalize_for_ipc
filt_ipc_kqueue_turnstile
lck_spin_assert
IOTaskHasEntitlement
thread_get_requested_qos
task_watchport_elem_deallocate
os_ref_init_count_internal
lck_mtx_lock_spin_always
turnstile_update_inheritor_complete
task_inspect
thread_bootstrap_return
thread_setstatus_from_user
turnstile_recompute_priority_locked
mach_vm_remap_external
zone_require
thread_getstatus_to_user
turnstile_hash_bucket_unlock
_NSConcreteGlobalBlock
filt_machport_kqueue_has_turnstile
mach_continuous_time
ipc_importance_init
turnstile_update_inheritor_locked
turnstile_alloc
ipc_importance_send
ipc_importance_thread_call_init
bank_get_bank_ledger_thread_group_and_persona
turnstile_hash_bucket_lock
filt_machport_turnstile_prepare_lazily
turnstile_deallocate_safe
os_ref_release_barrier_internal
turnstile_reference
vm_map_wire_kernel
thread_deallocate_safe
turnstile_stats_update
thread_set_pending_block_hint
task_info_from_user
thread_inspect_deallocate
catch_exc_subsystem
ux_handler_stop
lck_mtx_assert
mach_vm_map_external
filt_machport_stash_port
ipc_importance_task_hold_internal_assertion
lck_spin_lock_grp
_Block_object_dispose
ipc_importance_check_circularity
task_restartable_subsystem
ipc_importance_task_drop_internal_assertion
random_bool_gen_bits
turnstile_update_inheritor
lck_spin_try_lock_grp
ipc_importance_task_release
kdp_lck_spin_is_acquired
ipc_importance_receive
os_ref_retain_internal
task_inspect_deallocate
_NSConcreteStackBlock
task_get_exc_guard_behavior
pid_from_task
sched_thread_unpromote_reason
memory_entry_subsystem
turnstile_prepare
act_get_state_to_user
sched_thread_promote_reason
task_set_exc_guard_behavior
ipc_importance_task_is_any_receiver_type
knote_vanish
thread_user_promotion_qos_for_pri
2020-09-08 10:06:49 -04:00
Ariel Abreu
fe1ee5ff55
Add CMakeLists.txt for libkxld
I'm not entirely sure if Darling *should* have this, but it can't hurt to build it, right? Besides, if we end up not needing it, we can just not add it with `add_subdirectory` in Darling's `src/CMakeLists.txt`
2020-07-05 18:06:01 -04:00
Ariel Abreu
fdd3038bbe
Merge remote-tracking branch 'origin/master' into update-sources 2020-06-15 14:42:39 -04:00
Ariel Abreu
2471b424ea
Add macros for log functions needed in libc 2020-06-15 14:00:50 -04:00
Ariel Abreu
f34b59112a
Fix OS log headers to allow trace_base.h to be included in libtrace 2020-06-08 22:03:25 -04:00
Ariel Abreu
546c710045
Add private os_log_pack API declarations 2020-05-18 09:52:11 -04:00
Lubos Dolezel
8153f635cd Fix build on <Linux 5.4 2020-05-15 14:16:30 +02:00
Lubos Dolezel
9cf6c731ed Add proper dependency on rtsig.h in case someone builds LKM first 2020-05-14 18:46:33 +02:00
Ariel Abreu
b2a7d4d3b0
xnu-6153.61.1 2020-05-14 11:17:09 -04:00
Lubos Dolezel
b87013326f Fix a kernel warning (darlinghq/darling#785) 2020-05-11 09:18:46 +02:00
Lubos Dolezel
cd9430c6bd Fix a bug in ovl_dentry_to_fid() which caused overlayfs not play well with fanotify 2020-05-04 21:05:36 +02:00
Lubos Dolezel
c1abe811c5 Fix a crash when FS cannot decode passed file handle 2020-05-04 18:21:55 +02:00
Thomas A
e8e2c70789 Add darling-overlay.mod to gitignore 2020-05-04 08:42:34 -07:00
Lubos Dolezel
72c08bbcbe Fix dentry leaks 2020-05-04 16:57:45 +02:00
Lubos Dolezel
f0b6a4fa33 Fix some reference/lock bugs 2020-05-04 16:48:07 +02:00
Lubos Dolezel
d2e68bab6e Fix a bad merge 2020-05-03 22:18:58 +02:00
Lubos Dolezel
4ab56441a2 Provide faulting address for EXC_BAD_ACCESS 2020-05-03 22:13:37 +02:00
Lubos Dolezel
bf32e6fbfe Code for dispatch queue name support in LLDB 2020-05-03 22:13:36 +02:00
Lubos Dolezel
80392113f3 Cleanup 2020-05-03 22:13:06 +02:00
Lubos Dolezel
fa3dc6f575 Implement task_info(MACH_TASK_BASIC_INFO) 2020-05-03 22:13:06 +02:00
Lubos Dolezel
985aa184d0 Implement mach_vm_remap() 2020-05-03 22:13:06 +02:00
Lubos Dolezel
9249e54934 Change thread_block() behavior with regard to signals and interruptible waiting.
When a message is being sent from inside the kernel to a kernel thread,
mach_kernelrpc.c expects that re-sending the message will not be interrupted again.

Without this change, it would loop forever.
2020-05-03 22:13:06 +02:00
Lubos Dolezel
4a3f640ede Debugger seemingly working again 2020-05-03 22:13:05 +02:00
Lubos Dolezel
e5ebe417e0 Signal reprocessing seems to work 2020-05-03 22:12:44 +02:00
Lubos Dolezel
3c646dabf7 More work, thupdate... 2020-05-03 22:11:50 +02:00
Lubos Dolezel
c27094aaa4 Proper kernel_task refcount 2020-05-03 22:11:24 +02:00
Lubos Dolezel
feb28cca43 ux_exception kthread stability fix 2020-05-03 22:11:24 +02:00
Lubos Dolezel
49b8217b49 Module now builds again 2020-05-03 22:11:24 +02:00
Lubos Dolezel
85a10157e5 sigprocess work progress 2020-05-03 22:10:53 +02:00
Ariel Abreu
c3d66a577b
Provide our own implementation of ovl_lookup_positive_unlocked for older kernels
This fixes the crash on older kernels when trying to access an invalid dentry
2020-05-01 12:27:01 -04:00
Lubos Dolezel
a21d11f4c0 More overlayfs build fixes for older kernels 2020-04-27 14:50:11 +02:00
Lubos Dolezel
00617c069b overlayfs build on <linux-5.2 2020-04-27 14:35:42 +02:00
Lubos Dolezel
f049bed9dc Build darling-overlay as a separate LKM 2020-04-27 10:10:54 +02:00
Lubos Dolezel
ef3d7e066c Integrate overlayfs with Darling's fake UID 2020-04-24 11:27:54 +02:00
Lubos Dolezel
d01d4d4e5c Overlayfs changes for Darling 2020-04-22 21:03:33 +02:00
Lubos Dolezel
7e227bffef Import overlayfs from Linux 2020-04-22 21:03:09 +02:00
Andrew Hyatt
d3169a4e30
Correct version check
darlinghq/darling#755
2020-04-18 10:29:49 -04:00
Andrew Hyatt
a1b6f512aa
Merge pull request #14 from Newbytee/fix-debian-10-build
Preliminary Debian 10 build fix
2020-04-18 09:41:40 -04:00
Newbyte
a8d24e6b1e Preliminary Debian 10 build fix 2020-04-17 16:33:28 +02:00
Lubos Dolezel
7c476f8275 Fix some weird crashes 2020-04-16 00:49:59 +02:00