Difference between revisions of "Kernel Syscalls"

From The iPhone Wiki
Jump to: navigation, search
(Mach: Added mach trap usage)
(List of system calls from iOS 6.0b1 - watch this space for more)
Line 54: Line 54:
 
<pre>
 
<pre>
   
$ ./fsysent ~/Documents/projects/iOS.5.1.iPod4.kernel
+
$ ./fsysent ~/Documents/projects/iOS.6.0b1.iPod4.kernel
  +
mach_trap_table offset in file (for patching purposes): 3064992 (0x2ec4a0)
This is an ARM binary. Applying iOS kernel signatures
 
This appears to be XNU 1878.11.8
+
This appears to be XNU 2107.1.78
  +
syscall 801b3aa4 T
 
fork 801a15cc T
+
exit 801d32dc T
read 801b3ac0 T
+
fork 801d61d4 T
write 801b3ea0 T
+
read 801e9d7c T
open 800a1e64 T
+
write 801ea150 T
close 80197570 T
+
open 800b12f0 T
wait4 8019f464 T
+
close 801cb904 T
8 old creat 801b3aa4 T
+
wait4 801d3f10 T
link 800a23a4 T
+
8 old creat 801e9d5c T
unlink 800a2aa8 T
+
link 800b1804 T
11 old execv 801b3aa4 T
+
unlink 800b1f0c T
chdir 800a175c T
+
11 old execv 801e9d5c T
fchdir 800a15f4 T
+
chdir 800b0be0 T
mknod 800a1f64 T
+
fchdir 800b0a70 T
chmod 800a3598 T
+
mknod 800b13d8 T
chown 800a3714 T
+
chmod 800b2a5c T
17 old break 801b3aa4 T
+
chown 800b2bb8 T
getfsstat 800a1390 T
+
17 old break 801e9d5c T
19 old lseek 801b3aa4 T
+
getfsstat 800b080c T
getpid 801a5838 T
+
19 old lseek 801e9d5c T
21 old mount 801b3aa4 T
+
getpid 801daa60 T
22 old umount 801b3aa4 T
+
21 old mount 801e9d5c T
setuid 801a5aec T
+
22 old umount 801e9d5c T
getuid 801a58bc T
+
setuid 801dad14 T
geteuid 801a58cc T
+
getuid 801daae4 T
ptrace 801b0a9c T
+
geteuid 801daaf4 T
recvmsg 801cfde4 T
+
ptrace 801e6924 T
sendmsg 801cf958 T
+
recvmsg 802090f4 T
recvfrom 801cfa40 T
+
sendmsg 80208c3c T
accept 801cf32c T
+
recvfrom 80208d20 T
getpeername 801d00a8 T
+
accept 802085f4 T
getsockname 801cfff8 T
+
getpeername 802093c0 T
access 800a2f14 T
+
getsockname 80209310 T
chflags 800a336c T
+
access 800b23c8 T
fchflags 800a343c T
+
chflags 800b2844 T
sync 800a0e5c T
+
fchflags 800b290c T
kill 801a91b0 T
+
sync 800b02a0 T
38 old stat 801b3aa4 T
+
kill 801de620 T
getppid 801a5840 T
+
38 old stat 801e9d5c T
40 old lstat 801b3aa4 T
+
getppid 801daa68 T
dup 80195890 T
+
40 old lstat 801e9d5c T
pipe 801b6a00 T
+
dup 801c9a94 T
getegid 801a5944 T
+
pipe 801ec3dc T
profil 801b3400 T
+
getegid 801dab6c T
45 old ktrace 801b3aa4 T
+
profil 801e9d5c T
sigaction 801a8348 T
+
45 old ktrace 801e9d5c T
getgid 801a5934 T
+
sigaction 801dd73c T
sigprocmask 801a8868 T
+
getgid 801dab5c T
getlogin 801a66cc T
+
sigprocmask 801ddc80 T
setlogin 801a6728 T
+
getlogin 801db93c T
acct 801908f0 T
+
setlogin 801db9b4 T
sigpending 801a8a0c T
+
acct 801c447c T
sigaltstack 801a90f4 T
+
sigpending 801dde24 T
ioctl 801b426c T
+
sigaltstack 801de564 T
reboot 801b0a2c T
+
ioctl 801ea514 T
revoke 800a4d8c T
+
reboot 801e6888 T
symlink 800a2620 T
+
revoke 800b4320 T
readlink 800a328c T
+
symlink 800b1a74 T
execve 8019e49c T
+
readlink 800b2748 T
umask 800a4d64 T
+
execve 801d2cb0 T
chroot 800a1824 T
+
umask 800b42f8 T
62 old fstat 801b3aa4 T
+
chroot 800b0cb0 T
  +
62 old fstat 801e9d5c T
63 used internally , reserved 801b3aa4 T
 
  +
63 used internally , reserved 801e9d5c T
64 old getpagesize 801b3aa4 T
 
  +
64 old getpagesize 801e9d5c T
msync 801a20c0 T
 
  +
getitimer 801e6228 T
87 old gethostname 801b3aa4 T
 
  +
88 old sethostname 801e9d5c T
getdtablesize 80195480 T
 
  +
103 old sigreturn 801e9d5c T
bind 801cee98 T
 
  +
110 old sigsetmask 801e9d5c T
sigsuspend 801a8a34 T
 
  +
130 old ftruncate 801e9d5c T
flock 801989e4 T
 
mkfifo 800a2254 T
+
flock 801cce8c T
sendto 801cf67c T
+
mkfifo 800b16b4 T
shutdown 801cfee0 T
+
sendto 80208960 T
socketpair 801cf534 T
+
shutdown 802091f8 T
mkdir 800a46b4 T
+
socketpair 80208804 T
rmdir 800a46fc T
+
mkdir 800b3c38 T
utimes 800a38f0 T
+
rmdir 800b3c78 T
futimes 800a3a70 T
+
utimes 800b2d7c T
adjtime 801b0338 T
+
futimes 800b2f50 T
  +
adjtime 801e6198 T
141 old getpeername 801b3aa4 T
 
  +
141 old getpeername 801e9d5c T
gethostuuid 801b5c44 T
 
  +
gethostuuid 801ebe9c T
143 old sethostid 801b3aa4 T
 
  +
150 old getsockname 801e9d5c T
getpgid 801a5850 T
 
pwrite 801b4008 T
+
pread 801e9f6c T
nfssvc 801b3aa4 T
+
pwrite 801ea2c8 T
  +
nfssvc 801e9d5c T
156 old getdirentries 801b3aa4 T
 
  +
156 old getdirentries 801e9d5c T
statfs 800a0eec T
 
  +
unmount 800afe08 T
160 old async_daemon 801b3aa4 T
 
  +
160 old async_daemon 801e9d5c T
getfh 801b3aa4 T
 
  +
getfh 801e9d5c T
162 old getdomainname 801b3aa4 T
 
163 old setdomainname 801b3aa4 T
+
162 old getdomainname 801e9d5c T
  +
163 old setdomainname 801e9d5c T
164 801b3aa4 T
 
166 old exportfs 801b3aa4 T
+
quotactl 800b033c T
mount 8009fd10 T
+
166 old exportfs 801e9d5c T
168 old ustat 801b3aa4 T
+
mount 800aefe8 T
csops 801a47bc T
+
168 old ustat 801e9d5c T
170 old table 801b3aa4 T
+
csops 801d9824 T
171 old wait3 801b3aa4 T
+
170 old table 801d9d10 T
172 old rpause 801b3aa4 T
+
171 old wait3 801e9d5c T
waitid 8019f860 T
+
172 old rpause 801e9d5c T
174 old getdents 801b3aa4 T
+
waitid 801d4308 T
175 old gc_control 801b3aa4 T
+
174 old getdents 801e9d5c T
  +
175 old gc_control 801e9d5c T
add_profil 801b3404 T
 
fdatasync 800a3cd8 T
+
186 801e9d5c T
stat 800a2fec T
+
fdatasync 800b31cc T
fstat 801977f8 T
+
stat 800b24a4 T
lstat 800a3134 T
+
fstat 801cbb98 T
pathconf 800a3228 T
+
lstat 800b25f0 T
fpathconf 80197858 T
+
pathconf 800b26e4 T
193 801b3aa4 T
+
fpathconf 801cbbf4 T
getrlimit 801a75d4 T
+
193 801e9d5c T
setrlimit 801a6eb8 T
+
getrlimit 801dc8c8 T
getdirentries 800a4928 T
+
setrlimit 801dc190 T
mmap 801a1b84 T
+
getdirentries 800b3eb0 T
198 __syscall 801b3aa4 T
+
mmap 801d6814 T
lseek 800a2b20 T
+
198 __syscall 801e9d5c T
truncate 800a3ac4 T
+
lseek 800b1f84 T
ftruncate 800a3b90 T
+
truncate 800b2fd0 T
__sysctl 801ab798 T
+
ftruncate 800b3090 T
mlock 801a2418 T
+
__sysctl 801e0ccc T
munlock 801a246c T
+
mlock 801d7074 T
undelete 800a27c8 T
+
munlock 801d70cc T
ATsocket 801b3aa4 T
+
undelete 800b1c0c T
ATgetmsg 801b3aa4 T
+
ATsocket 801e9d5c T
ATputmsg 801b3aa4 T
+
ATgetmsg 801e9d5c T
ATPsndreq 801b3aa4 T
+
ATputmsg 801e9d5c T
ATPsndrsp 801b3aa4 T
+
ATPsndreq 801e9d5c T
ATPgetreq 801b3aa4 T
+
ATPsndrsp 801e9d5c T
ATPgetrsp 801b3aa4 T
+
ATPgetreq 801e9d5c T
  +
ATPgetrsp 801e9d5c T
213 Reserved for AppleTalk 801b3aa4 T
 
  +
213 Reserved for AppleTalk 801e9d5c T
214 801b3aa4 T
 
  +
setattrlist 8009b058 T
getdirentriesattr 800a4e80 T
 
  +
getdirentriesattr 800b4408 T
exchangedata 800a5018 T
 
  +
exchangedata 800b45c4 T
224 old checkuseraccess / fsgetpath ( which moved to 427 ) 801b3aa4 T
 
  +
224 old checkuseraccess / fsgetpath ( which moved to 427 ) 801e9d5c T
searchfs 800a5258 T
 
ffsctl 800a5f78 T
+
posix_spawn 801d1d74 T
246 801b3aa4 T
+
ffsctl 800b539c T
nfsclnt 801b3aa4 T
+
246 801e9d5c T
fhopen 801b3aa4 T
+
nfsclnt 801e9d5c T
249 801b3aa4 T
+
fhopen 801e9d5c T
minherit 801a222c T
+
249 801e9d5c T
semsys 801b3aa4 T
+
minherit 801d6e84 T
msgsys 801b3aa4 T
+
semsys 801e9d5c T
shmsys 801b3aa4 T
+
msgsys 801e9d5c T
semctl 801b3aa4 T
+
shmsys 801e9d5c T
semget 801b3aa4 T
+
semctl 801e9d5c T
semop 801b3aa4 T
+
semget 801e9d5c T
257 801b3aa4 T
+
semop 801e9d5c T
msgctl 801b3aa4 T
+
257 801e9d5c T
msgget 801b3aa4 T
+
msgctl 801e9d5c T
msgsnd 801b3aa4 T
+
msgget 801e9d5c T
msgrcv 801b3aa4 T
+
msgsnd 801e9d5c T
shmat 801b3aa4 T
+
msgrcv 801e9d5c T
shmctl 801b3aa4 T
+
shmat 801e9d5c T
shmdt 801b3aa4 T
+
shmctl 801e9d5c T
shmget 801b3aa4 T
+
shmdt 801e9d5c T
shm_open 801d3b34 T
+
shmget 801e9d5c T
shm_unlink 801d45d0 T
+
shm_open 8020d2c0 T
sem_open 801d3110 T
+
shm_unlink 8020dda0 T
sem_close 801d379c T
+
sem_open 8020c718 T
sem_unlink 801d35cc T
+
sem_close 8020ceb0 T
sem_wait 801d37f8 T
+
sem_unlink 8020cc78 T
sem_trywait 801d38bc T
+
sem_wait 8020cf08 T
sem_post 801d395c T
+
sem_trywait 8020cfd0 T
sem_getvalue 801d39fc T
+
sem_post 8020d074 T
sem_init 801d39f4 T
+
sem_getvalue 8020d118 T
sem_destroy 801d39f8 T
+
sem_init 8020d110 T
open_extended 800a1cb8 T
+
sem_destroy 8020d114 T
umask_extended 800a4d14 T
+
open_extended 800b1144 T
stat_extended 800a2f98 T
+
umask_extended 800b42a8 T
lstat_extended 800a30e0 T
+
stat_extended 800b244c T
fstat_extended 801975e4 T
+
lstat_extended 800b2598 T
chmod_extended 800a347c T
+
fstat_extended 801cb97c T
fchmod_extended 800a35d4 T
+
chmod_extended 800b294c T
access_extended 800a2c54 T
+
fchmod_extended 800b2a90 T
  +
access_extended 800b20bc T
settid 801a6358 T
 
  +
identitysvc 801e9d5c T
shared_region_check_np 801e0a68 T
 
  +
shared_region_check_np 8021ab68 T
shared_region_map_np 801b3aa4 T
 
  +
shared_region_map_np 801e9d5c T
vm_pressure_monitor 801e1150 T
 
  +
vm_pressure_monitor 8021b2cc T
psynch_rw_longrdlock 801da274 T
 
  +
psynch_rw_longrdlock 8021415c T
psynch_rw_yieldwrlock 801da79c T
 
  +
psynch_rw_yieldwrlock 80214408 T
psynch_rw_downgrade 801daa38 T
 
  +
psynch_rw_downgrade 80214410 T
psynch_rw_upgrade 801daa34 T
 
  +
psynch_rw_upgrade 8021440c T
psynch_mutexwait 801d77d0 T
 
  +
psynch_rw_unlock 80214414 T
psynch_rw_unlock2 801dad10 T
 
  +
psynch_rw_unlock2 8021470c T
getsid 801a5880 T
 
  +
getsid 801daaa8 T
settid_with_pid 801a63f8 T
 
  +
settid_with_pid 801db620 T
312 old __pthread_cond_timedwait 801d95e8 T
 
  +
312 old __pthread_cond_timedwait 80213430 T
aio_fsync 80191278 T
 
  +
lio_listio 801c54f4 T
321 old __pthread_cond_wait 801b3aa4 T
 
  +
321 old __pthread_cond_wait 801e9d5c T
iopolicysys 801a795c T
 
  +
__pthread_kill 801de298 T
__pthread_sigmask 801a8e94 T
 
  +
__pthread_sigmask 801de2f8 T
__sigwait 801a8f38 T
 
  +
__sigwait 801de3a8 T
__disable_threadsignal 801a8b48 T
 
  +
__disable_threadsignal 801ddf74 T
__pthread_markcancel 801a8b64 T
 
  +
__pthread_markcancel 801ddf90 T
__pthread_canceled 801a8bac T
 
  +
__pthread_canceled 801ddfd8 T
__semwait_signal 801a8d30 T
 
  +
__semwait_signal 801de178 T
335 old utrace 801b3aa4 T
 
__pthread_chdir 800a181c T
+
getfsstat64 800b09b8 T
__pthread_fchdir 800a1754 T
+
__pthread_chdir 800b0ca8 T
  +
__pthread_fchdir 800b0bd8 T
; -----------------------
 
  +
audit 801c0a18 T
; The following are unused in iOS - symbols are stubs returning 0x4E (ENOSYS)
 
352 801b3aa4 T
+
getauid 801c0a20 T
getauid 8018d998 T
+
setauid 801c0a24 T
setauid 8018d99c T
+
getaudit 801e9d5c T
getaudit 8018d9a0 T
+
setaudit 801e9d5c T
setaudit 8018d9a4 T
+
getaudit_addr 801c0a28 T
getaudit_addr 8018d9a8 T
+
setaudit_addr 801c0a2c T
setaudit_addr 8018d9ac T
+
auditctl 801c0a30 T
  +
bsdthread_create 80215260 T
auditctl 8018d9b0 T
 
  +
bsdthread_terminate 802154d8 T
; ---------------------
 
  +
kqueue 801cddec T
bsdthread_create 801db740 T
 
  +
kevent 801cde6c T
bsdthread_terminate 801db9b4 T
 
  +
bsdthread_register 8021553c T
lchown 800a3818 T
 
  +
workq_kernreturn 802165f8 T
bsdthread_register 801dba18 T
 
  +
__old_semwait_signal 801de04c T
workq_kernreturn 801dccac T
 
  +
__old_semwait_signal_nocancel 801de080 T
kevent64 80199bd4 T
 
  +
thread_selfid 80216afc T
__old_semwait_signal 801a8c1c T
 
  +
ledger 801ebf04 T
__old_semwait_signal_nocancel 801a8c54 T
 
375 801b3aa4 T
+
377 801e9d5c T
376 801b3aa4 T
+
378 801e9d5c T
377 801b3aa4 T
+
379 801e9d5c T
378 801b3aa4 T
+
__mac_execve 801d2cd0 T
379 801b3aa4 T
+
__mac_syscall 8027b874 T
__mac_execve 8019e4bc T
+
__mac_get_file 8027b51c T
__mac_syscall 80244734 T
+
__mac_set_file 8027b764 T
__mac_get_file 802443d4 T
+
__mac_get_link 8027b640 T
__mac_set_file 80244628 T
+
__mac_set_link 8027b864 T
__mac_get_link 80244504 T
+
__mac_get_proc 8027b010 T
__mac_set_link 80244724 T
+
__mac_set_proc 8027b0d0 T
__mac_get_proc 80243eb0 T
+
__mac_get_fd 8027b3c8 T
__mac_set_proc 80243f74 T
+
__mac_set_fd 8027b650 T
__mac_get_fd 80244280 T
+
__mac_get_pid 8027af44 T
__mac_set_fd 80244514 T
+
__mac_get_lcid 8027b184 T
__mac_get_pid 80243ddc T
+
__mac_get_lctx 8027b248 T
__mac_get_lcid 80244030 T
+
__mac_set_lctx 8027b304 T
__mac_get_lctx 802440fc T
+
setlcid 801dba7c T
__mac_set_lctx 802441c0 T
+
getlcid 801dbb64 T
setlcid 801a67cc T
+
read_nocancel 801e9d9c T
getlcid 801a68ac T
+
write_nocancel 801ea170 T
read_nocancel 801b3ae0 T
+
open_nocancel 800b1368 T
write_nocancel 801b3ec0 T
+
close_nocancel 801cb920 T
open_nocancel 800a1ee8 T
+
wait4_nocancel 801d3f30 T
close_nocancel 8019758c T
+
recvmsg_nocancel 80209114 T
wait4_nocancel 8019f484 T
+
sendmsg_nocancel 80208c5c T
  +
recvfrom_nocancel 80208d40 T
recvmsg_nocancel 801cfe04 T
 
  +
msync_nocancel 801d6d3c T
recvfrom_nocancel 801cfa60 T
 
  +
connect_nocancel 8020862c T
sigsuspend_nocancel 801a8ae4 T
 
  +
sigsuspend_nocancel 801ddf08 T
readv_nocancel 801b3d6c T
 
  +
msgrcv_nocancel 801e9d5c T
sem_wait_nocancel 801d3814 T
 
  +
sem_wait_nocancel 8020cf24 T
aio_suspend_nocancel 801916c0 T
 
  +
aio_suspend_nocancel 801c52e0 T
__sigwait_nocancel 801a8f70 T
 
  +
__sigwait_nocancel 801de3e0 T
__semwait_signal_nocancel 801a8d68 T
 
  +
__semwait_signal_nocancel 801de1ac T
__mac_mount 8009fd34 T
 
  +
fsgetpath 800b5c0c T
audit_session_self 8018d984 T
 
  +
audit_session_self 801c0a0c T
audit_session_join 8018d988 T
 
  +
audit_session_join 801c0a10 T
fileport_makeport 80198ad4 T
 
  +
fileport_makeport 801ccf70 T
fileport_makefd 80198c58 T
 
  +
fileport_makefd 801cd0f4 T
audit_session_port 8018d98c T
 
  +
audit_session_port 801c0a14 T
pid_suspend 801e084c T
 
  +
pid_hibernate 8021aa2c T
pid_shutdown_sockets 801e0984 T
 
  +
pid_shutdown_sockets 8021aa84 T
437 old shared_region_slide_np 801b3aa4 T
 
  +
437 old shared_region_slide_np 801e9d5c T
shared_region_map_and_slide_np 801e1008 T
 
Sysent offset in file (for patching purposes): 2931636 (0x2cbbb4)
+
Sysent offset in file (for patching purposes): 3076288 (0x2ef0c0)
exit 8019e924 T
+
syscall 801e9d5c T
vfork 801a0cfc T
+
msync 801d6d24 T
67 old vread 801b3aa4 T
+
vfork 801d586c T
68 old vwrite 801b3aa4 T
+
67 old vread 801e9d5c T
69 old sbrk 801b3aa4 T
+
68 old vwrite 801e9d5c T
70 old sstk 801b3aa4 T
+
69 old sbrk 801e9d5c T
71 old mmap 801b3aa4 T
+
70 old sstk 801e9d5c T
72 old vadvise 801b3aa4 T
+
71 old mmap 801e9d5c T
munmap 801a216c T
+
72 old vadvise 801e9d5c T
mprotect 801a21a4 T
+
munmap 801d6dd0 T
madvise 801a2264 T
+
mprotect 801d6e04 T
76 old vhangup 801b3aa4 T
+
madvise 801d6ebc T
77 old vlimit 801b3aa4 T
+
76 old vhangup 801e9d5c T
mincore 801a22d0 T
+
77 old vlimit 801e9d5c T
getgroups 801a5954 T
+
mincore 801d6f28 T
setgroups 801a6610 T
+
getgroups 801dab7c T
getpgrp 801a5848 T
+
setgroups 801db880 T
setpgid 801a59f4 T
+
getpgrp 801daa70 T
setitimer 801b0518 T
+
setpgid 801dac1c T
84 old wait 801b3aa4 T
+
setitimer 801e6370 T
swapon 801e0548 T
+
84 old wait 801e9d5c T
getitimer 801b03c8 T
+
swapon 8021a638 T
88 old sethostname 801b3aa4 T
+
87 old gethostname 801e9d5c T
dup2 80195bc4 T
+
getdtablesize 801c966c T
91 old getdopt 801b3aa4 T
+
dup2 801c9ec0 T
fcntl 80195fc4 T
+
91 old getdopt 801e9d5c T
select 801b44fc T
+
fcntl 801ca2d8 T
94 old setdopt 801b3aa4 T
+
select 801ea7c0 T
fsync 800a3c60 T
+
94 old setdopt 801e9d5c T
setpriority 801a6a24 T
+
fsync 800b3154 T
socket 801cedc8 T
+
setpriority 801dbce8 T
connect 801cf34c T
+
socket 8020809c T
99 old accept 801b3aa4 T
+
connect 80208614 T
getpriority 801a6918 T
+
99 old accept 801e9d5c T
101 old send 801b3aa4 T
+
getpriority 801dbbdc T
102 old recv 801b3aa4 T
+
101 old send 801e9d5c T
103 old sigreturn 801b3aa4 T
+
102 old recv 801e9d5c T
setsockopt 801cff10 T
+
bind 80208168 T
listen 801cf00c T
+
setsockopt 80209228 T
107 old vtimes 801b3aa4 T
+
listen 802082d4 T
108 old sigvec 801b3aa4 T
+
107 old vtimes 801e9d5c T
109 old sigblock 801b3aa4 T
+
108 old sigvec 801e9d5c T
110 old sigsetmask 801b3aa4 T
+
109 old sigblock 801e9d5c T
112 old sigstack 801b3aa4 T
+
sigsuspend 801dde4c T
113 old recvmsg 801b3aa4 T
+
112 old sigstack 801e9d5c T
114 old sendmsg 801b3aa4 T
+
113 old recvmsg 801e9d5c T
115 old vtrace 801b3aa4 T
+
114 old sendmsg 801e9d5c T
gettimeofday 801b01d8 T
+
115 old vtrace 801e9d5c T
getrusage 801a7798 T
+
gettimeofday 801e6038 T
getsockopt 801cff74 T
+
getrusage 801dca80 T
119 old resuba 801b3aa4 T
+
getsockopt 8020928c T
readv 801b3d4c T
+
119 old resuba 801e9d5c T
writev 801b40f4 T
+
readv 801ea008 T
settimeofday 801b0238 T
+
writev 801ea3a8 T
fchown 800a3830 T
+
settimeofday 801e6094 T
fchmod 800a36dc T
+
fchown 800b2cc8 T
125 old recvfrom 801b3aa4 T
+
fchmod 800b2b8c T
setreuid 801a5e40 T
+
125 old recvfrom 801e9d5c T
setregid 801a61d8 T
+
setreuid 801db060 T
rename 800a3e34 T
+
setregid 801db3f4 T
129 old truncate 801b3aa4 T
+
rename 800b3344 T
130 old ftruncate 801b3aa4 T
+
129 old truncate 801e9d5c T
144 old getrlimit 801b3aa4 T
+
143 old sethostid 801e9d5c T
145 old setrlimit 801b3aa4 T
+
144 old getrlimit 801e9d5c T
146 old killpg 801b3aa4 T
+
145 old setrlimit 801e9d5c T
setsid 801a59b0 T
+
146 old killpg 801e9d5c T
148 old setquota 801b3aa4 T
+
setsid 801dabd8 T
149 old qquota 801b3aa4 T
+
148 old setquota 801e9d5c T
150 old getsockname 801b3aa4 T
+
149 old qquota 801e9d5c T
setprivexec 801a5820 T
+
getpgid 801daa78 T
pread 801b3ca4 T
+
setprivexec 801daa48 T
fstatfs 800a117c T
+
statfs 800b0340 T
unmount 800a09f0 T
+
fstatfs 800b05f8 T
quotactl 800a0ee8 T
+
164 801e9d5c T
177 801b3aa4 T
+
add_profil 801e9d5c T
178 801b3aa4 T
+
177 801e9d5c T
179 801b3aa4 T
+
178 801e9d5c T
kdebug_trace 8018e964 T
+
179 801e9d5c T
setgid 801a5fe0 T
+
kdebug_trace 801c1d58 T
setegid 801a60ec T
+
setgid 801db1f8 T
seteuid 801a5d48 T
+
setegid 801db304 T
sigreturn 801e2cb0 T
+
seteuid 801daf64 T
chud 801e1acc T
+
sigreturn 8021cfa8 T
186 801b3aa4 T
+
chud 8021bcb8 T
215 801b3aa4 T
+
214 801e9d5c T
mkcomplex 800a1d9c T
+
215 801e9d5c T
statv 801b3aa4 T
+
mkcomplex 800b1224 T
lstatv 801b3aa4 T
+
statv 801e9d5c T
fstatv 801b3aa4 T
+
lstatv 801e9d5c T
getattrlist 8008d1c4 T
+
fstatv 801e9d5c T
setattrlist 8008d23c T
+
getattrlist 8009afe0 T
delete 800a2ae4 T
+
searchfs 800b4804 T
copyfile 800a3cf4 T
+
delete 800b1f48 T
fgetattrlist 8008a6c8 T
+
copyfile 800b31e8 T
fsetattrlist 8008d904 T
+
fgetattrlist 80098408 T
poll 801b4d04 T
+
fsetattrlist 8009b760 T
watchevent 801b5604 T
+
poll 801eaf24 T
waitevent 801b579c T
+
watchevent 801eb84c T
modwatch 801b5914 T
+
waitevent 801eb9f0 T
getxattr 800a6048 T
+
modwatch 801ebb60 T
fgetxattr 800a6160 T
+
getxattr 800b5478 T
setxattr 800a6240 T
+
fgetxattr 800b55b4 T
fsetxattr 800a6328 T
+
setxattr 800b56b4 T
removexattr 800a6408 T
+
fsetxattr 800b57c0 T
fremovexattr 800a64b0 T
+
removexattr 800b58bc T
listxattr 800a654c T
+
fremovexattr 800b5984 T
flistxattr 800a6610 T
+
listxattr 800b5a44 T
fsctl 800a5964 T
+
flistxattr 800b5b28 T
initgroups 801a64d0 T
+
fsctl 800b4cfc T
posix_spawn 8019d658 T
+
initgroups 801db6fc T
gettid 801a58dc T
+
settid 801db580 T
setsgroups 801a6620 T
+
gettid 801dab04 T
getsgroups 801a59a8 T
+
setsgroups 801db890 T
setwgroups 801a6624 T
+
getsgroups 801dabd0 T
getwgroups 801a59ac T
+
setwgroups 801db894 T
mkfifo_extended 800a21a8 T
+
getwgroups 801dabd4 T
mkdir_extended 800a44ac T
+
mkfifo_extended 800b1610 T
identitysvc 801b3aa4 T
+
mkdir_extended 800b3a4c T
psynch_mutexdrop 801d85f8 T
+
psynch_mutexwait 80211374 T
psynch_cvbroad 801d864c T
+
psynch_mutexdrop 80212338 T
psynch_cvsignal 801d8bb4 T
+
psynch_cvbroad 8021238c T
psynch_cvwait 801d9020 T
+
psynch_cvsignal 80212970 T
psynch_rw_rdlock 801d96ec T
+
psynch_cvwait 80212df8 T
psynch_rw_wrlock 801da508 T
+
psynch_rw_rdlock 80213530 T
psynch_rw_unlock 801daa3c T
+
psynch_rw_wrlock 80214160 T
aio_return 8019143c T
+
aio_fsync 801c4e60 T
aio_suspend 801916a0 T
+
aio_return 801c5038 T
aio_cancel 80190e24 T
+
aio_suspend 801c52c0 T
aio_error 801911d4 T
+
aio_cancel 801c49d8 T
aio_read 8019141c T
+
aio_error 801c4db4 T
aio_write 801918a4 T
+
aio_read 801c5018 T
lio_listio 801918c4 T
+
aio_write 801c54d4 T
323 801df090 T
+
iopolicysys 801dcc74 T
mlockall 801a24ac T
+
323 80218edc T
munlockall 801a24b0 T
+
mlockall 801d7108 T
326 801b3aa4 T
+
munlockall 801d710c T
issetugid 801a5adc T
+
326 801e9d5c T
__pthread_kill 801a8e34 T
+
issetugid 801dad04 T
proc_info 801dd524 T
+
335 old utrace 801e9d5c T
sendfile 801b3aa4 T
+
proc_info 80216dc0 T
stat64 800a3038 T
+
sendfile 801e9d5c T
fstat64 80197838 T
+
stat64 800b24f0 T
lstat64 800a3180 T
+
fstat64 801cbbd4 T
stat64_extended 800a3088 T
+
lstat64 800b263c T
lstat64_extended 800a31d0 T
+
stat64_extended 800b2540 T
fstat64_extended 80197818 T
+
lstat64_extended 800b268c T
getdirentries64 800a4cd0 T
+
fstat64_extended 801cbbb8 T
statfs64 800a11e4 T
+
getdirentries64 800b4268 T
fstatfs64 800a132c T
+
statfs64 800b0660 T
getfsstat64 800a1540 T
+
fstatfs64 800b07a8 T
audit 8018d990 T
+
auditon 801c0a1c T
auditon 8018d994 T
+
352 801e9d5c T
kqueue 801998c4 T
+
lchown 800b2cb0 T
kevent 80199948 T
+
stack_snapshot 801c41a0 T
stack_snapshot 8019066c T
+
workq_open 80216190 T
workq_open 801dc70c T
+
kevent64 801ce104 T
thread_selfid 801dd27c T
+
374 801e9d5c T
ledger 801b5c98 T
+
375 801e9d5c T
374 801b3aa4 T
+
376 801e9d5c T
sendmsg_nocancel 801cf978 T
+
accept_nocancel 80208314 T
accept_nocancel 801cf04c T
+
fcntl_nocancel 801ca2f8 T
msync_nocancel 801a20d8 T
+
select_nocancel 801ea7dc T
fcntl_nocancel 80195fe4 T
+
fsync_nocancel 800b31c4 T
select_nocancel 801b4518 T
+
connect_nocancel 8020862c T
fsync_nocancel 800a3cd0 T
+
select_nocancel 801ea7dc T
connect_nocancel 801cf364 T
+
fsync_nocancel 800b31c4 T
writev_nocancel 801b4114 T
+
readv_nocancel 801ea028 T
sendto_nocancel 801cf69c T
+
writev_nocancel 801ea3c8 T
pread_nocancel 801b3cc4 T
+
sendto_nocancel 80208980 T
pwrite_nocancel 801b4028 T
+
pread_nocancel 801e9f8c T
waitid_nocancel 8019f87c T
+
pwrite_nocancel 801ea2e8 T
poll_nocancel 801b4d24 T
+
waitid_nocancel 801d4324 T
msgsnd_nocancel 801b3aa4 T
+
poll_nocancel 801eaf44 T
msgrcv_nocancel 801b3aa4 T
+
msgsnd_nocancel 801e9d5c T
__mac_get_mount 80244900 T
+
__mac_mount 800af00c T
__mac_getfsstat 800a13b4 T
+
__mac_get_mount 8027ba6c T
fsgetpath 800a66d4 T
+
__mac_getfsstat 800b0830 T
pid_resume 801e08bc T
+
pid_suspend 8021a950 T
pid_hibernate 801e0928 T
+
pid_resume 8021a9c0 T
  +
shared_region_map_and_slide_np 8021b118 T
  +
   
 
</pre>
 
</pre>

Revision as of 08:17, 12 June 2012

Note on these

Args go in their normal registers, like arg1 in R0, as usual. Syscall # goes in IP (that's intra-procedural, not instruction pointer!), a.k.a R12.

As in all ARM (i.e. also on Android) the kernel entry is accomplished by the SVC command (SWI in some debuggers and ARM dialects). On the kernel end, a low level CPU exception handler (fleh_swi) is installed as part of the ExceptionVectorsBase, and - upon issuing a SWI/SVC - control is transferred to that address. This handler can check the syscall number to distinguish between POSIX calls (non negative) and Mach traps (negative).


Unix

Usage

MOV IP, #x // number from following list into Intraprocedural, a.k.a. r12
SVC 0x80   // Formerly, SWI (software interrupt)

For example:


(gdb) disass chown
0x30d2ad54 <chown>:	mov	r12, #16	       ; 0x10, being # of chown
0x30d2ad58 <chown+4>:	svc	0x00000080

Most of these are the same as you would find in the XNU open source kernel, with ARM idiosyncrasies aside (and #372, ledger)

sysent

The system call table in XNU is known as "sysent", and is no longer a public symbol, for obvious reasons (e.g. syscall hooking). It is fairly straightforward, however, to find the sysent and its calls. While i0nic proposes a heuristic of finding the sysent based on the (still) exported kdebug symbol, this is unreliable, as the latter might change in the future (either be moved or no longer exported). A better way is to home in on the pattern of the struct sysent entries itself, i.e - as defined in bsd/sys/sysent.h:


struct sysent {         /* system call table */
        int16_t         sy_narg;        /* number of args */
        int8_t          sy_resv;        /* reserved  */
        int8_t          sy_flags;       /* flags */
        sy_call_t       *sy_call;       /* implementing function */
        sy_munge_t      *sy_arg_munge32; /* system call arguments munger for 32-bit process */
        sy_munge_t      *sy_arg_munge64; /* system call arguments munger for 64-bit process */
        int32_t         sy_return_type; /* system call return types */
        uint16_t        sy_arg_bytes;   /* Total size of arguments in bytes for
                                         * 32-bit system calls
                                         */
};

Because system calls arguments are set in stone, it is straightforward to write code to find the signature of the first few syscalls (syscall, exit, fork..), and from there calculate the other sysent entries. A program to do so reliable on iOS has, in fact, been written, and produces the following output for iOS 5.1:

List of system calls from iOS 5.1

note: Even though a syscall is present in the table, it does not in any way imply it is functional. Auditing, for example, is not enabled in iOS (no CONFIG_AUDIT in the XNU build). Most of these syscalls are the same as those of OS X, with the exception of ledger (which actually makes a comeback in OS X Mountain Lion), and 434+ (CONFIG_EMBEDDED).


$ ./fsysent ~/Documents/projects/iOS.6.0b1.iPod4.kernel 
mach_trap_table offset in file (for patching purposes): 3064992 (0x2ec4a0)
Sysent offset in file (for patching purposes):  3076288 (0x2ef0c0)
This appears to be XNU 2107.1.78

syscall              801e9d5c T
exit                 801d32dc T
fork                 801d61d4 T
read                 801e9d7c T
write                801ea150 T
open                 800b12f0 T
close                801cb904 T
wait4                801d3f10 T
8  old creat         801e9d5c T
link                 800b1804 T
unlink               800b1f0c T
11  old execv        801e9d5c T
chdir                800b0be0 T
fchdir               800b0a70 T
mknod                800b13d8 T
chmod                800b2a5c T
chown                800b2bb8 T
17  old break        801e9d5c T
getfsstat            800b080c T
19  old lseek        801e9d5c T
getpid               801daa60 T
21  old mount        801e9d5c T
22  old umount       801e9d5c T
setuid               801dad14 T
getuid               801daae4 T
geteuid              801daaf4 T
ptrace               801e6924 T
recvmsg              802090f4 T
sendmsg              80208c3c T
recvfrom             80208d20 T
accept               802085f4 T
getpeername          802093c0 T
getsockname          80209310 T
access               800b23c8 T
chflags              800b2844 T
fchflags             800b290c T
sync                 800b02a0 T
kill                 801de620 T
38  old stat         801e9d5c T
getppid              801daa68 T
40  old lstat        801e9d5c T
dup                  801c9a94 T
pipe                 801ec3dc T
getegid              801dab6c T
profil               801e9d5c T
45  old ktrace       801e9d5c T
sigaction            801dd73c T
getgid               801dab5c T
sigprocmask          801ddc80 T
getlogin             801db93c T
setlogin             801db9b4 T
acct                 801c447c T
sigpending           801dde24 T
sigaltstack          801de564 T
ioctl                801ea514 T
reboot               801e6888 T
revoke               800b4320 T
symlink              800b1a74 T
readlink             800b2748 T
execve               801d2cb0 T
umask                800b42f8 T
chroot               800b0cb0 T
62  old fstat        801e9d5c T
63  used internally , reserved 801e9d5c T
64  old getpagesize  801e9d5c T
msync                801d6d24 T
vfork                801d586c T
67  old vread        801e9d5c T
68  old vwrite       801e9d5c T
69  old sbrk         801e9d5c T
70  old sstk         801e9d5c T
71  old mmap         801e9d5c T
72  old vadvise      801e9d5c T
munmap               801d6dd0 T
mprotect             801d6e04 T
madvise              801d6ebc T
76  old vhangup      801e9d5c T
77  old vlimit       801e9d5c T
mincore              801d6f28 T
getgroups            801dab7c T
setgroups            801db880 T
getpgrp              801daa70 T
setpgid              801dac1c T
setitimer            801e6370 T
84  old wait         801e9d5c T
swapon               8021a638 T
getitimer            801e6228 T
87  old gethostname  801e9d5c T
88  old sethostname  801e9d5c T
getdtablesize        801c966c T
dup2                 801c9ec0 T
91  old getdopt      801e9d5c T
fcntl                801ca2d8 T
select               801ea7c0 T
94  old setdopt      801e9d5c T
fsync                800b3154 T
setpriority          801dbce8 T
socket               8020809c T
connect              80208614 T
99  old accept       801e9d5c T
getpriority          801dbbdc T
101  old send        801e9d5c T
102  old recv        801e9d5c T
103  old sigreturn   801e9d5c T
bind                 80208168 T
setsockopt           80209228 T
listen               802082d4 T
107  old vtimes      801e9d5c T
108  old sigvec      801e9d5c T
109  old sigblock    801e9d5c T
110  old sigsetmask  801e9d5c T
sigsuspend           801dde4c T
112  old sigstack    801e9d5c T
113  old recvmsg     801e9d5c T
114  old sendmsg     801e9d5c T
115  old vtrace      801e9d5c T
gettimeofday         801e6038 T
getrusage            801dca80 T
getsockopt           8020928c T
119  old resuba      801e9d5c T
readv                801ea008 T
writev               801ea3a8 T
settimeofday         801e6094 T
fchown               800b2cc8 T
fchmod               800b2b8c T
125  old recvfrom    801e9d5c T
setreuid             801db060 T
setregid             801db3f4 T
rename               800b3344 T
129  old truncate    801e9d5c T
130  old ftruncate   801e9d5c T
flock                801cce8c T
mkfifo               800b16b4 T
sendto               80208960 T
shutdown             802091f8 T
socketpair           80208804 T
mkdir                800b3c38 T
rmdir                800b3c78 T
utimes               800b2d7c T
futimes              800b2f50 T
adjtime              801e6198 T
141  old getpeername 801e9d5c T
gethostuuid          801ebe9c T
143  old sethostid   801e9d5c T
144  old getrlimit   801e9d5c T
145  old setrlimit   801e9d5c T
146  old killpg      801e9d5c T
setsid               801dabd8 T
148  old setquota    801e9d5c T
149  old qquota      801e9d5c T
150  old getsockname 801e9d5c T
getpgid              801daa78 T
setprivexec          801daa48 T
pread                801e9f6c T
pwrite               801ea2c8 T
nfssvc               801e9d5c T
156  old getdirentries 801e9d5c T
statfs               800b0340 T
fstatfs              800b05f8 T
unmount              800afe08 T
160  old async_daemon 801e9d5c T
getfh                801e9d5c T
162  old getdomainname 801e9d5c T
163  old setdomainname 801e9d5c T
164                  801e9d5c T
quotactl             800b033c T
166  old exportfs    801e9d5c T
mount                800aefe8 T
168  old ustat       801e9d5c T
csops                801d9824 T
170  old table       801d9d10 T
171  old wait3       801e9d5c T
172  old rpause      801e9d5c T
waitid               801d4308 T
174  old getdents    801e9d5c T
175  old gc_control  801e9d5c T
add_profil           801e9d5c T
177                  801e9d5c T
178                  801e9d5c T
179                  801e9d5c T
kdebug_trace         801c1d58 T
setgid               801db1f8 T
setegid              801db304 T
seteuid              801daf64 T
sigreturn            8021cfa8 T
chud                 8021bcb8 T
186                  801e9d5c T
fdatasync            800b31cc T
stat                 800b24a4 T
fstat                801cbb98 T
lstat                800b25f0 T
pathconf             800b26e4 T
fpathconf            801cbbf4 T
193                  801e9d5c T
getrlimit            801dc8c8 T
setrlimit            801dc190 T
getdirentries        800b3eb0 T
mmap                 801d6814 T
198  __syscall       801e9d5c T
lseek                800b1f84 T
truncate             800b2fd0 T
ftruncate            800b3090 T
__sysctl             801e0ccc T
mlock                801d7074 T
munlock              801d70cc T
undelete             800b1c0c T
ATsocket             801e9d5c T
ATgetmsg             801e9d5c T
ATputmsg             801e9d5c T
ATPsndreq            801e9d5c T
ATPsndrsp            801e9d5c T
ATPgetreq            801e9d5c T
ATPgetrsp            801e9d5c T
213  Reserved for AppleTalk 801e9d5c T
214                  801e9d5c T
215                  801e9d5c T
mkcomplex            800b1224 T
statv                801e9d5c T
lstatv               801e9d5c T
fstatv               801e9d5c T
getattrlist          8009afe0 T
setattrlist          8009b058 T
getdirentriesattr    800b4408 T
exchangedata         800b45c4 T
224  old checkuseraccess / fsgetpath ( which moved to 427 ) 801e9d5c T
searchfs             800b4804 T
delete               800b1f48 T
copyfile             800b31e8 T
fgetattrlist         80098408 T
fsetattrlist         8009b760 T
poll                 801eaf24 T
watchevent           801eb84c T
waitevent            801eb9f0 T
modwatch             801ebb60 T
getxattr             800b5478 T
fgetxattr            800b55b4 T
setxattr             800b56b4 T
fsetxattr            800b57c0 T
removexattr          800b58bc T
fremovexattr         800b5984 T
listxattr            800b5a44 T
flistxattr           800b5b28 T
fsctl                800b4cfc T
initgroups           801db6fc T
posix_spawn          801d1d74 T
ffsctl               800b539c T
246                  801e9d5c T
nfsclnt              801e9d5c T
fhopen               801e9d5c T
249                  801e9d5c T
minherit             801d6e84 T
semsys               801e9d5c T
msgsys               801e9d5c T
shmsys               801e9d5c T
semctl               801e9d5c T
semget               801e9d5c T
semop                801e9d5c T
257                  801e9d5c T
msgctl               801e9d5c T
msgget               801e9d5c T
msgsnd               801e9d5c T
msgrcv               801e9d5c T
shmat                801e9d5c T
shmctl               801e9d5c T
shmdt                801e9d5c T
shmget               801e9d5c T
shm_open             8020d2c0 T
shm_unlink           8020dda0 T
sem_open             8020c718 T
sem_close            8020ceb0 T
sem_unlink           8020cc78 T
sem_wait             8020cf08 T
sem_trywait          8020cfd0 T
sem_post             8020d074 T
sem_getvalue         8020d118 T
sem_init             8020d110 T
sem_destroy          8020d114 T
open_extended        800b1144 T
umask_extended       800b42a8 T
stat_extended        800b244c T
lstat_extended       800b2598 T
fstat_extended       801cb97c T
chmod_extended       800b294c T
fchmod_extended      800b2a90 T
access_extended      800b20bc T
settid               801db580 T
gettid               801dab04 T
setsgroups           801db890 T
getsgroups           801dabd0 T
setwgroups           801db894 T
getwgroups           801dabd4 T
mkfifo_extended      800b1610 T
mkdir_extended       800b3a4c T
identitysvc          801e9d5c T
shared_region_check_np 8021ab68 T
shared_region_map_np 801e9d5c T
vm_pressure_monitor  8021b2cc T
psynch_rw_longrdlock 8021415c T
psynch_rw_yieldwrlock 80214408 T
psynch_rw_downgrade  80214410 T
psynch_rw_upgrade    8021440c T
psynch_mutexwait     80211374 T
psynch_mutexdrop     80212338 T
psynch_cvbroad       8021238c T
psynch_cvsignal      80212970 T
psynch_cvwait        80212df8 T
psynch_rw_rdlock     80213530 T
psynch_rw_wrlock     80214160 T
psynch_rw_unlock     80214414 T
psynch_rw_unlock2    8021470c T
getsid               801daaa8 T
settid_with_pid      801db620 T
312  old __pthread_cond_timedwait 80213430 T
aio_fsync            801c4e60 T
aio_return           801c5038 T
aio_suspend          801c52c0 T
aio_cancel           801c49d8 T
aio_error            801c4db4 T
aio_read             801c5018 T
aio_write            801c54d4 T
lio_listio           801c54f4 T
321  old __pthread_cond_wait 801e9d5c T
iopolicysys          801dcc74 T
323                  80218edc T
mlockall             801d7108 T
munlockall           801d710c T
326                  801e9d5c T
issetugid            801dad04 T
__pthread_kill       801de298 T
__pthread_sigmask    801de2f8 T
__sigwait            801de3a8 T
__disable_threadsignal 801ddf74 T
__pthread_markcancel 801ddf90 T
__pthread_canceled   801ddfd8 T
__semwait_signal     801de178 T
335  old utrace      801e9d5c T
proc_info            80216dc0 T
sendfile             801e9d5c T
stat64               800b24f0 T
fstat64              801cbbd4 T
lstat64              800b263c T
stat64_extended      800b2540 T
lstat64_extended     800b268c T
fstat64_extended     801cbbb8 T
getdirentries64      800b4268 T
statfs64             800b0660 T
fstatfs64            800b07a8 T
getfsstat64          800b09b8 T
__pthread_chdir      800b0ca8 T
__pthread_fchdir     800b0bd8 T
audit                801c0a18 T
auditon              801c0a1c T
352                  801e9d5c T
getauid              801c0a20 T
setauid              801c0a24 T
getaudit             801e9d5c T
setaudit             801e9d5c T
getaudit_addr        801c0a28 T
setaudit_addr        801c0a2c T
auditctl             801c0a30 T
bsdthread_create     80215260 T
bsdthread_terminate  802154d8 T
kqueue               801cddec T
kevent               801cde6c T
lchown               800b2cb0 T
stack_snapshot       801c41a0 T
bsdthread_register   8021553c T
workq_open           80216190 T
workq_kernreturn     802165f8 T
kevent64             801ce104 T
__old_semwait_signal 801de04c T
__old_semwait_signal_nocancel 801de080 T
thread_selfid        80216afc T
ledger               801ebf04 T
374                  801e9d5c T
375                  801e9d5c T
376                  801e9d5c T
377                  801e9d5c T
378                  801e9d5c T
379                  801e9d5c T
__mac_execve         801d2cd0 T
__mac_syscall        8027b874 T
__mac_get_file       8027b51c T
__mac_set_file       8027b764 T
__mac_get_link       8027b640 T
__mac_set_link       8027b864 T
__mac_get_proc       8027b010 T
__mac_set_proc       8027b0d0 T
__mac_get_fd         8027b3c8 T
__mac_set_fd         8027b650 T
__mac_get_pid        8027af44 T
__mac_get_lcid       8027b184 T
__mac_get_lctx       8027b248 T
__mac_set_lctx       8027b304 T
setlcid              801dba7c T
getlcid              801dbb64 T
read_nocancel        801e9d9c T
write_nocancel       801ea170 T
open_nocancel        800b1368 T
close_nocancel       801cb920 T
wait4_nocancel       801d3f30 T
recvmsg_nocancel     80209114 T
sendmsg_nocancel     80208c5c T
recvfrom_nocancel    80208d40 T
accept_nocancel      80208314 T
msync_nocancel       801d6d3c T
fcntl_nocancel       801ca2f8 T
select_nocancel      801ea7dc T
fsync_nocancel       800b31c4 T
connect_nocancel     8020862c T
select_nocancel      801ea7dc T
fsync_nocancel       800b31c4 T
connect_nocancel     8020862c T
sigsuspend_nocancel  801ddf08 T
readv_nocancel       801ea028 T
writev_nocancel      801ea3c8 T
sendto_nocancel      80208980 T
pread_nocancel       801e9f8c T
pwrite_nocancel      801ea2e8 T
waitid_nocancel      801d4324 T
poll_nocancel        801eaf44 T
msgsnd_nocancel      801e9d5c T
msgrcv_nocancel      801e9d5c T
sem_wait_nocancel    8020cf24 T
aio_suspend_nocancel 801c52e0 T
__sigwait_nocancel   801de3e0 T
__semwait_signal_nocancel 801de1ac T
__mac_mount          800af00c T
__mac_get_mount      8027ba6c T
__mac_getfsstat      800b0830 T
fsgetpath            800b5c0c T
audit_session_self   801c0a0c T
audit_session_join   801c0a10 T
fileport_makeport    801ccf70 T
fileport_makefd      801cd0f4 T
audit_session_port   801c0a14 T
pid_suspend          8021a950 T
pid_resume           8021a9c0 T
pid_hibernate        8021aa2c T
pid_shutdown_sockets 8021aa84 T
437  old shared_region_slide_np 801e9d5c T
shared_region_map_and_slide_np 8021b118 T


Mach

XNU also supports the Mach personality, which is distinct from that of the UNIX syscalls discussed above. Mach syscalls (on 32-bit systems like iOS) are encoded as negative numbers, which is clever, since POSIX system calls are all non-negative. For example, consider mach_msg_trap:

_mach_msg_trap:
0001a8b4        e1a0c00d        mov     ip, sp
0001a8b8        e92d0170        push    {r4, r5, r6, r8}
0001a8bc        e89c0070        ldm     ip, {r4, r5, r6}
0001a8c0        e3e0c01e        mvn     ip, #30 @ 0x1e    ; Move NEGATIVE -30 into IP (R12)
0001a8c4        ef000080        svc     0x00000080        ; issue a supervisor call
0001a8c8        e8bd0170        pop     {r4, r5, r6, r8}
0001a8cc        e12fff1e        bx      lr
..
_semaphore_signal_all_trap:
0001a8f8        e3e0c021        mvn     ip, #33 @ 0x21   ; NEGATIVE -33 into IP (R12)
0001a8fc        ef000080        svc     0x00000080
0001a900        e12fff1e        bx      lr


Mach system calls are commonly known as "traps", and are maintained in a Mach Trap table. iOS's fleh_swi handler (the kernel entry point on the other side of the "SWI" or "SVC" command) checks the system call number - if it is negative, it is flipped (2's complement), and interpreted as Mach trap instead.

mach_trap_table

In iOS 5.x, the mach_trap_table is not far from the page_size export, and right next to the trap names. kern_invalid is the equivalent of ENOSYS. All the traps are ARM Thumb. The fsysent binary can be used to find the Mach trap table, as well.

$ ./fsysent -m ~/Documents/projects/iOS.5.1.iPod4.kernel 
This is an ARM binary. Applying iOS kernel signatures
mach_trap_table offset in file (for patching purposes): 2855556 (0x2b9284)
Kern invalid detected at 0x80025f50 (+1). Ignoring those.
..This appears to be XNU 1878.11.8
 // -- New in iOS 5 (and expect these in Mountain Lion)
 10 _kernelrpc_mach_vm_allocate_trap         800132ac T
 11 _kernelrpc_vm_allocate_trap              80013318 T
 12 _kernelrpc_mach_vm_deallocate_trap       800133b4 T
 13 _kernelrpc_vm_deallocate_trap            80013374 T
 14 _kernelrpc_mach_vm_protect_trap          8001343c T
 15 _kernelrpc_vm_protect_trap               800133f8 T
 16 _kernelrpc_mach_port_allocate_trap       80013494 T
 17 _kernelrpc_mach_port_destroy_trap        800134e4 T
 18 _kernelrpc_mach_port_deallocate_trap     80013520 T
 19 _kernelrpc_mach_port_mod_refs_trap       8001355c T
 20 _kernelrpc_mach_port_move_member_trap    8001359c T
 21 _kernelrpc_mach_port_insert_right_trap   800135e0 T
 22 _kernelrpc_mach_port_insert_member_trap  8001363c T
 23 _kernelrpc_mach_port_extract_member_trap 80013680 T
 // -----------------------------------------
 26 mach_reply_port                          800198ac T
 27 thread_self_trap                         80019890 T
 28 task_self_trap                           80019870 T
 29 host_self_trap                           80017db8 T
 31 mach_msg_trap                            80013c1c T
 32 mach_msg_overwrite_trap                  80013ae4 T
 33 semaphore_signal_trap                    800252d4 T
 34 semaphore_signal_all_trap                80025354 T
 35 semaphore_signal_thread_trap             80025260 T
 36 semaphore_wait_trap                      800255e8 T
 37 semaphore_wait_signal_trap               8002578c T
 38 semaphore_timedwait_trap                 800256c8 T
 39 semaphore_timedwait_signal_trap          8002586c T
 44 task_name_for_pid                        801e0734 T
 45 task_for_pid                             801e0598 T
 46 pid_for_task                             801e054c T
 48 macx_swapon                              801e127c T
 49 macx_swapoff                             801e14cc T
 51 macx_triggers                            801e1260 T
 52 macx_backing_store_suspend               801e11f0 T
 53 macx_backing_store_recovery              801e1198 T
 58 pfz_exit                                 80025944 T
 59 swtch_pri                                800259f4 T
 60 swtch                                    80025948 T
 61 thread_switch                            80025bb8 T
 62 clock_sleep_trap                         800160f0 T
 89 mach_timebase_info_trap                  80015318 T
 90 mach_wait_until_trap                     80015934 T
 91 mk_timer_create_trap                     8001d238 T
 92 mk_timer_destroy_trap                    8001d428 T
 93 mk_timer_arm_trap                        8001d46c T
 94 mk_timer_cancel_trap                     8001d4f0 T
100 iokit_user_client_trap (probably)        80234aa0 T