├── .gitignore ├── README.md └── grapevine ├── dist └── grapevine.0.1.tar.gz ├── docs ├── report.pdf └── userguide.pdf ├── old ├── broadcaster.py ├── broadcastlisten.py ├── example.db ├── hostcontrol.py └── nofuzz.py ├── res ├── imgs │ ├── process.svg │ └── vmoverview.svg ├── parseflow ├── rfc ├── syscall_emulation.c ├── syscall_subr.c ├── syscall_sw.c ├── syscalls.master ├── tkintertest.py └── xnufuzz.py └── src ├── common ├── __init__.py ├── fuzzgenerator │ ├── __init__.py │ └── gvgenerator.py └── fuzzprofile │ ├── __init__.py │ ├── gvparser.py │ └── gvsyscalls.py ├── gfuzzd ├── common ├── fuzzd │ ├── __init__.py │ ├── gvcallingmechanisms.py │ └── gvfuzz.py ├── fuzzlogger │ ├── __init__.py │ └── gvlogger.py └── gfuzzd.py └── ghost ├── common ├── generators ├── __init__.py ├── common └── random_fi.py ├── ghost.py ├── host ├── __init__.py ├── gvhost.py └── vm │ ├── __init__.py │ ├── html │ ├── index.html │ ├── jquery.min.js │ ├── reset.css │ └── title.png │ ├── vbcontrol.py │ ├── vbinfo.py │ └── vbwebui.py └── logger ├── __init__.py └── gvloglistener.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | grapevine OSX XNU Kernel Fuzzer 2 | =============================== 3 | Mac OSX/Darwin Kernel Automated Fuzzer Generator. 4 | ------------------------------------------------- 5 | 6 | ##Aims 7 | - Automatically parses syscall files/headers to generate fuzz input. 8 | - Dynamic, if there are new or removed syscalls, fuzzer will change accordingly. 9 | - Modular 10 | - different fuzzing techniques 11 | - Extensible 12 | - Write parsers to parse syscalls from other kernels (Linux/BSD/etc) 13 | 14 | ##Program Flow 15 | Refer to [parseflow](https://github.com/jergorn93/grapevine/blob/master/grapevine/res/parseflow) 16 | -------------------------------------------------------------------------------- /grapevine/dist/grapevine.0.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/dist/grapevine.0.1.tar.gz -------------------------------------------------------------------------------- /grapevine/docs/report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/docs/report.pdf -------------------------------------------------------------------------------- /grapevine/docs/userguide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/docs/userguide.pdf -------------------------------------------------------------------------------- /grapevine/old/broadcaster.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | 4 | def __send_cmd(sock, data): 5 | sock.sendto(data, ('', 10001)) 6 | 7 | def main(): 8 | sock = socket.socket (socket.AF_INET, socket.SOCK_DGRAM) 9 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1 ) 10 | while True: 11 | sys.stdout.write("input> ") 12 | msg = raw_input().rstrip() 13 | __send_cmd(sock, msg) 14 | 15 | if __name__ == "__main__" : 16 | main() 17 | -------------------------------------------------------------------------------- /grapevine/old/broadcastlisten.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | UDP_IP="0.0.0.0" #listens on all the address the machines has, DO NOT CHANGE TO LOCALHOST 4 | UDP_PORT=10001 5 | 6 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 7 | sock.bind( (UDP_IP, UDP_PORT) ) 8 | 9 | print 'Start listener aka gfuzzd instance...' 10 | while True: 11 | message, addr = sock.recvfrom(1024) 12 | print 'message (%s) from : %s' % ( str(message), addr[0] ) 13 | -------------------------------------------------------------------------------- /grapevine/old/example.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/old/example.db -------------------------------------------------------------------------------- /grapevine/old/hostcontrol.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import sys 3 | import re 4 | from threading import Thread 5 | from time import time 6 | 7 | udp_ip="127.0.0.1" 8 | udp_port=10001 9 | log_listeners = [4999] 10 | loggers = [] 11 | 12 | def parse(): 13 | """Function to make use of the parser.""" 14 | pass 15 | 16 | def prompt(): 17 | """Helper function""" 18 | sys.stdout.write( "command> ") 19 | uin = raw_input().rstrip() 20 | return uin 21 | 22 | def set_connection(ip,port): 23 | """Set currently targetted VM""" 24 | global udp_ip 25 | udp_ip = ip 26 | global udp_port 27 | udp_port = port 28 | 29 | def logger(port,udp_ip,udp_port): 30 | """UDP Logging function, writes to file""" 31 | print "Logger spawned" 32 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 33 | sock.bind( ('0.0.0.0',port) ) 34 | print "Port Bound",port 35 | filename = str(int(time())) 36 | f = open( filename, 'w') 37 | f.write("VMIP: ") 38 | f.write(udp_ip) 39 | f.write(" VMPORT: ") 40 | f.write(str(udp_port)) 41 | f.write(" Logger port ") 42 | f.write(str(port)) 43 | f.write("\n") 44 | f.close() 45 | while True: 46 | f = open(filename, 'a') 47 | data, addr = sock.recvfrom( 3072 ) 48 | f.write(data) 49 | f.write("\nNEWSET\n") 50 | f.close() 51 | 52 | 53 | if __name__ == "__main__": 54 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 55 | #print "Fuzzd IP: ", UDP_IP 56 | #print "Fuzzd Port: ", UDP_PORT 57 | ipregex = re.compile('\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b', re.VERBOSE) 58 | portregex = re.compile('\b\d{1,5}\b') 59 | while True: 60 | msg = prompt() 61 | #if fuzzing, program should fork a new udp listener at a specific port, and send the details to fuzzd for logging. 62 | print "Msg:",msg 63 | #sock.sendto( msg, ( udp_ip, udp_port ) ) 64 | if msg == "currentvm": 65 | print "Current VM ip:",udp_ip 66 | print "Current VM port:",udp_port 67 | elif msg == "connect": 68 | badport = True 69 | badip = True 70 | while badip: 71 | sys.stdout.write( "Input IP address of VM to send commands to> ") 72 | ip = raw_input().rstrip() 73 | try: 74 | socket.inet_aton(ip) 75 | badip = False 76 | except socket.error: 77 | badip = True 78 | 79 | while badport: 80 | sys.stdout.write("Input port> ") 81 | port = raw_input().rstrip() 82 | if re.match('\d{1,5}',port) and len(port) < 6: 83 | badport = False 84 | else: 85 | badport = True 86 | set_connection( ip, int(port) ) 87 | elif msg == "parse": 88 | sys.stdout.write("Do some parsing, get some values\n") 89 | elif msg == "fuzz": 90 | print "Fuzzing:",udp_ip 91 | sock.sendto( msg, (udp_ip, udp_port) ) #send "fuzz" 92 | #fork udp logger listener 93 | #global log_listeners 94 | log_listeners.append(log_listeners[len(log_listeners)-1]+1) #add new port to list 95 | port = log_listeners[len(log_listeners)-1] #same value as above 96 | sock.sendto( str(port), (udp_ip,udp_port) ) #send logger port 97 | logging = Thread( target=logger, args=([port,udp_ip,udp_port]) ) 98 | logging.daemon = True 99 | loggers.append(logging) 100 | logging.start() 101 | elif msg == "exit": 102 | print "Exiting" 103 | sock.sendto(msg, ( udp_ip, udp_port ) ) 104 | exit() 105 | elif msg == "help": 106 | sys.stdout.write( "Grapevine Host Control alpha\nCommands:\n\tcurrentvm:\t displays IP and PORT of currently connected VM\n\tconnect:\t prompts for new connection details\n\tfuzz:\t\t start fuzzing in the connected vm.\n\texit:\t\t exits the program.\n\thelp:\t\t Prints this help message.\n" ) 107 | else: 108 | sys.stdout.write("Command not supported\n") 109 | 110 | 111 | -------------------------------------------------------------------------------- /grapevine/old/nofuzz.py: -------------------------------------------------------------------------------- 1 | from ctypes import * 2 | import random 3 | import socket 4 | import time 5 | import pickle 6 | import binascii 7 | from time import sleep 8 | import fuzzmod.randomFI 9 | from threading import Timer 10 | from threading import Thread 11 | randomFI = fuzzmod.randomFI() 12 | #libc = cdll.LoadLibrary("libc.dylib") 13 | UDP_IP="127.0.0.1" 14 | UDP_PORT=10001 15 | log_ip = "0.0.0.0" 16 | log_port = 0 17 | 18 | #This ignore list is customized for xnu-1504.9.37 (10.6.7). 19 | 20 | class Logger: 21 | def logit(self, syscallnr, arg): 22 | """Logging to UDP listener. Sends a JSON string with syscall numbers and arguments. Arguments and hexlifyied.""" 23 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 24 | prepayload = {"syscallnr": syscallnr, 25 | "arg1": arg[0], 26 | "arg2": arg[1], 27 | "arg3": arg[2], 28 | "arg4": arg[3], 29 | "arg5": arg[4], 30 | "arg6": arg[5], 31 | "arg7": arg[6], 32 | "arg8": arg[7] 33 | } 34 | #payload = binascii.b2a_base64(pickle.dumps(prepayload)) 35 | payload = pickle.dumps(prepayload) 36 | sock.sendto( payload, (log_ip, log_port) ) 37 | 38 | def logret(self, retVal): 39 | """Sends return value of syscall to logger.""" 40 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 41 | payload = json.dumps({"returnVal": str(retVal)}, ensure_ascii=True) 42 | sock.sendto( payload, (log_ip, log_port) ) 43 | 44 | class Syscaller: 45 | """Functions to call syscalls. Takes in a syscall number and a tuple or list of args""" 46 | def call(self, syscallnr, args): 47 | """Takes in a syscall number and a list or tuple of arguments""" 48 | logger = Logger() 49 | logger.logit(syscallnr, args) 50 | sleep(5/1000000.0) 51 | #returnVal = libc.syscall(syscallnr, 52 | # args[0], 53 | # args[1], 54 | # args[2], 55 | # args[3], 56 | # args[4], 57 | # args[5], 58 | # args[6], 59 | # args[7] 60 | # ) 61 | #logger.logret(returnVal) 62 | 63 | 64 | ignore = [8, 11, 17, 19, 21, 22, 38, 40, 45, 62, 63, 64, 67, 65 | 68, 69, 70, 71, 72, 76, 77, 84, 87, 88, 91, 94, 99, 66 | 101, 102, 103, 107, 108, 109, 110, 112, 113, 114, 67 | 115, 119, 125, 129, 130, 141, 143, 144, 145, 146, 68 | 148, 149, 150, 156, 160, 162, 163, 164, 166, 168, 69 | 170, 171, 172, 174, 175, 177, 178, 179, 186, 193, 70 | 198, 213, 214, 215, 216, 217, 218, 219, 224, 246, 71 | 249, 257, 312, 321, 323, 326, 335, 352, 373, 374, 72 | 375, 376, 377, 378, 379, 401, 402, 403, 404, 409, 73 | 413, 418, 419, 423, 432, 433, 74 | 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, 75 | -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, 76 | -30, -40, -41, -42, -47, -50, -54, -55, -56, -57, -63, -64, 77 | -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, 78 | -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, 79 | -95, -96, -97, -98, -99, -100] 80 | 81 | def memfuzz(): 82 | """Fuzz XNU Kernel. Generates random input and calls syscalls with random inputs as arguments.""" 83 | logger = Logger() 84 | syscall = Syscaller() 85 | arg = [] 86 | syscallnr = 0 87 | flag = 1 88 | while True: 89 | flag = 1 90 | while not flag == 0: 91 | flag = 0 92 | random.seed(randomFI.getseed()) 93 | syscallnr = random.randint(-100, 433) 94 | for i in ignore: 95 | if(i == syscallnr): 96 | flag = 1 97 | break 98 | 99 | arg = randomFI.getargs() 100 | syscall.call(syscallnr, arg) #uncomment this line to call syscalls 101 | 102 | #logger.logit(syscallnr,arg) 103 | #print('syscall({}, {}, {}, {}, {}, {}, {}, {}, {})\n').format(syscallnr, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]) 104 | #sleep(5/1000000.0) 105 | #returnVal = libc.syscall(syscallnr, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]) 106 | #logret(returnVal) 107 | #print "return: ", returnVal 108 | 109 | def checkFuzz(thread): 110 | """Checks for dead fuzzing thread and starts a new thread if none exists.""" 111 | print "Checking" 112 | if thread.isAlive() is False: 113 | fuzzing = Thread(target=memfuzz, name="fuzz") 114 | fuzzing.start() 115 | else: 116 | print "Thread is alive" 117 | 118 | 119 | 120 | if __name__ == "__main__": 121 | sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 122 | sock.bind ( (UDP_IP,UDP_PORT) ) 123 | print "Socket binding success. Listening on",UDP_PORT 124 | while True: 125 | data, addr = sock.recvfrom( 1024 ) #buffer 1024 126 | print "Instructs: ",data 127 | print "From: ",addr 128 | if data == 'fuzz': 129 | log_ip = addr[0] 130 | log_port = int(sock.recvfrom( 512 )[0]) #recv log port 131 | fuzzing = Thread(target=memfuzz,name="fuzz") 132 | fuzzing.start() #starts the fuzzing function 133 | checker = Timer(30.0, checkFuzz, [fuzzing]) #checks for dead fuzzing thread 134 | checker.start() 135 | if data == "exit": 136 | exit() 137 | -------------------------------------------------------------------------------- /grapevine/res/imgs/process.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 27 | 32 | 33 | 40 | 45 | 46 | 53 | 59 | 60 | 61 | 79 | 81 | 82 | 84 | image/svg+xml 85 | 87 | 88 | 89 | 90 | 91 | 96 | Process Communication Diagram 107 | 110 | ghost 121 | 124 | 134 | 140 | 141 | 142 | 145 | 147 | 150 | gfuzzd 161 | 164 | 174 | 179 | 180 | 181 | - generator- syscall_profile- logger- fuzzd 204 | 205 | 206 | 212 | 1. sends 'hello' to a specified udp address and port pair. 223 | 230 | 2. Acknowledgeswith 'hello from %s' % self 245 | 252 | 3. sends 'loadgen', generator_name, initial_seed, and generator definition. 271 | 281 | 288 | 4. receives and installs the generator into a private namespace with the generator_name as a key. Then, gfuzzd instantiates the newly installed generator with the initial_seed and syscall_profiles as the current generator. 331 | 338 | 5. 'returns 'generator %s loaded' % generator_name 353 | 360 | 6. sends 'fuzz' 371 | 377 | 7. spawns a new thread and begins fuzzing using inputs generated from the generator.getNext() function. 404 | 411 | 423 | 424 | 425 | -------------------------------------------------------------------------------- /grapevine/res/imgs/vmoverview.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 27 | 32 | 33 | 40 | 45 | 46 | 53 | 58 | 59 | 66 | 72 | 73 | 80 | 86 | 87 | 94 | 100 | 101 | 108 | 114 | 115 | 122 | 128 | 129 | 136 | 142 | 143 | 144 | 162 | 164 | 165 | 167 | image/svg+xml 168 | 170 | 171 | 172 | 173 | 174 | 178 | 189 | VM Control Overview 200 | 207 | 218 | 221 | ghost.py 232 | 239 | 240 | 243 | gfuzzd.py 254 | 261 | 262 | 265 | gfuzzd.py 276 | 283 | 284 | 287 | gfuzzd.py 298 | 305 | 306 | 309 | gfuzzd.py 320 | 327 | 328 | 333 | 338 | 343 | 348 | 359 | 360 | 361 | -------------------------------------------------------------------------------- /grapevine/res/parseflow: -------------------------------------------------------------------------------- 1 | Assuming one machine is under fuzz, 2 | 3 | pre-requisites: 4 | gfuzzd is installed on the machine to be fuzzed with all required kernel source files. 5 | ghost is installed on the machine acting as controller to VMs under fuzz along with the required generator definitions. 6 | 7 | listen: 8 | 1. gfuzzd parses the syscall source files and creates a syscall profile. 9 | 2. gfuzzd creates a fuzzd instance by supplying a logger, calling mechanism, and the syscall profile. 10 | 2. gfuzzd begins listening on a specified udp address and port pair. 11 | 12 | expected process: 13 | 1. ghost sends a 'hello' to the specified udp address and port pair. 14 | 2. If gfuzzd is listening, it will acknowledge with 'hello from %s' % self. 15 | 3. ghost sends 'loadgen', generator_name, initial_seed, and generator definition. generator_name must correspond to the class definition. 16 | 4. gfuzzd receives and installs the generator into a private namespace with the generator_name as a key. Then, gfuzzd instantiates the newly installed generator with the initial_seed and syscall_profiles as the current generator. gfuzzd returns 'generator %s loaded' % generator_name. 17 | 5. ghost sends 'fuzz'. 18 | 6. gfuzzd spawns a new thread and begins fuzzing using inputs generated from the generator.getNext() function. It returns 'fuzzing is turned on'. 19 | 7. ghost sends 'stopfuzz'. 20 | 7. gfuzzd stops the fuzzing thread by signalling to the running loop that fuzzing is cancelled and returns 'fuzzing is turned off'. 21 | 8. ghost sends 'exit'. 22 | 9. gfuzzd returns 'goodbye' and exits the python program. 23 | 24 | glossary 25 | 26 | gfuzzd - listener framework to be installed on the machines to be fuzzed. 27 | ghost - controller that manages many gfuzzd instances. 28 | syscall collection - collection of syscalls represented in object form for easy generation of fuzz input data through information extracted in the form of data types of returns or arguments. 29 | calling mechanism - controls how fuzz input data is executed as a syscall. 30 | syscall profile - consolidated group(s) of syscall collections to be utilised by a generator when generating fuzz input data. 31 | generator - a state machine that when instantiated with a seed value may return fuzz data or affect the state of the state machine through two public functions: getNext() and affectState(return_val) respectively. -------------------------------------------------------------------------------- /grapevine/res/rfc: -------------------------------------------------------------------------------- 1 | Protocol Specification for Communication Between Multiple Instances of gfuzzd and fuzzer controller only ghost. 2 | 3 | Assumptions: 4 | gfuzzd is installed on the target machine. 5 | 6 | Protocol: 7 | 8 | - Connect Phase (Req: Establish that gfuzzd is listening. Initialise logging and generator.) 9 | ghost sends "hello" 10 | gfuzzd replies "hello from %s" % self 11 | ghost sends " 12 | -------------------------------------------------------------------------------- /grapevine/res/syscall_emulation.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | /* 32 | * Mach Operating System 33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 | * All Rights Reserved. 35 | * 36 | * Permission to use, copy, modify and ditribute this software and its 37 | * documentation is hereby granted, provided that both the copyright 38 | * notice and this permission notice appear in all copies of the 39 | * software, derivative works or modified versions, and any portions 40 | * thereof, and that both notices appear in supporting documentation. 41 | * 42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 | * 46 | * Carnegie Mellon requests users of this software to return to 47 | * 48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 | * School of Computer Science 50 | * Carnegie Mellon University 51 | * Pittsburgh PA 15213-3890 52 | * 53 | * any improvements or extensions that they make and grant Carnegie Mellon 54 | * the rights to redistribute these changes. 55 | */ 56 | /* 57 | */ 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | 64 | #include 65 | #include 66 | #include 67 | #include 68 | 69 | #include 70 | #include 71 | 72 | /* 73 | * Exported interface 74 | */ 75 | 76 | /* 77 | * task_set_emulation_vector: [Server Entry] 78 | * 79 | * Set the list of emulated system calls for this task. 80 | * The list is out-of-line. 81 | */ 82 | kern_return_t 83 | task_set_emulation_vector( 84 | __unused task_t task, 85 | __unused int vector_start, 86 | __unused emulation_vector_t emulation_vector, 87 | __unused mach_msg_type_number_t emulation_vector_count) 88 | { 89 | return KERN_NOT_SUPPORTED; 90 | } 91 | 92 | /* 93 | * task_get_emulation_vector: [Server Entry] 94 | * 95 | * Get the list of emulated system calls for this task. 96 | * List is returned out-of-line. 97 | */ 98 | kern_return_t 99 | task_get_emulation_vector( 100 | __unused task_t task, 101 | __unused int *vector_start, /* out */ 102 | __unused emulation_vector_t *emulation_vector, /* out */ 103 | __unused mach_msg_type_number_t *emulation_vector_count)/* out */ 104 | { 105 | return KERN_NOT_SUPPORTED; 106 | } 107 | 108 | /* 109 | * task_set_emulation: [Server Entry] 110 | * set up for user space emulation of syscalls within this task. 111 | */ 112 | kern_return_t 113 | task_set_emulation( 114 | __unused task_t task, 115 | __unused vm_offset_t routine_entry_pt, 116 | __unused int routine_number) 117 | { 118 | return KERN_NOT_SUPPORTED; 119 | } 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /grapevine/res/syscall_subr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2009 Apple Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | /* 32 | * Mach Operating System 33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 | * All Rights Reserved. 35 | * 36 | * Permission to use, copy, modify and distribute this software and its 37 | * documentation is hereby granted, provided that both the copyright 38 | * notice and this permission notice appear in all copies of the 39 | * software, derivative works or modified versions, and any portions 40 | * thereof, and that both notices appear in supporting documentation. 41 | * 42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 | * 46 | * Carnegie Mellon requests users of this software to return to 47 | * 48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 | * School of Computer Science 50 | * Carnegie Mellon University 51 | * Pittsburgh PA 15213-3890 52 | * 53 | * any improvements or extensions that they make and grant Carnegie Mellon 54 | * the rights to redistribute these changes. 55 | */ 56 | /* 57 | */ 58 | 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | #include 74 | #include 75 | #include 76 | 77 | 78 | #ifdef MACH_BSD 79 | extern void workqueue_thread_yielded(void); 80 | #endif /* MACH_BSD */ 81 | 82 | 83 | /* Called from commpage to take a delayed preemption when exiting 84 | * the "Preemption Free Zone" (PFZ). 85 | */ 86 | kern_return_t 87 | pfz_exit( 88 | __unused struct pfz_exit_args *args) 89 | { 90 | /* For now, nothing special to do. We'll pick up the ASTs on kernel exit. */ 91 | 92 | return (KERN_SUCCESS); 93 | } 94 | 95 | 96 | /* 97 | * swtch and swtch_pri both attempt to context switch (logic in 98 | * thread_block no-ops the context switch if nothing would happen). 99 | * A boolean is returned that indicates whether there is anything 100 | * else runnable. 101 | * 102 | * This boolean can be used by a thread waiting on a 103 | * lock or condition: If FALSE is returned, the thread is justified 104 | * in becoming a resource hog by continuing to spin because there's 105 | * nothing else useful that the processor could do. If TRUE is 106 | * returned, the thread should make one more check on the 107 | * lock and then be a good citizen and really suspend. 108 | */ 109 | 110 | static void 111 | swtch_continue(void) 112 | { 113 | register processor_t myprocessor; 114 | boolean_t result; 115 | 116 | disable_preemption(); 117 | myprocessor = current_processor(); 118 | result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0; 119 | enable_preemption(); 120 | 121 | thread_syscall_return(result); 122 | /*NOTREACHED*/ 123 | } 124 | 125 | boolean_t 126 | swtch( 127 | __unused struct swtch_args *args) 128 | { 129 | register processor_t myprocessor; 130 | boolean_t result; 131 | 132 | disable_preemption(); 133 | myprocessor = current_processor(); 134 | if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) { 135 | mp_enable_preemption(); 136 | 137 | return (FALSE); 138 | } 139 | enable_preemption(); 140 | 141 | counter(c_swtch_block++); 142 | 143 | thread_block_reason((thread_continue_t)swtch_continue, NULL, AST_YIELD); 144 | 145 | disable_preemption(); 146 | myprocessor = current_processor(); 147 | result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0; 148 | enable_preemption(); 149 | 150 | return (result); 151 | } 152 | 153 | static void 154 | swtch_pri_continue(void) 155 | { 156 | register processor_t myprocessor; 157 | boolean_t result; 158 | 159 | thread_depress_abort_internal(current_thread()); 160 | 161 | disable_preemption(); 162 | myprocessor = current_processor(); 163 | result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0; 164 | mp_enable_preemption(); 165 | 166 | thread_syscall_return(result); 167 | /*NOTREACHED*/ 168 | } 169 | 170 | boolean_t 171 | swtch_pri( 172 | __unused struct swtch_pri_args *args) 173 | { 174 | register processor_t myprocessor; 175 | boolean_t result; 176 | 177 | disable_preemption(); 178 | myprocessor = current_processor(); 179 | if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) { 180 | mp_enable_preemption(); 181 | 182 | return (FALSE); 183 | } 184 | enable_preemption(); 185 | 186 | counter(c_swtch_pri_block++); 187 | 188 | thread_depress_abstime(thread_depress_time); 189 | 190 | thread_block_reason((thread_continue_t)swtch_pri_continue, NULL, AST_YIELD); 191 | 192 | thread_depress_abort_internal(current_thread()); 193 | 194 | disable_preemption(); 195 | myprocessor = current_processor(); 196 | result = !SCHED(processor_queue_empty)(myprocessor) || rt_runq.count > 0; 197 | enable_preemption(); 198 | 199 | return (result); 200 | } 201 | 202 | static void 203 | thread_switch_continue(void) 204 | { 205 | register thread_t self = current_thread(); 206 | int option = self->saved.swtch.option; 207 | 208 | if (option == SWITCH_OPTION_DEPRESS) 209 | thread_depress_abort_internal(self); 210 | 211 | thread_syscall_return(KERN_SUCCESS); 212 | /*NOTREACHED*/ 213 | } 214 | 215 | /* 216 | * thread_switch: 217 | * 218 | * Context switch. User may supply thread hint. 219 | */ 220 | kern_return_t 221 | thread_switch( 222 | struct thread_switch_args *args) 223 | { 224 | register thread_t thread, self = current_thread(); 225 | mach_port_name_t thread_name = args->thread_name; 226 | int option = args->option; 227 | mach_msg_timeout_t option_time = args->option_time; 228 | 229 | /* 230 | * Process option. 231 | */ 232 | switch (option) { 233 | 234 | case SWITCH_OPTION_NONE: 235 | case SWITCH_OPTION_DEPRESS: 236 | case SWITCH_OPTION_WAIT: 237 | break; 238 | 239 | default: 240 | return (KERN_INVALID_ARGUMENT); 241 | } 242 | 243 | workqueue_thread_yielded(); 244 | 245 | /* 246 | * Translate the port name if supplied. 247 | */ 248 | if (thread_name != MACH_PORT_NULL) { 249 | ipc_port_t port; 250 | 251 | if (ipc_port_translate_send(self->task->itk_space, 252 | thread_name, &port) == KERN_SUCCESS) { 253 | ip_reference(port); 254 | ip_unlock(port); 255 | 256 | thread = convert_port_to_thread(port); 257 | ipc_port_release(port); 258 | 259 | if (thread == self) { 260 | (void)thread_deallocate_internal(thread); 261 | thread = THREAD_NULL; 262 | } 263 | } 264 | else 265 | thread = THREAD_NULL; 266 | } 267 | else 268 | thread = THREAD_NULL; 269 | 270 | /* 271 | * Try to handoff if supplied. 272 | */ 273 | if (thread != THREAD_NULL) { 274 | processor_t processor; 275 | spl_t s; 276 | 277 | s = splsched(); 278 | thread_lock(thread); 279 | 280 | /* 281 | * Check that the thread is not bound 282 | * to a different processor, and that realtime 283 | * is not involved. 284 | * 285 | * Next, pull it off its run queue. If it 286 | * doesn't come, it's not eligible. 287 | */ 288 | processor = current_processor(); 289 | if (processor->current_pri < BASEPRI_RTQUEUES && 290 | thread->sched_pri < BASEPRI_RTQUEUES && 291 | (thread->bound_processor == PROCESSOR_NULL || 292 | thread->bound_processor == processor) && 293 | thread_run_queue_remove(thread) ) { 294 | /* 295 | * Hah, got it!! 296 | */ 297 | thread_unlock(thread); 298 | 299 | (void)thread_deallocate_internal(thread); 300 | 301 | if (option == SWITCH_OPTION_WAIT) 302 | assert_wait_timeout((event_t)assert_wait_timeout, THREAD_ABORTSAFE, 303 | option_time, 1000*NSEC_PER_USEC); 304 | else 305 | if (option == SWITCH_OPTION_DEPRESS) 306 | thread_depress_ms(option_time); 307 | 308 | self->saved.swtch.option = option; 309 | 310 | thread_run(self, (thread_continue_t)thread_switch_continue, NULL, thread); 311 | /* NOTREACHED */ 312 | } 313 | 314 | thread_unlock(thread); 315 | splx(s); 316 | 317 | thread_deallocate(thread); 318 | } 319 | 320 | if (option == SWITCH_OPTION_WAIT) 321 | assert_wait_timeout((event_t)assert_wait_timeout, THREAD_ABORTSAFE, option_time, 1000*NSEC_PER_USEC); 322 | else 323 | if (option == SWITCH_OPTION_DEPRESS) 324 | thread_depress_ms(option_time); 325 | 326 | self->saved.swtch.option = option; 327 | 328 | thread_block_reason((thread_continue_t)thread_switch_continue, NULL, AST_YIELD); 329 | 330 | if (option == SWITCH_OPTION_DEPRESS) 331 | thread_depress_abort_internal(self); 332 | 333 | return (KERN_SUCCESS); 334 | } 335 | 336 | /* 337 | * Depress thread's priority to lowest possible for the specified interval, 338 | * with a value of zero resulting in no timeout being scheduled. 339 | */ 340 | void 341 | thread_depress_abstime( 342 | uint64_t interval) 343 | { 344 | register thread_t self = current_thread(); 345 | uint64_t deadline; 346 | spl_t s; 347 | 348 | s = splsched(); 349 | thread_lock(self); 350 | if (!(self->sched_flags & TH_SFLAG_DEPRESSED_MASK)) { 351 | processor_t myprocessor = self->last_processor; 352 | 353 | self->sched_pri = DEPRESSPRI; 354 | myprocessor->current_pri = self->sched_pri; 355 | self->sched_flags |= TH_SFLAG_DEPRESS; 356 | 357 | if (interval != 0) { 358 | clock_absolutetime_interval_to_deadline(interval, &deadline); 359 | if (!timer_call_enter(&self->depress_timer, deadline, TIMER_CALL_CRITICAL)) 360 | self->depress_timer_active++; 361 | } 362 | } 363 | thread_unlock(self); 364 | splx(s); 365 | } 366 | 367 | void 368 | thread_depress_ms( 369 | mach_msg_timeout_t interval) 370 | { 371 | uint64_t abstime; 372 | 373 | clock_interval_to_absolutetime_interval( 374 | interval, 1000*NSEC_PER_USEC, &abstime); 375 | thread_depress_abstime(abstime); 376 | } 377 | 378 | /* 379 | * Priority depression expiration. 380 | */ 381 | void 382 | thread_depress_expire( 383 | void *p0, 384 | __unused void *p1) 385 | { 386 | thread_t thread = p0; 387 | spl_t s; 388 | 389 | s = splsched(); 390 | thread_lock(thread); 391 | if (--thread->depress_timer_active == 0) { 392 | thread->sched_flags &= ~TH_SFLAG_DEPRESSED_MASK; 393 | SCHED(compute_priority)(thread, FALSE); 394 | } 395 | thread_unlock(thread); 396 | splx(s); 397 | } 398 | 399 | /* 400 | * Prematurely abort priority depression if there is one. 401 | */ 402 | kern_return_t 403 | thread_depress_abort_internal( 404 | thread_t thread) 405 | { 406 | kern_return_t result = KERN_NOT_DEPRESSED; 407 | spl_t s; 408 | 409 | s = splsched(); 410 | thread_lock(thread); 411 | if (!(thread->sched_flags & TH_SFLAG_POLLDEPRESS)) { 412 | if (thread->sched_flags & TH_SFLAG_DEPRESSED_MASK) { 413 | thread->sched_flags &= ~TH_SFLAG_DEPRESSED_MASK; 414 | SCHED(compute_priority)(thread, FALSE); 415 | result = KERN_SUCCESS; 416 | } 417 | 418 | if (timer_call_cancel(&thread->depress_timer)) 419 | thread->depress_timer_active--; 420 | } 421 | thread_unlock(thread); 422 | splx(s); 423 | 424 | return (result); 425 | } 426 | 427 | void 428 | thread_poll_yield( 429 | thread_t self) 430 | { 431 | spl_t s; 432 | 433 | assert(self == current_thread()); 434 | 435 | s = splsched(); 436 | if (self->sched_mode == TH_MODE_FIXED) { 437 | uint64_t total_computation, abstime; 438 | 439 | abstime = mach_absolute_time(); 440 | total_computation = abstime - self->computation_epoch; 441 | total_computation += self->computation_metered; 442 | if (total_computation >= max_poll_computation) { 443 | processor_t myprocessor = current_processor(); 444 | ast_t preempt; 445 | 446 | thread_lock(self); 447 | if (!(self->sched_flags & TH_SFLAG_DEPRESSED_MASK)) { 448 | self->sched_pri = DEPRESSPRI; 449 | myprocessor->current_pri = self->sched_pri; 450 | } 451 | self->computation_epoch = abstime; 452 | self->computation_metered = 0; 453 | self->sched_flags |= TH_SFLAG_POLLDEPRESS; 454 | 455 | abstime += (total_computation >> sched_poll_yield_shift); 456 | if (!timer_call_enter(&self->depress_timer, abstime, TIMER_CALL_CRITICAL)) 457 | self->depress_timer_active++; 458 | thread_unlock(self); 459 | 460 | if ((preempt = csw_check(myprocessor)) != AST_NONE) 461 | ast_on(preempt); 462 | } 463 | } 464 | splx(s); 465 | } 466 | 467 | 468 | void 469 | thread_yield_internal( 470 | mach_msg_timeout_t ms) 471 | { 472 | processor_t myprocessor; 473 | 474 | disable_preemption(); 475 | myprocessor = current_processor(); 476 | if (SCHED(processor_queue_empty)(myprocessor) && rt_runq.count == 0) { 477 | mp_enable_preemption(); 478 | 479 | return; 480 | } 481 | enable_preemption(); 482 | 483 | thread_depress_ms(ms); 484 | 485 | thread_block_reason(THREAD_CONTINUE_NULL, NULL, AST_YIELD); 486 | 487 | thread_depress_abort_internal(current_thread()); 488 | } 489 | 490 | -------------------------------------------------------------------------------- /grapevine/res/syscall_sw.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. 3 | * 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 | * 6 | * This file contains Original Code and/or Modifications of Original Code 7 | * as defined in and that are subject to the Apple Public Source License 8 | * Version 2.0 (the 'License'). You may not use this file except in 9 | * compliance with the License. The rights granted to you under the License 10 | * may not be used to create, or enable the creation or redistribution of, 11 | * unlawful or unlicensed copies of an Apple operating system, or to 12 | * circumvent, violate, or enable the circumvention or violation of, any 13 | * terms of an Apple operating system software license agreement. 14 | * 15 | * Please obtain a copy of the License at 16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 | * 18 | * The Original Code and all software distributed under the License are 19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 | * Please see the License for the specific language governing rights and 24 | * limitations under the License. 25 | * 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 | */ 28 | /* 29 | * @OSF_COPYRIGHT@ 30 | */ 31 | /* 32 | * Mach Operating System 33 | * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University 34 | * All Rights Reserved. 35 | * 36 | * Permission to use, copy, modify and distribute this software and its 37 | * documentation is hereby granted, provided that both the copyright 38 | * notice and this permission notice appear in all copies of the 39 | * software, derivative works or modified versions, and any portions 40 | * thereof, and that both notices appear in supporting documentation. 41 | * 42 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 43 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 44 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 | * 46 | * Carnegie Mellon requests users of this software to return to 47 | * 48 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 49 | * School of Computer Science 50 | * Carnegie Mellon University 51 | * Pittsburgh PA 15213-3890 52 | * 53 | * any improvements or extensions that they make and grant Carnegie Mellon 54 | * the rights to redistribute these changes. 55 | */ 56 | /* 57 | */ 58 | 59 | #include 60 | #include 61 | 62 | #include 63 | 64 | /* Forwards */ 65 | 66 | 67 | /* 68 | * To add a new entry: 69 | * Add an "MACH_TRAP(routine, arg count)" to the table below. 70 | * 71 | * Add trap definition to mach/syscall_sw.h and 72 | * recompile user library. 73 | * 74 | * WARNING: If you add a trap which requires more than 7 75 | * parameters, mach/{machine}/syscall_sw.h and {machine}/trap.c 76 | * and/or {machine}/locore.s may need to be modified for it 77 | * to work successfully. 78 | * 79 | * WARNING: Don't use numbers 0 through -9. They (along with 80 | * the positive numbers) are reserved for Unix. 81 | */ 82 | 83 | int kern_invalid_debug = 0; 84 | 85 | /* Include declarations of the trap functions. */ 86 | 87 | #include 88 | #include 89 | #include 90 | 91 | #include 92 | #include 93 | 94 | mach_trap_t mach_trap_table[MACH_TRAP_TABLE_COUNT] = { 95 | /* 0 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 96 | /* 1 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 97 | /* 2 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 98 | /* 3 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 99 | /* 4 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 100 | /* 5 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 101 | /* 6 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 102 | /* 7 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 103 | /* 8 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 104 | /* 9 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 105 | /* 10 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 106 | /* 11 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 107 | /* 12 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 108 | /* 13 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 109 | /* 14 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 110 | /* 15 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 111 | /* 16 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 112 | /* 17 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 113 | /* 18 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 114 | /* 19 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 115 | /* 20 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 116 | /* 21 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 117 | /* 22 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 118 | /* 23 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 119 | /* 24 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 120 | /* 25 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 121 | /* 26 */ MACH_TRAP(mach_reply_port, 0, NULL, NULL), 122 | /* 27 */ MACH_TRAP(thread_self_trap, 0, NULL, NULL), 123 | /* 28 */ MACH_TRAP(task_self_trap, 0, NULL, NULL), 124 | /* 29 */ MACH_TRAP(host_self_trap, 0, NULL, NULL), 125 | /* 30 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 126 | /* 31 */ MACH_TRAP(mach_msg_trap, 7, munge_wwwwwww, munge_ddddddd), 127 | /* 32 */ MACH_TRAP(mach_msg_overwrite_trap, 8, munge_wwwwwwww, munge_dddddddd), 128 | /* 33 */ MACH_TRAP(semaphore_signal_trap, 1, munge_w, munge_d), 129 | /* 34 */ MACH_TRAP(semaphore_signal_all_trap, 1, munge_w, munge_d), 130 | /* 35 */ MACH_TRAP(semaphore_signal_thread_trap, 2, munge_ww, munge_dd), 131 | /* 36 */ MACH_TRAP(semaphore_wait_trap, 1, munge_w, munge_d), 132 | /* 37 */ MACH_TRAP(semaphore_wait_signal_trap, 2, munge_ww, munge_dd), 133 | /* 38 */ MACH_TRAP(semaphore_timedwait_trap, 3, munge_www, munge_ddd), 134 | /* 39 */ MACH_TRAP(semaphore_timedwait_signal_trap, 4, munge_wwww, munge_dddd), 135 | /* 40 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 136 | /* 41 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 137 | /* 42 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 138 | #if !defined(CONFIG_EMBEDDED) 139 | /* 43 */ MACH_TRAP(map_fd, 5, munge_wwwww, munge_ddddd), 140 | #else 141 | /* 43 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 142 | #endif /* !defined(CONFIG_EMBEDDED) */ 143 | /* 44 */ MACH_TRAP(task_name_for_pid, 3, munge_www, munge_ddd), 144 | /* 45 */ MACH_TRAP(task_for_pid, 3, munge_www, munge_ddd), 145 | /* 46 */ MACH_TRAP(pid_for_task, 2, munge_ww,munge_dd), 146 | /* 47 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 147 | /* 48 */ MACH_TRAP(macx_swapon, 5, munge_lwww, munge_dddd), 148 | /* 49 */ MACH_TRAP(macx_swapoff, 3, munge_lw, munge_dd), 149 | /* 50 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 150 | /* 51 */ MACH_TRAP(macx_triggers, 4, munge_wwww, munge_dddd), 151 | /* 52 */ MACH_TRAP(macx_backing_store_suspend, 1, munge_w, munge_d), 152 | /* 53 */ MACH_TRAP(macx_backing_store_recovery, 1, munge_w, munge_d), 153 | /* 54 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 154 | /* 55 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 155 | /* 56 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 156 | /* 57 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 157 | /* 58 */ MACH_TRAP(pfz_exit, 0, NULL, NULL), 158 | /* 59 */ MACH_TRAP(swtch_pri, 0, NULL, NULL), 159 | /* 60 */ MACH_TRAP(swtch, 0, NULL, NULL), 160 | /* 61 */ MACH_TRAP(thread_switch, 3, munge_www, munge_ddd), 161 | /* 62 */ MACH_TRAP(clock_sleep_trap, 5, munge_wwwww, munge_ddddd), 162 | /* 63 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 163 | /* traps 64 - 95 reserved (debo) */ 164 | /* 64 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 165 | /* 65 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 166 | /* 66 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 167 | /* 67 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 168 | /* 68 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 169 | /* 69 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 170 | /* 70 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 171 | /* 71 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 172 | /* 72 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 173 | /* 73 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 174 | /* 74 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 175 | /* 75 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 176 | /* 76 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 177 | /* 77 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 178 | /* 78 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 179 | /* 79 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 180 | /* 80 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 181 | /* 81 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 182 | /* 82 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 183 | /* 83 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 184 | /* 84 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 185 | /* 85 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 186 | /* 86 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 187 | /* 87 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 188 | /* 88 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 189 | /* 89 */ MACH_TRAP(mach_timebase_info_trap, 1, munge_w, munge_d), 190 | /* 90 */ MACH_TRAP(mach_wait_until_trap, 2, munge_l, munge_d), 191 | /* 91 */ MACH_TRAP(mk_timer_create_trap, 0, NULL, NULL), 192 | /* 92 */ MACH_TRAP(mk_timer_destroy_trap, 1, munge_w, munge_d), 193 | /* 93 */ MACH_TRAP(mk_timer_arm_trap, 3, munge_wl, munge_dd), 194 | /* 94 */ MACH_TRAP(mk_timer_cancel_trap, 2, munge_ww, munge_dd), 195 | /* 95 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 196 | /* traps 64 - 95 reserved (debo) */ 197 | /* 96 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 198 | /* 97 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 199 | /* 98 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 200 | /* 99 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 201 | /* traps 100-107 reserved for iokit (esb) */ 202 | /* 100 */ MACH_TRAP(iokit_user_client_trap, 8, munge_wwwwwwww, munge_dddddddd), 203 | /* 101 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 204 | /* 102 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 205 | /* 103 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 206 | /* 104 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 207 | /* 105 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 208 | /* 106 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 209 | /* 107 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 210 | /* traps 108-127 unused */ 211 | /* 108 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 212 | /* 109 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 213 | /* 110 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 214 | /* 111 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 215 | /* 112 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 216 | /* 113 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 217 | /* 114 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 218 | /* 115 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 219 | /* 116 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 220 | /* 117 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 221 | /* 118 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 222 | /* 119 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 223 | /* 120 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 224 | /* 121 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 225 | /* 122 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 226 | /* 123 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 227 | /* 124 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 228 | /* 125 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 229 | /* 126 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 230 | /* 127 */ MACH_TRAP(kern_invalid, 0, NULL, NULL), 231 | }; 232 | 233 | const char * mach_syscall_name_table[MACH_TRAP_TABLE_COUNT] = { 234 | /* 0 */ "kern_invalid", 235 | /* 1 */ "kern_invalid", 236 | /* 2 */ "kern_invalid", 237 | /* 3 */ "kern_invalid", 238 | /* 4 */ "kern_invalid", 239 | /* 5 */ "kern_invalid", 240 | /* 6 */ "kern_invalid", 241 | /* 7 */ "kern_invalid", 242 | /* 8 */ "kern_invalid", 243 | /* 9 */ "kern_invalid", 244 | /* 10 */ "kern_invalid", 245 | /* 11 */ "kern_invalid", 246 | /* 12 */ "kern_invalid", 247 | /* 13 */ "kern_invalid", 248 | /* 14 */ "kern_invalid", 249 | /* 15 */ "kern_invalid", 250 | /* 16 */ "kern_invalid", 251 | /* 17 */ "kern_invalid", 252 | /* 18 */ "kern_invalid", 253 | /* 19 */ "kern_invalid", 254 | /* 20 */ "kern_invalid", 255 | /* 21 */ "kern_invalid", 256 | /* 22 */ "kern_invalid", 257 | /* 23 */ "kern_invalid", 258 | /* 24 */ "kern_invalid", 259 | /* 25 */ "kern_invalid", 260 | /* 26 */ "mach_reply_port", 261 | /* 27 */ "thread_self_trap", 262 | /* 28 */ "task_self_trap", 263 | /* 29 */ "host_self_trap", 264 | /* 30 */ "kern_invalid", 265 | /* 31 */ "mach_msg_trap", 266 | /* 32 */ "mach_msg_overwrite_trap", 267 | /* 33 */ "semaphore_signal_trap", 268 | /* 34 */ "semaphore_signal_all_trap", 269 | /* 35 */ "semaphore_signal_thread_trap", 270 | /* 36 */ "semaphore_wait_trap", 271 | /* 37 */ "semaphore_wait_signal_trap", 272 | /* 38 */ "semaphore_timedwait_trap", 273 | /* 39 */ "semaphore_timedwait_signal_trap", 274 | /* 40 */ "kern_invalid", 275 | /* 41 */ "kern_invalid", 276 | /* 42 */ "kern_invalid", 277 | /* 43 */ "map_fd", 278 | /* 44 */ "task_name_for_pid", 279 | /* 45 */ "task_for_pid", 280 | /* 46 */ "pid_for_task", 281 | /* 47 */ "kern_invalid", 282 | /* 48 */ "macx_swapon", 283 | /* 49 */ "macx_swapoff", 284 | /* 50 */ "kern_invalid", 285 | /* 51 */ "macx_triggers", 286 | /* 52 */ "macx_backing_store_suspend", 287 | /* 53 */ "macx_backing_store_recovery", 288 | /* 54 */ "kern_invalid", 289 | /* 55 */ "kern_invalid", 290 | /* 56 */ "kern_invalid", 291 | /* 57 */ "kern_invalid", 292 | /* 58 */ "pfz_exit", 293 | /* 59 */ "swtch_pri", 294 | /* 60 */ "swtch", 295 | /* 61 */ "thread_switch", 296 | /* 62 */ "clock_sleep_trap", 297 | /* 63 */ "kern_invalid", 298 | /* traps 64 - 95 reserved (debo) */ 299 | /* 64 */ "kern_invalid", 300 | /* 65 */ "kern_invalid", 301 | /* 66 */ "kern_invalid", 302 | /* 67 */ "kern_invalid", 303 | /* 68 */ "kern_invalid", 304 | /* 69 */ "kern_invalid", 305 | /* 70 */ "kern_invalid", 306 | /* 71 */ "kern_invalid", 307 | /* 72 */ "kern_invalid", 308 | /* 73 */ "kern_invalid", 309 | /* 74 */ "kern_invalid", 310 | /* 75 */ "kern_invalid", 311 | /* 76 */ "kern_invalid", 312 | /* 77 */ "kern_invalid", 313 | /* 78 */ "kern_invalid", 314 | /* 79 */ "kern_invalid", 315 | /* 80 */ "kern_invalid", 316 | /* 81 */ "kern_invalid", 317 | /* 82 */ "kern_invalid", 318 | /* 83 */ "kern_invalid", 319 | /* 84 */ "kern_invalid", 320 | /* 85 */ "kern_invalid", 321 | /* 86 */ "kern_invalid", 322 | /* 87 */ "kern_invalid", 323 | /* 88 */ "kern_invalid", 324 | /* 89 */ "mach_timebase_info_trap", 325 | /* 90 */ "mach_wait_until_trap", 326 | /* 91 */ "mk_timer_create_trap", 327 | /* 92 */ "mk_timer_destroy_trap", 328 | /* 93 */ "mk_timer_arm_trap", 329 | /* 94 */ "mk_timer_cancel_trap", 330 | /* 95 */ "kern_invalid", 331 | /* traps 64 - 95 reserved (debo) */ 332 | /* 96 */ "kern_invalid", 333 | /* 97 */ "kern_invalid", 334 | /* 98 */ "kern_invalid", 335 | /* 99 */ "kern_invalid", 336 | /* traps 100-107 reserved for iokit (esb) */ 337 | /* 100 */ "kern_invalid", 338 | /* 100 */ //"iokit_user_client_trap", 339 | /* 101 */ "kern_invalid", 340 | /* 102 */ "kern_invalid", 341 | /* 103 */ "kern_invalid", 342 | /* 104 */ "kern_invalid", 343 | /* 105 */ "kern_invalid", 344 | /* 106 */ "kern_invalid", 345 | /* 107 */ "kern_invalid", 346 | /* traps 108-127 unused */ 347 | /* 108 */ "kern_invalid", 348 | /* 109 */ "kern_invalid", 349 | /* 110 */ "kern_invalid", 350 | /* 111 */ "kern_invalid", 351 | /* 112 */ "kern_invalid", 352 | /* 113 */ "kern_invalid", 353 | /* 114 */ "kern_invalid", 354 | /* 115 */ "kern_invalid", 355 | /* 116 */ "kern_invalid", 356 | /* 117 */ "kern_invalid", 357 | /* 118 */ "kern_invalid", 358 | /* 119 */ "kern_invalid", 359 | /* 120 */ "kern_invalid", 360 | /* 121 */ "kern_invalid", 361 | /* 122 */ "kern_invalid", 362 | /* 123 */ "kern_invalid", 363 | /* 124 */ "kern_invalid", 364 | /* 125 */ "kern_invalid", 365 | /* 126 */ "kern_invalid", 366 | /* 127 */ "kern_invalid", 367 | }; 368 | 369 | int mach_trap_count = (sizeof(mach_trap_table) / sizeof(mach_trap_table[0])); 370 | 371 | kern_return_t 372 | kern_invalid( 373 | __unused struct kern_invalid_args *args) 374 | { 375 | if (kern_invalid_debug) Debugger("kern_invalid mach trap"); 376 | return(KERN_INVALID_ARGUMENT); 377 | } 378 | 379 | -------------------------------------------------------------------------------- /grapevine/res/syscalls.master: -------------------------------------------------------------------------------- 1 | ; derived from: FreeBSD @(#)syscalls.master 8.2 (Berkeley) 1/13/94 2 | ; 3 | ; System call name/number master file. 4 | ; This is file processed by .../xnu/bsd/kern/makesyscalls.sh and creates: 5 | ; .../xnu/bsd/kern/init_sysent.c 6 | ; .../xnu/bsd/kern/syscalls.c 7 | ; .../xnu/bsd/sys/syscall.h 8 | ; .../xnu/bsd/sys/sysproto.h 9 | ; .../xnu/bsd/security/audit_syscalls.c 10 | 11 | ; Columns -> | Number Audit Files | { Name and Args } | { Comments } 12 | ; Number: system call number, must be in order 13 | ; Audit: the audit event associated with the system call 14 | ; A value of AUE_NULL means no auditing, but it also means that 15 | ; there is no audit event for the call at this time. For the 16 | ; case where the event exists, but we don't want auditing, the 17 | ; event should be #defined to AUE_NULL in audit_kevents.h. 18 | ; Files: with files to generate - "ALL" or any combo of: 19 | ; "T" for syscall table (in init_sysent.c) 20 | ; "N" for syscall names (in syscalls.c) 21 | ; "H" for syscall headers (in syscall.h) 22 | ; "P" for syscall prototypes (in sysproto.h) 23 | ; Name and Args: function prototype, optionally followed by 24 | ; NO_SYSCALL_STUB (which mean no system call stub will 25 | ; be generated in libSystem) and ending with a semicolon. 26 | ; (Note: functions prefixed by double-underbar are 27 | ; automatically given the NO_SYSCALL_STUB attribute.) 28 | ; Comments: additional comments about the sys call copied to output files 29 | 30 | ; #ifdef's, #include's, #if's etc. are copied to all output files. 31 | ; N.B.: makesyscalls.sh and createsyscalls.pl must be updated to account 32 | ; for any new argument types. 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | 0 AUE_NULL ALL { int nosys(void); } { indirect syscall } 42 | 1 AUE_EXIT ALL { void exit(int rval); } 43 | 2 AUE_FORK ALL { int fork(void); } 44 | 3 AUE_NULL ALL { user_ssize_t read(int fd, user_addr_t cbuf, user_size_t nbyte); } 45 | 4 AUE_NULL ALL { user_ssize_t write(int fd, user_addr_t cbuf, user_size_t nbyte); } 46 | 5 AUE_OPEN_RWTC ALL { int open(user_addr_t path, int flags, int mode); } 47 | 6 AUE_CLOSE ALL { int close(int fd); } 48 | 7 AUE_WAIT4 ALL { int wait4(int pid, user_addr_t status, int options, user_addr_t rusage); } 49 | 8 AUE_NULL ALL { int nosys(void); } { old creat } 50 | 9 AUE_LINK ALL { int link(user_addr_t path, user_addr_t link); } 51 | 10 AUE_UNLINK ALL { int unlink(user_addr_t path); } 52 | 11 AUE_NULL ALL { int nosys(void); } { old execv } 53 | 12 AUE_CHDIR ALL { int chdir(user_addr_t path); } 54 | 13 AUE_FCHDIR ALL { int fchdir(int fd); } 55 | 14 AUE_MKNOD ALL { int mknod(user_addr_t path, int mode, int dev); } 56 | 15 AUE_CHMOD ALL { int chmod(user_addr_t path, int mode); } 57 | 16 AUE_CHOWN ALL { int chown(user_addr_t path, int uid, int gid); } 58 | 17 AUE_NULL ALL { int nosys(void); } { old break } 59 | 18 AUE_GETFSSTAT ALL { int getfsstat(user_addr_t buf, int bufsize, int flags); } 60 | 19 AUE_NULL ALL { int nosys(void); } { old lseek } 61 | 20 AUE_GETPID ALL { int getpid(void); } 62 | 21 AUE_NULL ALL { int nosys(void); } { old mount } 63 | 22 AUE_NULL ALL { int nosys(void); } { old umount } 64 | 23 AUE_SETUID ALL { int setuid(uid_t uid); } 65 | 24 AUE_GETUID ALL { int getuid(void); } 66 | 25 AUE_GETEUID ALL { int geteuid(void); } 67 | 26 AUE_PTRACE ALL { int ptrace(int req, pid_t pid, caddr_t addr, int data); } 68 | #if SOCKETS 69 | 27 AUE_RECVMSG ALL { int recvmsg(int s, struct msghdr *msg, int flags); } 70 | 28 AUE_SENDMSG ALL { int sendmsg(int s, caddr_t msg, int flags); } 71 | 29 AUE_RECVFROM ALL { int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlenaddr); } 72 | 30 AUE_ACCEPT ALL { int accept(int s, caddr_t name, socklen_t *anamelen); } 73 | 31 AUE_GETPEERNAME ALL { int getpeername(int fdes, caddr_t asa, socklen_t *alen); } 74 | 32 AUE_GETSOCKNAME ALL { int getsockname(int fdes, caddr_t asa, socklen_t *alen); } 75 | #else 76 | 27 AUE_NULL ALL { int nosys(void); } 77 | 28 AUE_NULL ALL { int nosys(void); } 78 | 29 AUE_NULL ALL { int nosys(void); } 79 | 30 AUE_NULL ALL { int nosys(void); } 80 | 31 AUE_NULL ALL { int nosys(void); } 81 | 32 AUE_NULL ALL { int nosys(void); } 82 | #endif /* SOCKETS */ 83 | 33 AUE_ACCESS ALL { int access(user_addr_t path, int flags); } 84 | 34 AUE_CHFLAGS ALL { int chflags(char *path, int flags); } 85 | 35 AUE_FCHFLAGS ALL { int fchflags(int fd, int flags); } 86 | 36 AUE_SYNC ALL { int sync(void); } 87 | 37 AUE_KILL ALL { int kill(int pid, int signum, int posix); } 88 | 38 AUE_NULL ALL { int nosys(void); } { old stat } 89 | 39 AUE_GETPPID ALL { int getppid(void); } 90 | 40 AUE_NULL ALL { int nosys(void); } { old lstat } 91 | 41 AUE_DUP ALL { int dup(u_int fd); } 92 | 42 AUE_PIPE ALL { int pipe(void); } 93 | 43 AUE_GETEGID ALL { int getegid(void); } 94 | 44 AUE_PROFILE ALL { int profil(short *bufbase, size_t bufsize, u_long pcoffset, u_int pcscale); } 95 | 45 AUE_NULL ALL { int nosys(void); } { old ktrace } 96 | 46 AUE_SIGACTION ALL { int sigaction(int signum, struct __sigaction *nsa, struct sigaction *osa); } 97 | 47 AUE_GETGID ALL { int getgid(void); } 98 | 48 AUE_SIGPROCMASK ALL { int sigprocmask(int how, user_addr_t mask, user_addr_t omask); } 99 | 49 AUE_GETLOGIN ALL { int getlogin(char *namebuf, u_int namelen); } 100 | 50 AUE_SETLOGIN ALL { int setlogin(char *namebuf); } 101 | 51 AUE_ACCT ALL { int acct(char *path); } 102 | 52 AUE_SIGPENDING ALL { int sigpending(struct sigvec *osv); } 103 | 53 AUE_SIGALTSTACK ALL { int sigaltstack(struct sigaltstack *nss, struct sigaltstack *oss); } 104 | 54 AUE_IOCTL ALL { int ioctl(int fd, u_long com, caddr_t data); } 105 | 55 AUE_REBOOT ALL { int reboot(int opt, char *command); } 106 | 56 AUE_REVOKE ALL { int revoke(char *path); } 107 | 57 AUE_SYMLINK ALL { int symlink(char *path, char *link); } 108 | 58 AUE_READLINK ALL { int readlink(char *path, char *buf, int count); } 109 | 59 AUE_EXECVE ALL { int execve(char *fname, char **argp, char **envp); } 110 | 60 AUE_UMASK ALL { int umask(int newmask); } 111 | 61 AUE_CHROOT ALL { int chroot(user_addr_t path); } 112 | 62 AUE_NULL ALL { int nosys(void); } { old fstat } 113 | 63 AUE_NULL ALL { int nosys(void); } { used internally, reserved } 114 | 64 AUE_NULL ALL { int nosys(void); } { old getpagesize } 115 | 65 AUE_MSYNC ALL { int msync(caddr_t addr, size_t len, int flags); } 116 | 66 AUE_VFORK ALL { int vfork(void); } 117 | 67 AUE_NULL ALL { int nosys(void); } { old vread } 118 | 68 AUE_NULL ALL { int nosys(void); } { old vwrite } 119 | 69 AUE_NULL ALL { int nosys(void); } { old sbrk } 120 | 70 AUE_NULL ALL { int nosys(void); } { old sstk } 121 | 71 AUE_NULL ALL { int nosys(void); } { old mmap } 122 | 72 AUE_NULL ALL { int nosys(void); } { old vadvise } 123 | 73 AUE_MUNMAP ALL { int munmap(caddr_t addr, size_t len); } 124 | 74 AUE_MPROTECT ALL { int mprotect(caddr_t addr, size_t len, int prot); } 125 | 75 AUE_MADVISE ALL { int madvise(caddr_t addr, size_t len, int behav); } 126 | 76 AUE_NULL ALL { int nosys(void); } { old vhangup } 127 | 77 AUE_NULL ALL { int nosys(void); } { old vlimit } 128 | 78 AUE_MINCORE ALL { int mincore(user_addr_t addr, user_size_t len, user_addr_t vec); } 129 | 79 AUE_GETGROUPS ALL { int getgroups(u_int gidsetsize, gid_t *gidset); } 130 | 80 AUE_SETGROUPS ALL { int setgroups(u_int gidsetsize, gid_t *gidset); } 131 | 81 AUE_GETPGRP ALL { int getpgrp(void); } 132 | 82 AUE_SETPGRP ALL { int setpgid(int pid, int pgid); } 133 | 83 AUE_SETITIMER ALL { int setitimer(u_int which, struct itimerval *itv, struct itimerval *oitv); } 134 | 84 AUE_NULL ALL { int nosys(void); } { old wait } 135 | 85 AUE_SWAPON ALL { int swapon(void); } 136 | 86 AUE_GETITIMER ALL { int getitimer(u_int which, struct itimerval *itv); } 137 | 87 AUE_NULL ALL { int nosys(void); } { old gethostname } 138 | 88 AUE_NULL ALL { int nosys(void); } { old sethostname } 139 | 89 AUE_GETDTABLESIZE ALL { int getdtablesize(void); } 140 | 90 AUE_DUP2 ALL { int dup2(u_int from, u_int to); } 141 | 91 AUE_NULL ALL { int nosys(void); } { old getdopt } 142 | 92 AUE_FCNTL ALL { int fcntl(int fd, int cmd, long arg); } 143 | 93 AUE_SELECT ALL { int select(int nd, u_int32_t *in, u_int32_t *ou, u_int32_t *ex, struct timeval *tv); } 144 | 94 AUE_NULL ALL { int nosys(void); } { old setdopt } 145 | 95 AUE_FSYNC ALL { int fsync(int fd); } 146 | 96 AUE_SETPRIORITY ALL { int setpriority(int which, id_t who, int prio); } 147 | #if SOCKETS 148 | 97 AUE_SOCKET ALL { int socket(int domain, int type, int protocol); } 149 | 98 AUE_CONNECT ALL { int connect(int s, caddr_t name, socklen_t namelen); } 150 | #else 151 | 97 AUE_NULL ALL { int nosys(void); } 152 | 98 AUE_NULL ALL { int nosys(void); } 153 | #endif /* SOCKETS */ 154 | 99 AUE_NULL ALL { int nosys(void); } { old accept } 155 | 100 AUE_GETPRIORITY ALL { int getpriority(int which, id_t who); } 156 | 101 AUE_NULL ALL { int nosys(void); } { old send } 157 | 102 AUE_NULL ALL { int nosys(void); } { old recv } 158 | 103 AUE_NULL ALL { int nosys(void); } { old sigreturn } 159 | #if SOCKETS 160 | 104 AUE_BIND ALL { int bind(int s, caddr_t name, socklen_t namelen); } 161 | 105 AUE_SETSOCKOPT ALL { int setsockopt(int s, int level, int name, caddr_t val, socklen_t valsize); } 162 | 106 AUE_LISTEN ALL { int listen(int s, int backlog); } 163 | #else 164 | 104 AUE_NULL ALL { int nosys(void); } 165 | 105 AUE_NULL ALL { int nosys(void); } 166 | 106 AUE_NULL ALL { int nosys(void); } 167 | #endif /* SOCKETS */ 168 | 107 AUE_NULL ALL { int nosys(void); } { old vtimes } 169 | 108 AUE_NULL ALL { int nosys(void); } { old sigvec } 170 | 109 AUE_NULL ALL { int nosys(void); } { old sigblock } 171 | 110 AUE_NULL ALL { int nosys(void); } { old sigsetmask } 172 | 111 AUE_NULL ALL { int sigsuspend(sigset_t mask); } 173 | 112 AUE_NULL ALL { int nosys(void); } { old sigstack } 174 | #if SOCKETS 175 | 113 AUE_NULL ALL { int nosys(void); } { old recvmsg } 176 | 114 AUE_NULL ALL { int nosys(void); } { old sendmsg } 177 | #else 178 | 113 AUE_NULL ALL { int nosys(void); } 179 | 114 AUE_NULL ALL { int nosys(void); } 180 | #endif /* SOCKETS */ 181 | 115 AUE_NULL ALL { int nosys(void); } { old vtrace } 182 | 116 AUE_GETTIMEOFDAY ALL { int gettimeofday(struct timeval *tp, struct timezone *tzp); } 183 | 117 AUE_GETRUSAGE ALL { int getrusage(int who, struct rusage *rusage); } 184 | #if SOCKETS 185 | 118 AUE_GETSOCKOPT ALL { int getsockopt(int s, int level, int name, caddr_t val, socklen_t *avalsize); } 186 | #else 187 | 118 AUE_NULL ALL { int nosys(void); } 188 | #endif /* SOCKETS */ 189 | 119 AUE_NULL ALL { int nosys(void); } { old resuba } 190 | 120 AUE_READV ALL { user_ssize_t readv(int fd, struct iovec *iovp, u_int iovcnt); } 191 | 121 AUE_WRITEV ALL { user_ssize_t writev(int fd, struct iovec *iovp, u_int iovcnt); } 192 | 122 AUE_SETTIMEOFDAY ALL { int settimeofday(struct timeval *tv, struct timezone *tzp); } 193 | 123 AUE_FCHOWN ALL { int fchown(int fd, int uid, int gid); } 194 | 124 AUE_FCHMOD ALL { int fchmod(int fd, int mode); } 195 | 125 AUE_NULL ALL { int nosys(void); } { old recvfrom } 196 | 126 AUE_SETREUID ALL { int setreuid(uid_t ruid, uid_t euid); } 197 | 127 AUE_SETREGID ALL { int setregid(gid_t rgid, gid_t egid); } 198 | 128 AUE_RENAME ALL { int rename(char *from, char *to); } 199 | 129 AUE_NULL ALL { int nosys(void); } { old truncate } 200 | 130 AUE_NULL ALL { int nosys(void); } { old ftruncate } 201 | 131 AUE_FLOCK ALL { int flock(int fd, int how); } 202 | 132 AUE_MKFIFO ALL { int mkfifo(user_addr_t path, int mode); } 203 | #if SOCKETS 204 | 133 AUE_SENDTO ALL { int sendto(int s, caddr_t buf, size_t len, int flags, caddr_t to, socklen_t tolen); } 205 | 134 AUE_SHUTDOWN ALL { int shutdown(int s, int how); } 206 | 135 AUE_SOCKETPAIR ALL { int socketpair(int domain, int type, int protocol, int *rsv); } 207 | #else 208 | 133 AUE_NULL ALL { int nosys(void); } 209 | 134 AUE_NULL ALL { int nosys(void); } 210 | 135 AUE_NULL ALL { int nosys(void); } 211 | #endif /* SOCKETS */ 212 | 136 AUE_MKDIR ALL { int mkdir(user_addr_t path, int mode); } 213 | 137 AUE_RMDIR ALL { int rmdir(char *path); } 214 | 138 AUE_UTIMES ALL { int utimes(char *path, struct timeval *tptr); } 215 | 139 AUE_FUTIMES ALL { int futimes(int fd, struct timeval *tptr); } 216 | 140 AUE_ADJTIME ALL { int adjtime(struct timeval *delta, struct timeval *olddelta); } 217 | 141 AUE_NULL ALL { int nosys(void); } { old getpeername } 218 | 142 AUE_SYSCTL ALL { int gethostuuid(unsigned char *uuid_buf, const struct timespec *timeoutp); } 219 | 143 AUE_NULL ALL { int nosys(void); } { old sethostid } 220 | 144 AUE_NULL ALL { int nosys(void); } { old getrlimit } 221 | 145 AUE_NULL ALL { int nosys(void); } { old setrlimit } 222 | 146 AUE_NULL ALL { int nosys(void); } { old killpg } 223 | 147 AUE_SETSID ALL { int setsid(void); } 224 | 148 AUE_NULL ALL { int nosys(void); } { old setquota } 225 | 149 AUE_NULL ALL { int nosys(void); } { old qquota } 226 | 150 AUE_NULL ALL { int nosys(void); } { old getsockname } 227 | 151 AUE_GETPGID ALL { int getpgid(pid_t pid); } 228 | 152 AUE_SETPRIVEXEC ALL { int setprivexec(int flag); } 229 | 153 AUE_PREAD ALL { user_ssize_t pread(int fd, user_addr_t buf, user_size_t nbyte, off_t offset); } 230 | 154 AUE_PWRITE ALL { user_ssize_t pwrite(int fd, user_addr_t buf, user_size_t nbyte, off_t offset); } 231 | 232 | #if NFSSERVER 233 | 155 AUE_NFS_SVC ALL { int nfssvc(int flag, caddr_t argp); } 234 | #else 235 | 155 AUE_NULL ALL { int nosys(void); } 236 | #endif 237 | 238 | 156 AUE_NULL ALL { int nosys(void); } { old getdirentries } 239 | 157 AUE_STATFS ALL { int statfs(char *path, struct statfs *buf); } 240 | 158 AUE_FSTATFS ALL { int fstatfs(int fd, struct statfs *buf); } 241 | 159 AUE_UNMOUNT ALL { int unmount(user_addr_t path, int flags); } 242 | 160 AUE_NULL ALL { int nosys(void); } { old async_daemon } 243 | 244 | #if NFSSERVER 245 | 161 AUE_NFS_GETFH ALL { int getfh(char *fname, fhandle_t *fhp); } 246 | #else 247 | 161 AUE_NULL ALL { int nosys(void); } 248 | #endif 249 | 250 | 162 AUE_NULL ALL { int nosys(void); } { old getdomainname } 251 | 163 AUE_NULL ALL { int nosys(void); } { old setdomainname } 252 | 164 AUE_NULL ALL { int nosys(void); } 253 | 165 AUE_QUOTACTL ALL { int quotactl(const char *path, int cmd, int uid, caddr_t arg); } 254 | 166 AUE_NULL ALL { int nosys(void); } { old exportfs } 255 | 167 AUE_MOUNT ALL { int mount(char *type, char *path, int flags, caddr_t data); } 256 | 168 AUE_NULL ALL { int nosys(void); } { old ustat } 257 | 169 AUE_CSOPS ALL { int csops(pid_t pid, uint32_t ops, user_addr_t useraddr, user_size_t usersize); } 258 | 170 AUE_NULL HN { int nosys(void); } { old table } 259 | 171 AUE_NULL ALL { int nosys(void); } { old wait3 } 260 | 172 AUE_NULL ALL { int nosys(void); } { old rpause } 261 | 173 AUE_WAITID ALL { int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); } 262 | 174 AUE_NULL ALL { int nosys(void); } { old getdents } 263 | 175 AUE_NULL ALL { int nosys(void); } { old gc_control } 264 | 176 AUE_ADDPROFILE ALL { int add_profil(short *bufbase, size_t bufsize, u_long pcoffset, u_int pcscale); } 265 | 177 AUE_NULL ALL { int nosys(void); } 266 | 178 AUE_NULL ALL { int nosys(void); } 267 | 179 AUE_NULL ALL { int nosys(void); } 268 | 180 AUE_KDEBUGTRACE ALL { int kdebug_trace(int code, int arg1, int arg2, int arg3, int arg4, int arg5) NO_SYSCALL_STUB; } 269 | 181 AUE_SETGID ALL { int setgid(gid_t gid); } 270 | 182 AUE_SETEGID ALL { int setegid(gid_t egid); } 271 | 183 AUE_SETEUID ALL { int seteuid(uid_t euid); } 272 | 184 AUE_SIGRETURN ALL { int sigreturn(struct ucontext *uctx, int infostyle) NO_SYSCALL_STUB; } 273 | 185 AUE_CHUD ALL { int chud(uint64_t code, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) NO_SYSCALL_STUB; } 274 | 186 AUE_NULL ALL { int nosys(void); } 275 | 187 AUE_FDATASYNC ALL { int fdatasync(int fd); } 276 | 188 AUE_STAT ALL { int stat(user_addr_t path, user_addr_t ub); } 277 | 189 AUE_FSTAT ALL { int fstat(int fd, user_addr_t ub); } 278 | 190 AUE_LSTAT ALL { int lstat(user_addr_t path, user_addr_t ub); } 279 | 191 AUE_PATHCONF ALL { int pathconf(char *path, int name); } 280 | 192 AUE_FPATHCONF ALL { int fpathconf(int fd, int name); } 281 | 193 AUE_NULL ALL { int nosys(void); } 282 | 194 AUE_GETRLIMIT ALL { int getrlimit(u_int which, struct rlimit *rlp); } 283 | 195 AUE_SETRLIMIT ALL { int setrlimit(u_int which, struct rlimit *rlp); } 284 | 196 AUE_GETDIRENTRIES ALL { int getdirentries(int fd, char *buf, u_int count, long *basep); } 285 | 197 AUE_MMAP ALL { user_addr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos); } 286 | 198 AUE_NULL ALL { int nosys(void); } { __syscall } 287 | 199 AUE_LSEEK ALL { off_t lseek(int fd, off_t offset, int whence); } 288 | 200 AUE_TRUNCATE ALL { int truncate(char *path, off_t length); } 289 | 201 AUE_FTRUNCATE ALL { int ftruncate(int fd, off_t length); } 290 | 202 AUE_SYSCTL ALL { int __sysctl(int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen); } 291 | 203 AUE_MLOCK ALL { int mlock(caddr_t addr, size_t len); } 292 | 204 AUE_MUNLOCK ALL { int munlock(caddr_t addr, size_t len); } 293 | 205 AUE_UNDELETE ALL { int undelete(user_addr_t path); } 294 | 295 | #if NETAT 296 | 206 AUE_ATSOCKET ALL { int ATsocket(int proto); } 297 | 207 AUE_ATGETMSG UALL { int ATgetmsg(int fd, void *ctlptr, void *datptr, int *flags); } 298 | 208 AUE_ATPUTMSG UALL { int ATputmsg(int fd, void *ctlptr, void *datptr, int flags); } 299 | 209 AUE_ATPSNDREQ UALL { int ATPsndreq(int fd, unsigned char *buf, int len, int nowait); } 300 | 210 AUE_ATPSNDRSP UALL { int ATPsndrsp(int fd, unsigned char *respbuff, int resplen, int datalen); } 301 | 211 AUE_ATPGETREQ UALL { int ATPgetreq(int fd, unsigned char *buf, int buflen); } 302 | 212 AUE_ATPGETRSP UALL { int ATPgetrsp(int fd, unsigned char *bdsp); } 303 | 213 AUE_NULL ALL { int nosys(void); } { Reserved for AppleTalk } 304 | #else 305 | 206 AUE_NULL ALL { int nosys(void); } 306 | 207 AUE_NULL ALL { int nosys(void); } 307 | 208 AUE_NULL ALL { int nosys(void); } 308 | 209 AUE_NULL ALL { int nosys(void); } 309 | 210 AUE_NULL ALL { int nosys(void); } 310 | 211 AUE_NULL ALL { int nosys(void); } 311 | 212 AUE_NULL ALL { int nosys(void); } 312 | 213 AUE_NULL ALL { int nosys(void); } { Reserved for AppleTalk } 313 | #endif /* NETAT */ 314 | 315 | 214 AUE_NULL ALL { int nosys(void); } 316 | 215 AUE_NULL ALL { int nosys(void); } 317 | 318 | ; System Calls 216 - 230 are reserved for calls to support HFS/HFS Plus 319 | ; file system semantics. Currently, we only use 215-227. The rest is 320 | ; for future expansion in anticipation of new MacOS APIs for HFS Plus. 321 | ; These calls are not conditionalized because while they are specific 322 | ; to HFS semantics, they are not specific to the HFS filesystem. 323 | ; We expect all filesystems to recognize the call and report that it is 324 | ; not supported or to actually implement it. 325 | 216 AUE_MKCOMPLEX UHN { int mkcomplex(const char *path, mode_t mode, u_long type); } { soon to be obsolete } 326 | 217 AUE_STATV UHN { int statv(const char *path, struct vstat *vsb); } { soon to be obsolete } 327 | 218 AUE_LSTATV UHN { int lstatv(const char *path, struct vstat *vsb); } { soon to be obsolete } 328 | 219 AUE_FSTATV UHN { int fstatv(int fd, struct vstat *vsb); } { soon to be obsolete } 329 | 220 AUE_GETATTRLIST ALL { int getattrlist(const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); } 330 | 221 AUE_SETATTRLIST ALL { int setattrlist(const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); } 331 | 222 AUE_GETDIRENTRIESATTR ALL { int getdirentriesattr(int fd, struct attrlist *alist, void *buffer, size_t buffersize, u_long *count, u_long *basep, u_long *newstate, u_long options); } 332 | 223 AUE_EXCHANGEDATA ALL { int exchangedata(const char *path1, const char *path2, u_long options); } 333 | 224 AUE_NULL ALL { int nosys(void); } { old checkuseraccess / fsgetpath (which moved to 427) } 334 | 225 AUE_SEARCHFS ALL { int searchfs(const char *path, struct fssearchblock *searchblock, uint32_t *nummatches, uint32_t scriptcode, uint32_t options, struct searchstate *state); } 335 | 226 AUE_DELETE ALL { int delete(user_addr_t path) NO_SYSCALL_STUB; } { private delete (Carbon semantics) } 336 | 227 AUE_COPYFILE ALL { int copyfile(char *from, char *to, int mode, int flags) NO_SYSCALL_STUB; } 337 | 228 AUE_FGETATTRLIST ALL { int fgetattrlist(int fd, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); } 338 | 229 AUE_FSETATTRLIST ALL { int fsetattrlist(int fd, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); } 339 | 230 AUE_POLL ALL { int poll(struct pollfd *fds, u_int nfds, int timeout); } 340 | 231 AUE_WATCHEVENT ALL { int watchevent(struct eventreq *u_req, int u_eventmask); } 341 | 232 AUE_WAITEVENT ALL { int waitevent(struct eventreq *u_req, struct timeval *tv); } 342 | 233 AUE_MODWATCH ALL { int modwatch(struct eventreq *u_req, int u_eventmask); } 343 | 234 AUE_GETXATTR ALL { user_ssize_t getxattr(user_addr_t path, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); } 344 | 235 AUE_FGETXATTR ALL { user_ssize_t fgetxattr(int fd, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); } 345 | 236 AUE_SETXATTR ALL { int setxattr(user_addr_t path, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); } 346 | 237 AUE_FSETXATTR ALL { int fsetxattr(int fd, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); } 347 | 238 AUE_REMOVEXATTR ALL { int removexattr(user_addr_t path, user_addr_t attrname, int options); } 348 | 239 AUE_FREMOVEXATTR ALL { int fremovexattr(int fd, user_addr_t attrname, int options); } 349 | 240 AUE_LISTXATTR ALL { user_ssize_t listxattr(user_addr_t path, user_addr_t namebuf, size_t bufsize, int options); } 350 | 241 AUE_FLISTXATTR ALL { user_ssize_t flistxattr(int fd, user_addr_t namebuf, size_t bufsize, int options); } 351 | 242 AUE_FSCTL ALL { int fsctl(const char *path, u_long cmd, caddr_t data, u_int options); } 352 | 243 AUE_INITGROUPS ALL { int initgroups(u_int gidsetsize, gid_t *gidset, int gmuid); } 353 | 244 AUE_POSIX_SPAWN ALL { int posix_spawn(pid_t *pid, const char *path, const struct _posix_spawn_args_desc *adesc, char **argv, char **envp); } 354 | 245 AUE_FFSCTL ALL { int ffsctl(int fd, u_long cmd, caddr_t data, u_int options); } 355 | 246 AUE_NULL ALL { int nosys(void); } 356 | 357 | #if NFSCLIENT 358 | 247 AUE_NULL ALL { int nfsclnt(int flag, caddr_t argp); } 359 | #else 360 | 247 AUE_NULL ALL { int nosys(void); } 361 | #endif 362 | #if NFSSERVER 363 | 248 AUE_FHOPEN ALL { int fhopen(const struct fhandle *u_fhp, int flags); } 364 | #else 365 | 248 AUE_NULL ALL { int nosys(void); } 366 | #endif 367 | 368 | 249 AUE_NULL ALL { int nosys(void); } 369 | 250 AUE_MINHERIT ALL { int minherit(void *addr, size_t len, int inherit); } 370 | #if SYSV_SEM 371 | 251 AUE_SEMSYS ALL { int semsys(u_int which, int a2, int a3, int a4, int a5); } 372 | #else 373 | 251 AUE_NULL ALL { int nosys(void); } 374 | #endif 375 | #if SYSV_MSG 376 | 252 AUE_MSGSYS ALL { int msgsys(u_int which, int a2, int a3, int a4, int a5); } 377 | #else 378 | 252 AUE_NULL ALL { int nosys(void); } 379 | #endif 380 | #if SYSV_SHM 381 | 253 AUE_SHMSYS ALL { int shmsys(u_int which, int a2, int a3, int a4); } 382 | #else 383 | 253 AUE_NULL ALL { int nosys(void); } 384 | #endif 385 | #if SYSV_SEM 386 | 254 AUE_SEMCTL ALL { int semctl(int semid, int semnum, int cmd, semun_t arg); } 387 | 255 AUE_SEMGET ALL { int semget(key_t key, int nsems, int semflg); } 388 | 256 AUE_SEMOP ALL { int semop(int semid, struct sembuf *sops, int nsops); } 389 | 257 AUE_NULL ALL { int nosys(void); } 390 | #else 391 | 254 AUE_NULL ALL { int nosys(void); } 392 | 255 AUE_NULL ALL { int nosys(void); } 393 | 256 AUE_NULL ALL { int nosys(void); } 394 | 257 AUE_NULL ALL { int nosys(void); } 395 | #endif 396 | #if SYSV_MSG 397 | 258 AUE_MSGCTL ALL { int msgctl(int msqid, int cmd, struct msqid_ds *buf); } 398 | 259 AUE_MSGGET ALL { int msgget(key_t key, int msgflg); } 399 | 260 AUE_MSGSND ALL { int msgsnd(int msqid, void *msgp, size_t msgsz, int msgflg); } 400 | 261 AUE_MSGRCV ALL { user_ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } 401 | #else 402 | 258 AUE_NULL ALL { int nosys(void); } 403 | 259 AUE_NULL ALL { int nosys(void); } 404 | 260 AUE_NULL ALL { int nosys(void); } 405 | 261 AUE_NULL ALL { int nosys(void); } 406 | #endif 407 | #if SYSV_SHM 408 | 262 AUE_SHMAT ALL { user_addr_t shmat(int shmid, void *shmaddr, int shmflg); } 409 | 263 AUE_SHMCTL ALL { int shmctl(int shmid, int cmd, struct shmid_ds *buf); } 410 | 264 AUE_SHMDT ALL { int shmdt(void *shmaddr); } 411 | 265 AUE_SHMGET ALL { int shmget(key_t key, size_t size, int shmflg); } 412 | #else 413 | 262 AUE_NULL ALL { int nosys(void); } 414 | 263 AUE_NULL ALL { int nosys(void); } 415 | 264 AUE_NULL ALL { int nosys(void); } 416 | 265 AUE_NULL ALL { int nosys(void); } 417 | #endif 418 | 266 AUE_SHMOPEN ALL { int shm_open(const char *name, int oflag, int mode); } 419 | 267 AUE_SHMUNLINK ALL { int shm_unlink(const char *name); } 420 | 268 AUE_SEMOPEN ALL { user_addr_t sem_open(const char *name, int oflag, int mode, int value); } 421 | 269 AUE_SEMCLOSE ALL { int sem_close(sem_t *sem); } 422 | 270 AUE_SEMUNLINK ALL { int sem_unlink(const char *name); } 423 | 271 AUE_SEMWAIT ALL { int sem_wait(sem_t *sem); } 424 | 272 AUE_SEMTRYWAIT ALL { int sem_trywait(sem_t *sem); } 425 | 273 AUE_SEMPOST ALL { int sem_post(sem_t *sem); } 426 | 274 AUE_SEMGETVALUE ALL { int sem_getvalue(sem_t *sem, int *sval); } 427 | 275 AUE_SEMINIT ALL { int sem_init(sem_t *sem, int phsared, u_int value); } 428 | 276 AUE_SEMDESTROY ALL { int sem_destroy(sem_t *sem); } 429 | 277 AUE_OPEN_EXTENDED_RWTC ALL { int open_extended(user_addr_t path, int flags, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; } 430 | 278 AUE_UMASK_EXTENDED ALL { int umask_extended(int newmask, user_addr_t xsecurity) NO_SYSCALL_STUB; } 431 | 279 AUE_STAT_EXTENDED ALL { int stat_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 432 | 280 AUE_LSTAT_EXTENDED ALL { int lstat_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 433 | 281 AUE_FSTAT_EXTENDED ALL { int fstat_extended(int fd, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 434 | 282 AUE_CHMOD_EXTENDED ALL { int chmod_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; } 435 | 283 AUE_FCHMOD_EXTENDED ALL { int fchmod_extended(int fd, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; } 436 | 284 AUE_ACCESS_EXTENDED ALL { int access_extended(user_addr_t entries, size_t size, user_addr_t results, uid_t uid) NO_SYSCALL_STUB; } 437 | 285 AUE_SETTID ALL { int settid(uid_t uid, gid_t gid) NO_SYSCALL_STUB; } 438 | 286 AUE_GETTID ALL { int gettid(uid_t *uidp, gid_t *gidp) NO_SYSCALL_STUB; } 439 | 287 AUE_SETSGROUPS ALL { int setsgroups(int setlen, user_addr_t guidset) NO_SYSCALL_STUB; } 440 | 288 AUE_GETSGROUPS ALL { int getsgroups(user_addr_t setlen, user_addr_t guidset) NO_SYSCALL_STUB; } 441 | 289 AUE_SETWGROUPS ALL { int setwgroups(int setlen, user_addr_t guidset) NO_SYSCALL_STUB; } 442 | 290 AUE_GETWGROUPS ALL { int getwgroups(user_addr_t setlen, user_addr_t guidset) NO_SYSCALL_STUB; } 443 | 291 AUE_MKFIFO_EXTENDED ALL { int mkfifo_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; } 444 | 292 AUE_MKDIR_EXTENDED ALL { int mkdir_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; } 445 | 293 AUE_IDENTITYSVC ALL { int identitysvc(int opcode, user_addr_t message) NO_SYSCALL_STUB; } 446 | 294 AUE_NULL ALL { int shared_region_check_np(uint64_t *start_address) NO_SYSCALL_STUB; } 447 | 295 AUE_NULL ALL { int shared_region_map_np(int fd, uint32_t count, const struct shared_file_mapping_np *mappings) NO_SYSCALL_STUB; } 448 | 296 AUE_NULL ALL { int vm_pressure_monitor(int wait_for_pressure, int nsecs_monitored, uint32_t *pages_reclaimed); } 449 | #if PSYNCH 450 | 297 AUE_NULL ALL { uint32_t psynch_rw_longrdlock(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 451 | 298 AUE_NULL ALL { uint32_t psynch_rw_yieldwrlock(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 452 | 299 AUE_NULL ALL { int psynch_rw_downgrade(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 453 | 300 AUE_NULL ALL { uint32_t psynch_rw_upgrade(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 454 | 301 AUE_NULL ALL { uint32_t psynch_mutexwait(user_addr_t mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) NO_SYSCALL_STUB; } 455 | 302 AUE_NULL ALL { uint32_t psynch_mutexdrop(user_addr_t mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) NO_SYSCALL_STUB; } 456 | 303 AUE_NULL ALL { int psynch_cvbroad(user_addr_t cv, uint32_t cvgen, uint32_t diffgen, user_addr_t mutex, uint32_t mgen, uint32_t ugen, uint64_t tid, uint32_t flags) NO_SYSCALL_STUB; } 457 | 304 AUE_NULL ALL { int psynch_cvsignal(user_addr_t cv, uint32_t cvgen, uint32_t cvugen, user_addr_t mutex, uint32_t mgen, uint32_t ugen, int thread_port, uint32_t flags) NO_SYSCALL_STUB; } 458 | 305 AUE_NULL ALL { uint32_t psynch_cvwait(user_addr_t cv, uint32_t cvgen, uint32_t cvugen, user_addr_t mutex, uint32_t mgen, uint32_t ugen, uint64_t sec, uint64_t usec) NO_SYSCALL_STUB; } 459 | 306 AUE_NULL ALL { uint32_t psynch_rw_rdlock(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 460 | 307 AUE_NULL ALL { uint32_t psynch_rw_wrlock(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 461 | 308 AUE_NULL ALL { uint32_t psynch_rw_unlock(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 462 | 309 AUE_NULL ALL { uint32_t psynch_rw_unlock2(user_addr_t rwlock, uint32_t lgenval, uint32_t ugenval, uint32_t rw_wc, int flags) NO_SYSCALL_STUB; } 463 | #else 464 | 297 AUE_NULL ALL { int nosys(void); } { old reset_shared_file } 465 | 298 AUE_NULL ALL { int nosys(void); } { old new_system_shared_regions } 466 | 299 AUE_NULL ALL { int enosys(void); } { old shared_region_map_file_np } 467 | 300 AUE_NULL ALL { int enosys(void); } { old shared_region_make_private_np } 468 | 301 AUE_NULL ALL { int nosys(void); } 469 | 302 AUE_NULL ALL { int nosys(void); } 470 | 303 AUE_NULL ALL { int nosys(void); } 471 | 304 AUE_NULL ALL { int nosys(void); } 472 | 305 AUE_NULL ALL { int nosys(void); } 473 | 306 AUE_NULL ALL { int nosys(void); } 474 | 307 AUE_NULL ALL { int nosys(void); } 475 | 308 AUE_NULL ALL { int nosys(void); } 476 | 309 AUE_NULL ALL { int nosys(void); } 477 | #endif 478 | 310 AUE_GETSID ALL { int getsid(pid_t pid); } 479 | 311 AUE_SETTIDWITHPID ALL { int settid_with_pid(pid_t pid, int assume) NO_SYSCALL_STUB; } 480 | 312 AUE_NULL ALL { int nosys(void); } { old __pthread_cond_timedwait } 481 | 313 AUE_NULL ALL { int aio_fsync(int op, user_addr_t aiocbp); } 482 | 314 AUE_NULL ALL { user_ssize_t aio_return(user_addr_t aiocbp); } 483 | 315 AUE_NULL ALL { int aio_suspend(user_addr_t aiocblist, int nent, user_addr_t timeoutp); } 484 | 316 AUE_NULL ALL { int aio_cancel(int fd, user_addr_t aiocbp); } 485 | 317 AUE_NULL ALL { int aio_error(user_addr_t aiocbp); } 486 | 318 AUE_NULL ALL { int aio_read(user_addr_t aiocbp); } 487 | 319 AUE_NULL ALL { int aio_write(user_addr_t aiocbp); } 488 | 320 AUE_LIOLISTIO ALL { int lio_listio(int mode, user_addr_t aiocblist, int nent, user_addr_t sigp); } 489 | 321 AUE_NULL ALL { int nosys(void); } { old __pthread_cond_wait } 490 | 322 AUE_IOPOLICYSYS ALL { int iopolicysys(int cmd, void *arg) NO_SYSCALL_STUB; } 491 | 323 AUE_NULL ALL { int nosys(void); } 492 | 324 AUE_MLOCKALL ALL { int mlockall(int how); } 493 | 325 AUE_MUNLOCKALL ALL { int munlockall(int how); } 494 | 326 AUE_NULL ALL { int nosys(void); } 495 | 327 AUE_ISSETUGID ALL { int issetugid(void); } 496 | 328 AUE_PTHREADKILL ALL { int __pthread_kill(int thread_port, int sig); } 497 | 329 AUE_PTHREADSIGMASK ALL { int __pthread_sigmask(int how, user_addr_t set, user_addr_t oset); } 498 | 330 AUE_SIGWAIT ALL { int __sigwait(user_addr_t set, user_addr_t sig); } 499 | 331 AUE_NULL ALL { int __disable_threadsignal(int value); } 500 | 332 AUE_NULL ALL { int __pthread_markcancel(int thread_port); } 501 | 333 AUE_NULL ALL { int __pthread_canceled(int action); } 502 | 503 | ;#if OLD_SEMWAIT_SIGNAL 504 | ;334 AUE_NULL ALL { int nosys(void); } { old __semwait_signal } 505 | ;#else 506 | 334 AUE_SEMWAITSIGNAL ALL { int __semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, int64_t tv_sec, int32_t tv_nsec); } 507 | ;#endif 508 | 509 | 335 AUE_NULL ALL { int nosys(void); } { old utrace } 510 | 336 AUE_PROCINFO ALL { int proc_info(int32_t callnum,int32_t pid,uint32_t flavor, uint64_t arg,user_addr_t buffer,int32_t buffersize) NO_SYSCALL_STUB; } 511 | #if SENDFILE 512 | 337 AUE_SENDFILE ALL { int sendfile(int fd, int s, off_t offset, off_t *nbytes, struct sf_hdtr *hdtr, int flags); } 513 | #else /* !SENDFILE */ 514 | 337 AUE_NULL ALL { int nosys(void); } 515 | #endif /* SENDFILE */ 516 | 338 AUE_STAT64 ALL { int stat64(user_addr_t path, user_addr_t ub); } 517 | 339 AUE_FSTAT64 ALL { int fstat64(int fd, user_addr_t ub); } 518 | 340 AUE_LSTAT64 ALL { int lstat64(user_addr_t path, user_addr_t ub); } 519 | 341 AUE_STAT64_EXTENDED ALL { int stat64_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 520 | 342 AUE_LSTAT64_EXTENDED ALL { int lstat64_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 521 | 343 AUE_FSTAT64_EXTENDED ALL { int fstat64_extended(int fd, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; } 522 | 344 AUE_GETDIRENTRIES64 ALL { user_ssize_t getdirentries64(int fd, void *buf, user_size_t bufsize, off_t *position) NO_SYSCALL_STUB; } 523 | 345 AUE_STATFS64 ALL { int statfs64(char *path, struct statfs64 *buf); } 524 | 346 AUE_FSTATFS64 ALL { int fstatfs64(int fd, struct statfs64 *buf); } 525 | 347 AUE_GETFSSTAT64 ALL { int getfsstat64(user_addr_t buf, int bufsize, int flags); } 526 | 348 AUE_NULL ALL { int __pthread_chdir(user_addr_t path); } 527 | 349 AUE_NULL ALL { int __pthread_fchdir(int fd); } 528 | 350 AUE_AUDIT ALL { int audit(void *record, int length); } 529 | 351 AUE_AUDITON ALL { int auditon(int cmd, void *data, int length); } 530 | 352 AUE_NULL ALL { int nosys(void); } 531 | 353 AUE_GETAUID ALL { int getauid(au_id_t *auid); } 532 | 354 AUE_SETAUID ALL { int setauid(au_id_t *auid); } 533 | 355 AUE_GETAUDIT ALL { int getaudit(struct auditinfo *auditinfo); } 534 | 356 AUE_SETAUDIT ALL { int setaudit(struct auditinfo *auditinfo); } 535 | 357 AUE_GETAUDIT_ADDR ALL { int getaudit_addr(struct auditinfo_addr *auditinfo_addr, int length); } 536 | 358 AUE_SETAUDIT_ADDR ALL { int setaudit_addr(struct auditinfo_addr *auditinfo_addr, int length); } 537 | 359 AUE_AUDITCTL ALL { int auditctl(char *path); } 538 | #if CONFIG_WORKQUEUE 539 | 360 AUE_NULL ALL { user_addr_t bsdthread_create(user_addr_t func, user_addr_t func_arg, user_addr_t stack, user_addr_t pthread, uint32_t flags) NO_SYSCALL_STUB; } 540 | 361 AUE_NULL ALL { int bsdthread_terminate(user_addr_t stackaddr, size_t freesize, uint32_t port, uint32_t sem) NO_SYSCALL_STUB; } 541 | #else 542 | 360 AUE_NULL ALL { int nosys(void); } 543 | 361 AUE_NULL ALL { int nosys(void); } 544 | #endif /* CONFIG_WORKQUEUE */ 545 | 362 AUE_KQUEUE ALL { int kqueue(void); } 546 | 363 AUE_NULL ALL { int kevent(int fd, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); } 547 | 364 AUE_LCHOWN ALL { int lchown(user_addr_t path, uid_t owner, gid_t group); } 548 | 365 AUE_STACKSNAPSHOT ALL { int stack_snapshot(pid_t pid, user_addr_t tracebuf, uint32_t tracebuf_size, uint32_t options) NO_SYSCALL_STUB; } 549 | #if CONFIG_WORKQUEUE 550 | 366 AUE_NULL ALL { int bsdthread_register(user_addr_t threadstart, user_addr_t wqthread, int pthsize,user_addr_t dummy_value, user_addr_t targetconc_ptr, uint64_t dispatchqueue_offset) NO_SYSCALL_STUB; } 551 | 367 AUE_WORKQOPEN ALL { int workq_open(void) NO_SYSCALL_STUB; } 552 | 368 AUE_WORKQOPS ALL { int workq_kernreturn(int options, user_addr_t item, int affinity, int prio) NO_SYSCALL_STUB; } 553 | #else 554 | 366 AUE_NULL ALL { int nosys(void); } 555 | 367 AUE_NULL ALL { int nosys(void); } 556 | 368 AUE_NULL ALL { int nosys(void); } 557 | #endif /* CONFIG_WORKQUEUE */ 558 | 369 AUE_NULL ALL { int kevent64(int fd, const struct kevent64_s *changelist, int nchanges, struct kevent64_s *eventlist, int nevents, unsigned int flags, const struct timespec *timeout); } 559 | #if OLD_SEMWAIT_SIGNAL 560 | 370 AUE_SEMWAITSIGNAL ALL { int __old_semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, const struct timespec *ts); } 561 | 371 AUE_SEMWAITSIGNAL ALL { int __old_semwait_signal_nocancel(int cond_sem, int mutex_sem, int timeout, int relative, const struct timespec *ts) NO_SYSCALL_STUB; } 562 | #else 563 | 370 AUE_NULL ALL { int nosys(void); } { old __semwait_signal } 564 | 371 AUE_NULL ALL { int nosys(void); } { old __semwait_signal } 565 | #endif 566 | 372 AUE_NULL ALL { user_addr_t thread_selfid (void) NO_SYSCALL_STUB; } 567 | 373 AUE_NULL ALL { int nosys(void); } 568 | 374 AUE_NULL ALL { int nosys(void); } 569 | 375 AUE_NULL ALL { int nosys(void); } 570 | 376 AUE_NULL ALL { int nosys(void); } 571 | 377 AUE_NULL ALL { int nosys(void); } 572 | 378 AUE_NULL ALL { int nosys(void); } 573 | 379 AUE_NULL ALL { int nosys(void); } 574 | 380 AUE_MAC_EXECVE ALL { int __mac_execve(char *fname, char **argp, char **envp, struct mac *mac_p); } 575 | 381 AUE_MAC_SYSCALL ALL { int __mac_syscall(char *policy, int call, user_addr_t arg); } 576 | 382 AUE_MAC_GET_FILE ALL { int __mac_get_file(char *path_p, struct mac *mac_p); } 577 | 383 AUE_MAC_SET_FILE ALL { int __mac_set_file(char *path_p, struct mac *mac_p); } 578 | 384 AUE_MAC_GET_LINK ALL { int __mac_get_link(char *path_p, struct mac *mac_p); } 579 | 385 AUE_MAC_SET_LINK ALL { int __mac_set_link(char *path_p, struct mac *mac_p); } 580 | 386 AUE_MAC_GET_PROC ALL { int __mac_get_proc(struct mac *mac_p); } 581 | 387 AUE_MAC_SET_PROC ALL { int __mac_set_proc(struct mac *mac_p); } 582 | 388 AUE_MAC_GET_FD ALL { int __mac_get_fd(int fd, struct mac *mac_p); } 583 | 389 AUE_MAC_SET_FD ALL { int __mac_set_fd(int fd, struct mac *mac_p); } 584 | 390 AUE_MAC_GET_PID ALL { int __mac_get_pid(pid_t pid, struct mac *mac_p); } 585 | 391 AUE_MAC_GET_LCID ALL { int __mac_get_lcid(pid_t lcid, struct mac *mac_p); } 586 | 392 AUE_MAC_GET_LCTX ALL { int __mac_get_lctx(struct mac *mac_p); } 587 | 393 AUE_MAC_SET_LCTX ALL { int __mac_set_lctx(struct mac *mac_p); } 588 | 394 AUE_SETLCID ALL { int setlcid(pid_t pid, pid_t lcid) NO_SYSCALL_STUB; } 589 | 395 AUE_GETLCID ALL { int getlcid(pid_t pid) NO_SYSCALL_STUB; } 590 | 396 AUE_NULL ALL { user_ssize_t read_nocancel(int fd, user_addr_t cbuf, user_size_t nbyte) NO_SYSCALL_STUB; } 591 | 397 AUE_NULL ALL { user_ssize_t write_nocancel(int fd, user_addr_t cbuf, user_size_t nbyte) NO_SYSCALL_STUB; } 592 | 398 AUE_OPEN_RWTC ALL { int open_nocancel(user_addr_t path, int flags, int mode) NO_SYSCALL_STUB; } 593 | 399 AUE_CLOSE ALL { int close_nocancel(int fd) NO_SYSCALL_STUB; } 594 | 400 AUE_WAIT4 ALL { int wait4_nocancel(int pid, user_addr_t status, int options, user_addr_t rusage) NO_SYSCALL_STUB; } 595 | #if SOCKETS 596 | 401 AUE_RECVMSG ALL { int recvmsg_nocancel(int s, struct msghdr *msg, int flags) NO_SYSCALL_STUB; } 597 | 402 AUE_SENDMSG ALL { int sendmsg_nocancel(int s, caddr_t msg, int flags) NO_SYSCALL_STUB; } 598 | 403 AUE_RECVFROM ALL { int recvfrom_nocancel(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlenaddr) NO_SYSCALL_STUB; } 599 | 404 AUE_ACCEPT ALL { int accept_nocancel(int s, caddr_t name, socklen_t *anamelen) NO_SYSCALL_STUB; } 600 | #else 601 | 401 AUE_NULL ALL { int nosys(void); } 602 | 402 AUE_NULL ALL { int nosys(void); } 603 | 403 AUE_NULL ALL { int nosys(void); } 604 | 404 AUE_NULL ALL { int nosys(void); } 605 | #endif /* SOCKETS */ 606 | 405 AUE_MSYNC ALL { int msync_nocancel(caddr_t addr, size_t len, int flags) NO_SYSCALL_STUB; } 607 | 406 AUE_FCNTL ALL { int fcntl_nocancel(int fd, int cmd, long arg) NO_SYSCALL_STUB; } 608 | 407 AUE_SELECT ALL { int select_nocancel(int nd, u_int32_t *in, u_int32_t *ou, u_int32_t *ex, struct timeval *tv) NO_SYSCALL_STUB; } 609 | 408 AUE_FSYNC ALL { int fsync_nocancel(int fd) NO_SYSCALL_STUB; } 610 | #if SOCKETS 611 | 409 AUE_CONNECT ALL { int connect_nocancel(int s, caddr_t name, socklen_t namelen) NO_SYSCALL_STUB; } 612 | #else 613 | 409 AUE_NULL ALL { int nosys(void); } 614 | #endif /* SOCKETS */ 615 | 410 AUE_NULL ALL { int sigsuspend_nocancel(sigset_t mask) NO_SYSCALL_STUB; } 616 | 411 AUE_READV ALL { user_ssize_t readv_nocancel(int fd, struct iovec *iovp, u_int iovcnt) NO_SYSCALL_STUB; } 617 | 412 AUE_WRITEV ALL { user_ssize_t writev_nocancel(int fd, struct iovec *iovp, u_int iovcnt) NO_SYSCALL_STUB; } 618 | #if SOCKETS 619 | 413 AUE_SENDTO ALL { int sendto_nocancel(int s, caddr_t buf, size_t len, int flags, caddr_t to, socklen_t tolen) NO_SYSCALL_STUB; } 620 | #else 621 | 413 AUE_NULL ALL { int nosys(void); } 622 | #endif /* SOCKETS */ 623 | 414 AUE_PREAD ALL { user_ssize_t pread_nocancel(int fd, user_addr_t buf, user_size_t nbyte, off_t offset) NO_SYSCALL_STUB; } 624 | 415 AUE_PWRITE ALL { user_ssize_t pwrite_nocancel(int fd, user_addr_t buf, user_size_t nbyte, off_t offset) NO_SYSCALL_STUB; } 625 | 416 AUE_WAITID ALL { int waitid_nocancel(idtype_t idtype, id_t id, siginfo_t *infop, int options) NO_SYSCALL_STUB; } 626 | 417 AUE_POLL ALL { int poll_nocancel(struct pollfd *fds, u_int nfds, int timeout) NO_SYSCALL_STUB; } 627 | #if SYSV_MSG 628 | 418 AUE_MSGSND ALL { int msgsnd_nocancel(int msqid, void *msgp, size_t msgsz, int msgflg) NO_SYSCALL_STUB; } 629 | 419 AUE_MSGRCV ALL { user_ssize_t msgrcv_nocancel(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) NO_SYSCALL_STUB; } 630 | #else 631 | 418 AUE_NULL ALL { int nosys(void); } 632 | 419 AUE_NULL ALL { int nosys(void); } 633 | #endif 634 | 420 AUE_SEMWAIT ALL { int sem_wait_nocancel(sem_t *sem) NO_SYSCALL_STUB; } 635 | 421 AUE_NULL ALL { int aio_suspend_nocancel(user_addr_t aiocblist, int nent, user_addr_t timeoutp) NO_SYSCALL_STUB; } 636 | 422 AUE_SIGWAIT ALL { int __sigwait_nocancel(user_addr_t set, user_addr_t sig) NO_SYSCALL_STUB; } 637 | ;#if OLD_SEMWAIT_SIGNAL 638 | ;423 AUE_NULL ALL { int nosys(void); } { old __semwait_signal_nocancel } 639 | ;#else 640 | 423 AUE_SEMWAITSIGNAL ALL { int __semwait_signal_nocancel(int cond_sem, int mutex_sem, int timeout, int relative, int64_t tv_sec, int32_t tv_nsec) NO_SYSCALL_STUB;} 641 | ;#endif 642 | 424 AUE_MAC_MOUNT ALL { int __mac_mount(char *type, char *path, int flags, caddr_t data, struct mac *mac_p); } 643 | 425 AUE_MAC_GET_MOUNT ALL { int __mac_get_mount(char *path, struct mac *mac_p); } 644 | 426 AUE_MAC_GETFSSTAT ALL { int __mac_getfsstat(user_addr_t buf, int bufsize, user_addr_t mac, int macsize, int flags); } 645 | 427 AUE_FSGETPATH ALL { user_ssize_t fsgetpath(user_addr_t buf, size_t bufsize, user_addr_t fsid, uint64_t objid) NO_SYSCALL_STUB; } { private fsgetpath (File Manager SPI) } 646 | 428 AUE_NULL ALL { mach_port_name_t audit_session_self(void); } 647 | 429 AUE_NULL ALL { int audit_session_join(mach_port_name_t port); } 648 | -------------------------------------------------------------------------------- /grapevine/res/tkintertest.py: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/Python 2 | """Displays the keysym for each KeyPress event as you type.""" 3 | import Tkinter 4 | 5 | root = Tkinter.Tk() 6 | root.title("Keysym Logger") 7 | 8 | def reportEvent(event): 9 | print 'keysym=%s, keysym_num=%s' % (event.keysym, event.keysym_num) 10 | 11 | text = Tkinter.Text(root, width=20, height=5, highlightthickness=2) 12 | 13 | text.bind('', reportEvent) 14 | 15 | text.pack(expand=1, fill="both") 16 | text.focus_set() 17 | root.mainloop() 18 | -------------------------------------------------------------------------------- /grapevine/res/xnufuzz.py: -------------------------------------------------------------------------------- 1 | from ctypes import * 2 | import random 3 | import binascii 4 | from time import sleep 5 | libc = cdll.LoadLibrary("libc.dylib") 6 | 7 | 8 | #This ignore list is customized for xnu-1486.2.11 (10.6.2). 9 | 10 | ignore = [ 11 | 8, 11, 17, 19, 21, 22, 38, 40, 45, 62, 63, 64, 67, 12 | 68, 69, 70, 71, 72, 77, 84, 87, 88, 91, 94, 99, 101, 13 | 102, 103, 107, 108, 109, 110, 112, 113, 114, 115, 119, 125, 129, 130, 14 | 141, 143, 144, 145, 146, 148, 149, 150, 156, 160, 162, 15 | 163, 164, 166, 168, 170, 171, 172, 174, 175, 177, 178, 16 | 179, 186, 193, 198, 213, 214, 215, 224, 246, 249, 257, 17 | 312, 321, 323, 326, 335, 352, 373, 374, 375, 376, 377, 18 | 378, 379 19 | ] 20 | 21 | def getseed(): 22 | return int(binascii.hexlify(open("/dev/urandom", 'r').read(5).rstrip()),16) 23 | 24 | def getrand(): 25 | f = open('/dev/urandom', 'r') 26 | d = f.read(128).rstrip() 27 | f.close() 28 | return d 29 | 30 | def getnumber(): 31 | state = random.randrange(0,5) 32 | #case statement goes here, lol python doesnt have switch 33 | if state == 0: 34 | random.seed(1) 35 | return random.randrange(2147483647) 36 | elif state == 1: 37 | random.seed(1) 38 | return (0xffffff00 | (random.randrange(2147483647) % 256)) #C-like random 39 | elif state == 2: 40 | return 0x8000 41 | elif state == 3: 42 | return 0xffff 43 | elif state == 4: 44 | return 0x80000000 45 | 46 | def getarg(): 47 | state = random.randrange(0,5) 48 | b = '' 49 | if state == 0: 50 | return 0x0804fd00 #userland addr 51 | elif state == 1: 52 | return 0x0000a000 #unmapped addr 53 | elif state == 2: 54 | return 0xc01fa0b6 #kernel addr, a guess 55 | elif state == 3: 56 | return getnumber() #some number 57 | elif state == 4: 58 | return getrand() 59 | 60 | def memfuzz(): 61 | arg = [] 62 | syscallnr = 0 63 | flag = 1 64 | while True: 65 | flag = 1 66 | while not flag == 0: 67 | flag = 0 68 | random.seed(getseed()) 69 | syscallnr = (random.randrange(2147483647) % 253) 70 | for i in ignore: 71 | if(i == syscallnr): 72 | flag = 1 73 | break 74 | 75 | for i in range(0,8): 76 | arg.append(getarg()) 77 | 78 | print('syscall({}, {}, {}, {}, {}, {}, {}, {}, {})\n').format(syscallnr, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]) 79 | sleep(5/1000000.0) 80 | returnVal = libc.syscall(syscallnr, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]) 81 | print "return: ", returnVal 82 | 83 | if __name__ == "__main__": 84 | memfuzz() 85 | -------------------------------------------------------------------------------- /grapevine/src/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/common/__init__.py -------------------------------------------------------------------------------- /grapevine/src/common/fuzzgenerator/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/common/fuzzgenerator/__init__.py -------------------------------------------------------------------------------- /grapevine/src/common/fuzzgenerator/gvgenerator.py: -------------------------------------------------------------------------------- 1 | #!/bin/usr/python 2 | 3 | # Template abstract class Generator 4 | # MUST BE SUBCLASSED to implement a generator. 5 | # All functions should be overriden and implemented. 6 | class Generator: 7 | profile = None 8 | state = None 9 | seed = None 10 | 11 | # Initialise the class with a seed value to kick start the generator. 12 | def __init__(self, profile, seed): 13 | self.profile 14 | self.seed = seed 15 | 16 | # Call getNext() to obtain the next set of inputs. 17 | # Should always return a list of values (Data should be expected by the syscall 18 | # calling mechanism). 19 | def getNext(self): 20 | raise Exception("Unimplemented getNext() in template Generator class.") 21 | 22 | # Call this function with a list of return values after fuzz input is run 23 | # to affect the state of the Generator in order to dynamically generate 24 | # input based on complex rules. 25 | # data is always a list of values. 26 | def affectState(self, data): 27 | raise Exception("Unimplemented affectState() in template Generator class.") 28 | 29 | 30 | # Default generator 31 | class DefaultGenerator(Generator): 32 | 33 | state = 0 34 | 35 | def getNext(self): 36 | return [0, 1, 2, 3, 4, 5, 6, 7, 8] 37 | 38 | def affectState(self, data): 39 | self.state = self.state + 1 40 | print "Generator got %s back. (State %d)" % (data, self.state) 41 | 42 | 43 | # Syscall Profile Use Generator 44 | class XNUIntellect(Generator): 45 | """A generator designed to make use of syscall list parsing and intelligent filtering of unusable syscalls and their orders.""" 46 | def getNext(self): 47 | pass 48 | 49 | def affectState(self, data): 50 | pass 51 | 52 | 53 | import random 54 | import binascii 55 | class RandomFI(Generator): 56 | profile = None 57 | state = None 58 | seed = None 59 | 60 | def __init__(self, profile, seed): 61 | self.state = 0 62 | pass 63 | 64 | def getNext(self): 65 | args = [] 66 | args.append(self.__getsyscall()) 67 | for _ in range(0,8): 68 | args.append(self.__getarg()) 69 | return args 70 | 71 | def affectState(self, data): 72 | self.state = self.state + 1 73 | print "Generator got %s back. (State %d)" % (data, self.state) 74 | 75 | def __getsyscall(self): 76 | ignore = [8, 11, 17, 19, 21, 22, 38, 40, 45, 62, 63, 64, 67, 77 | 68, 69, 70, 71, 72, 76, 77, 84, 87, 88, 91, 94, 99, 78 | 101, 102, 103, 107, 108, 109, 110, 112, 113, 114, 79 | 115, 119, 125, 129, 130, 141, 143, 144, 145, 146, 80 | 148, 149, 150, 156, 160, 162, 163, 164, 166, 168, 81 | 170, 171, 172, 174, 175, 177, 178, 179, 186, 193, 82 | 198, 213, 214, 215, 216, 217, 218, 219, 224, 246, 83 | 249, 257, 312, 321, 323, 326, 335, 352, 373, 374, 84 | 375, 376, 377, 378, 379, 401, 402, 403, 404, 409, 85 | 413, 418, 419, 423, 432, 433, 86 | 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, 87 | -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, 88 | -30, -40, -41, -42, -47, -50, -54, -55, -56, -57, -63, -64, 89 | -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, 90 | -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, 91 | -95, -96, -97, -98, -99, -100] 92 | 93 | while True: 94 | random.seed(self.__getseed()) 95 | temp_sys = random.randint(-100, 433) 96 | if temp_sys not in ignore: 97 | return temp_sys 98 | 99 | def __getseed(self): 100 | return int(binascii.hexlify(open("/dev/urandom", "r").read(5).rstrip()),16) 101 | 102 | def __getrand(self): 103 | random_file = open('/dev/urandom', 'r') 104 | data = random_file.read(128).rstrip() 105 | random_file.close() 106 | return data 107 | 108 | def __getnumber(self): 109 | state = random.randrange(0,5) 110 | if state == 0: 111 | random.seed(1) 112 | return random.randrange(2147483647) 113 | elif state == 1: 114 | random.seed(1) 115 | # C-like random 116 | return (0xffffff00 | (random.randrange(2147483647) % 256)) 117 | elif state == 2: 118 | return 0x8000 119 | elif state == 3: 120 | return 0xffff 121 | elif state == 4: 122 | return 0x80000000 123 | 124 | def __getarg(self): 125 | state = random.randrange(0,5) 126 | if state == 0: 127 | return 0x0804fd00 #userland addr 128 | elif state == 1: 129 | return 0x0000a000 #unmapped addr 130 | elif state == 2: 131 | return 0xc01fa0b6 #kernel addr, a guess 132 | elif state == 3: 133 | return self.__getnumber() #some number 134 | elif state == 4: 135 | return self.__getrand() 136 | -------------------------------------------------------------------------------- /grapevine/src/common/fuzzprofile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/common/fuzzprofile/__init__.py -------------------------------------------------------------------------------- /grapevine/src/common/fuzzprofile/gvparser.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from gvsyscalls import * 4 | import re 5 | 6 | class GrapevineParser: 7 | 8 | def parse(self, bsd_file, mach_file): 9 | bsd_syscalls = self.parse_bsdsyscalls(bsd_file) 10 | mach_syscalls = self.parse_machsyscalls(mach_file) 11 | new_profile = SyscallProfile(bsd_syscalls, mach_syscalls) 12 | return new_profile 13 | 14 | def parse_bsdsyscalls(self, filename): 15 | syscall_collection = BSDSyscallsCollection() 16 | parse_strings = [i.strip() for i in file(filename).read().splitlines()] 17 | syscall_pattern = re.compile(r"(\d+)\s+(\w+)\s+(ALL|[TNHP]{1,4}|UALL|UHN)\s+{\s+(\w+)\s+(\w+)\((.+)\)(?:\s+(NO_SYSCALL_STUB)\s*)?;\s+}(?:\s+{\s+(.+)\s+})?") 18 | option_patterns= {"if": re.compile(r"#if (\w+)"), 19 | "else": re.compile(r"#else.*"), 20 | "endif": re.compile(r"#endif.*")} 21 | current_branch = "default" 22 | current_else = False 23 | 24 | for i in parse_strings: 25 | syscalldef_match = syscall_pattern.match(i) 26 | 27 | option_match = None 28 | option_index = "" 29 | for p in option_patterns.keys(): 30 | option_match = option_patterns[p].match(i) 31 | if option_match: 32 | option_index = p 33 | 34 | if option_index == "if": 35 | current_branch = option_match.group(1) 36 | elif option_index == "else": 37 | current_else = True 38 | elif option_index == "endif": 39 | current_branch = "default" 40 | current_else = False 41 | elif syscalldef_match: 42 | number = syscalldef_match.group(1) 43 | audit_event = syscalldef_match.group(2) 44 | in_files = syscalldef_match.group(3) 45 | comments = syscalldef_match.group(8) or "No comments" 46 | 47 | # Construct the function prototype object 48 | func_rettype = syscalldef_match.group(4) 49 | func_name = syscalldef_match.group(5) 50 | syscall_stub = (True if syscalldef_match.group(7) == "NO_SYSCALL_STUB" or func_name[0:2] == "__" else False) 51 | function_prototype = BSDSyscallFunctionPrototype(func_rettype, func_name, syscall_stub) 52 | argument_pattern = re.compile("(.+)\s+(.+)") 53 | if not syscalldef_match.group(6) == "void": 54 | for j in [k.strip() for k in syscalldef_match.group(6).split(",")]: 55 | arg_split = argument_pattern.match(j) 56 | function_prototype.add_argument(arg_split.group(1), arg_split.group(2)) 57 | 58 | # Adding the syscall to the collection 59 | new_bsdsyscall = BSDSyscall(function_prototype, number, audit_event, in_files, comments) 60 | syscall_collection.add_syscall(new_bsdsyscall, current_branch, current_else) 61 | 62 | return syscall_collection 63 | 64 | def parse_machsyscalls(self, filename): 65 | syscall_collection = MachSyscallsCollection() 66 | parse_strings = [i.strip() for i in file(filename).read().splitlines()] 67 | syscall_pattern = re.compile(r"/\* (\d+) \*/\s+MACH_TRAP\((\w+), (\d+), (\w+), (\w+)\),") 68 | 69 | for i in parse_strings: 70 | syscalldef_match = syscall_pattern.match(i) 71 | 72 | if syscalldef_match: 73 | number = syscalldef_match.group(1) 74 | name = syscalldef_match.group(2) 75 | arg_count = syscalldef_match.group(3) 76 | munge_w = syscalldef_match.group(4) 77 | munge_d = syscalldef_match.group(5) 78 | 79 | new_machsyscall = MachSyscall(int(number), name, int(arg_count), munge_w, munge_d) 80 | syscall_collection.add_syscall(new_machsyscall) 81 | 82 | return syscall_collection 83 | 84 | if __name__ == "__main__": 85 | g = GrapevineParser() 86 | a = g.parse_bsdsyscalls("../../../res/syscalls.master") 87 | b = g.parse_machsyscalls("../../../res/syscall_sw.c") 88 | print a.syscall_tree['default'] 89 | print b.syscalls 90 | -------------------------------------------------------------------------------- /grapevine/src/common/fuzzprofile/gvsyscalls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Syscall Base Class # 4 | 5 | class Syscall: 6 | pass 7 | 8 | 9 | # BSD Syscalls # 10 | 11 | class BSDSyscall(Syscall): 12 | number = None # int, BSD Syscalls will never be less than 0. 13 | audit_event = None # string 14 | in_files = None # list 15 | function_prototype = None # BSDSyscallFunctionPrototype 16 | comments = None # string 17 | 18 | def __init__(self, function_prototype, number = -1, audit_event = "AUE_NULL", in_files = [], comments = ""): 19 | self.number = int(number) 20 | self.audit_event = audit_event 21 | self.in_files = in_files 22 | self.comments = comments 23 | self.function_prototype = function_prototype 24 | 25 | def __str__(self): 26 | return "%-10d %-15s %-15s {%s} {%s}" % (self.number, self.audit_event, self.in_files, self.function_prototype.__str__(), self.comments) 27 | 28 | def __repr__(self): 29 | return "" % (self.number, self.function_prototype.function_name) 30 | 31 | class BSDSyscallFunctionPrototype: 32 | return_type = None # string 33 | function_name = None # string 34 | arguments = None # list of paired tuples 35 | nosyscall_stub = None # boolean 36 | 37 | def __init__(self, return_type, function_name, nosyscall_stub = False): 38 | self.return_type = return_type 39 | self.function_name = function_name 40 | self.arguments = [] 41 | self.nosyscall_stub = nosyscall_stub 42 | 43 | def add_argument(self, data_type, name): 44 | self.arguments.append((data_type, name)) 45 | 46 | def __str__(self): 47 | function_list = "".join("%s %s, " % (i,v) for i, v in self.arguments)[0:-2] 48 | return "%s %s(%s)%s;" % (self.return_type, self.function_name, (function_list if not function_list == "" else "void"), (" NO_SYSCALL_STUB" if self.nosyscall_stub else "")) 49 | 50 | def __repr__(self): 51 | return self.__str__() 52 | 53 | class BSDSyscallsCollection: 54 | syscall_tree = {"default": []} 55 | 56 | def add_syscall(self, syscall, branch_name="default", else_branch=False): 57 | if branch_name == "default": 58 | if else_branch: 59 | return False # The default branch can never contain an else branch 60 | self.syscall_tree["default"].append(syscall) 61 | return True 62 | 63 | if branch_name not in self.syscall_tree: 64 | self.syscall_tree[branch_name] = {"default": [], "else": []} 65 | 66 | if else_branch: 67 | self.syscall_tree[branch_name]["else"].append(syscall) 68 | return True 69 | 70 | self.syscall_tree[branch_name]["default"].append(syscall) 71 | return True 72 | 73 | # Mach Syscalls # 74 | 75 | class MachSyscall(Syscall): 76 | number = None 77 | name = None 78 | arg_count = None 79 | munge_w = None # No idea what 80 | munge_d = None # these are at this point of time. 81 | 82 | def __init__(self, number, name, arg_count = 0, munge_w = "NULL", munge_d = "NULL"): 83 | self.number = number 84 | self.name = name 85 | self.arg_count = arg_count 86 | self.munge_w = munge_w 87 | self.munge_d = munge_d 88 | 89 | def __str__(self): 90 | return "/* %d */ MACH_TRAP(%s, %d, %s, %s)" % (self.number, self.name, self.arg_count, self.munge_w, self.munge_d) 91 | 92 | def __repr__(self): 93 | return "" % (self.number, self.name) 94 | 95 | class MachSyscallsCollection: 96 | syscalls = [] 97 | 98 | def add_syscall(self, syscall): 99 | if syscall not in self.syscalls: 100 | self.syscalls.append(syscall) 101 | return True 102 | else: 103 | return False 104 | 105 | # Syscall Profile # 106 | 107 | class SyscallProfile: 108 | bsd_syscalls = None 109 | mach_syscalls = None 110 | 111 | def __init__(self, bsd_syscalls, mach_syscalls): 112 | self.bsd_syscalls = bsd_syscalls 113 | self.mach_syscalls = mach_syscalls 114 | 115 | -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/fuzzd/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/gfuzzd/fuzzd/__init__.py -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/fuzzd/gvcallingmechanisms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Calling Mechanisms 4 | 5 | # Abstract class, needs to be implemented. 6 | class CallingMechanism: 7 | 8 | def call(self, syscall_number, *args): 9 | raise Exception("Unimplemented call() in abstract CallingMechanism class.") 10 | 11 | # Calling mechanism used for this project 12 | # UNCOMMENT OUT THE FOLLOWING LINES TO RUN IN A MAC OS X ENVIRONMENT 13 | # from ctypes import * 14 | # libc = cdll.LoadLibrary("libc.dylib") 15 | class XNUCallingMechanism(CallingMechanism): 16 | 17 | def call(self, syscall_number, *args): 18 | """Takes in a syscall number and a list or tuple of arguments""" 19 | returnVal = libc.syscall(syscall_number, *args) 20 | return returnVal 21 | 22 | # Calling mechanism to test input handling. 23 | class TestCallingMechanism(CallingMechanism): 24 | 25 | def call(self, syscall_number, *args): 26 | print "We called syscall %s with arguments: %s" % (syscall_number, args) 27 | returnVal = syscall_number 28 | return returnVal 29 | -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/fuzzd/gvfuzz.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import socket 4 | import sys 5 | from common.fuzzgenerator.gvgenerator import DefaultGenerator 6 | from threading import Thread 7 | import signal 8 | import time 9 | 10 | # Main entry class 11 | class FuzzD: 12 | udp_ip = "0.0.0.0" #Listens on all addresses 13 | udp_port = 10001 14 | logger = None 15 | call_mech = None 16 | sock = None 17 | generator = None 18 | generator_namespace = {} 19 | syscalls_profile = None 20 | fuzzing = False 21 | fuzz_thread = None 22 | 23 | def __init__(self, logger, call_mech, syscalls_profile, udp_ip="0.0.0.0", udp_port=10001): 24 | self.logger = logger 25 | self.call_mech = call_mech 26 | self.generator = DefaultGenerator(syscalls_profile, 0) 27 | self.udp_ip = udp_ip 28 | self.udp_port = udp_port 29 | 30 | # Set up the signals 31 | signal.signal(signal.SIGSEGV, self.__sig_handler) 32 | signal.signal(signal.SIGILL, self.__sig_handler) 33 | signal.signal(signal.SIGSYS, self.__sig_handler) 34 | signal.signal(signal.SIGINT, self.__interrupt_handler) 35 | 36 | def listen(self): 37 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 38 | self.sock.bind((self.udp_ip, self.udp_port)) 39 | print "Socket binding success. Listening on %d." % self.udp_port 40 | while True: 41 | data, addr = self.sock.recvfrom(1024) # buffer 1024 42 | self.__handle(data, addr) 43 | 44 | def __fuzz(self): 45 | """Begin the fuzzing process with the specified generator inputs called by the calling mechanism.""" 46 | while self.fuzzing: 47 | gin = self.generator.getNext() 48 | self.logger.log_syscall(gin[0], *gin[1:]) 49 | gout = self.call_mech.call(gin[0], *gin[1:]) 50 | self.logger.log_return(gout) 51 | self.generator.affectState(gout) 52 | 53 | 54 | def __sendback(self, msg, addr): 55 | self.sock.sendto(msg, addr) 56 | 57 | def __handle(self, data, addr): 58 | """Protocol handling.""" 59 | data = data.lower().strip() 60 | self.logger.log_command(data, addr) 61 | print "Received data from host control: %s" % data 62 | if data == "loadgen": 63 | gen_name, _ = self.sock.recvfrom(2048) 64 | seed, _ = self.sock.recvfrom(2048) 65 | exe_code, _ = self.sock.recvfrom(1024*10) 66 | exec exe_code in self.generator_namespace # load dynamic code into temp namespace 67 | self.generator = self.generator_namespace[gen_name](seed, self.syscalls_profile) 68 | self.logger.log_data('loadgen_params', 69 | addr, 70 | gen_name = gen_name, 71 | seed = seed, 72 | exe_code = exe_code) 73 | self.__sendback("generator %s loaded" % gen_name, addr) 74 | elif data == "hello": 75 | self.__sendback("hello from %s" % self, addr) 76 | elif data == "bye": 77 | self.__sendback("bye %s:%d." % addr ,addr) 78 | elif data == "ping": 79 | self.__sendback("pong", addr) 80 | elif data == "log": 81 | log_details, _ = self.sock.recvfrom(2048) # To be sent in the form "127.0.0.1 9001" 82 | log_ip, log_port = log_details.split() 83 | self.logger.set_conn(log_ip, log_port) 84 | self.logger.log_data('log_params', 85 | addr, 86 | log_ip = log_ip, 87 | log_port = log_port) 88 | self.__sendback("Set the address to log on to %s:%d." % (log_ip, int(log_port)), addr) 89 | elif data == "dumpstate": 90 | self_dump = dict((name, getattr(self, name)) for name in dir(self)) 91 | self_dump['generator_namespace'] = "Removed for practical reasons." 92 | dump_to_requester = "Dump of current state:\n\n" 93 | dump_to_requester = dump_to_requester + "".join(("%s: %s\n" % (i, str(self_dump[i])) for i in self_dump)) 94 | self.__sendback(dump_to_requester, addr) 95 | elif data == "fuzz": 96 | if not self.fuzzing: 97 | self.fuzzing = True 98 | self.fuzz_thread = Thread(target=self.__fuzz, name="fuzz") 99 | self.fuzz_thread.start() 100 | self.__sendback("Fuzzing is turned on.", addr) 101 | else: 102 | self.__sendback("Error: A fuzzing instance is already running.", addr) 103 | elif data == "stopfuzz": 104 | if self.fuzzing: 105 | self.fuzzing = False 106 | self.__sendback("Fuzzing is turned off.", addr) 107 | else: 108 | self.__sendback("Error: There is no fuzzing instance to stop.", addr) 109 | elif data == "exit": 110 | self.__sendback("goodbye", addr) 111 | self.__safe_exit("Controller requests exit, terminating program.") 112 | else: 113 | self.__sendback("Error: Invalid command.", addr) 114 | 115 | 116 | # Signal handling to continue fuzzing 117 | def __sig_handler(self, sig_no, stack_frame): 118 | self.logger.log_signal(sig_no) 119 | print "Signal handled: %d." % sig_no 120 | 121 | def __interrupt_handler(self, sig_no, stack_frame): 122 | self.__safe_exit("Interrupt signal detected, terminating program.") 123 | 124 | # Ensuring a thread safe exit. 125 | def __safe_exit(self, reason): 126 | print reason 127 | self.fuzzing = False 128 | time.sleep(0) 129 | sys.exit() 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/fuzzlogger/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/gfuzzd/fuzzlogger/__init__.py -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/fuzzlogger/gvlogger.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import socket 4 | import pickle 5 | import json 6 | 7 | class LoggerClient: 8 | """Simple logging over the network.""" 9 | 10 | log_ip = None 11 | log_port = None 12 | sock = None 13 | 14 | def __init__(self, log_ip, log_port): 15 | self.log_ip = log_ip 16 | self.log_port = log_port 17 | self.sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 18 | 19 | def set_conn(self, log_ip, log_port): 20 | self.log_ip = log_ip 21 | self.log_port = int(log_port) 22 | 23 | def log_syscall(self, syscallnr, *arg): 24 | """Logging to UDP listener. Sends a JSON string with syscall numbers and arguments. Arguments and hexlifyied.""" 25 | prepayload = {"syscall_number": syscallnr} 26 | for i in range(0, len(arg)): 27 | prepayload["arg%d" % i] = pickle.dumps(arg[i]) 28 | payload = json.dumps(prepayload, ensure_ascii=True) 29 | self.__dgram_send(payload) 30 | 31 | def log_return(self, retVal): 32 | """Sends JSON string of the return value of an executed syscall to logger.""" 33 | payload = json.dumps({"return_value": str(retVal)}, ensure_ascii=True) 34 | self.__dgram_send(payload) 35 | 36 | def log_event(self, event, urgency): 37 | """Sends a JSON string describing an event and sets its urgency type""" 38 | pay = {"event": event, "urgency": urgency} 39 | payload = json.dumps(pay, ensure_ascii=True) 40 | self.__dgram_send(payload) 41 | 42 | def log_command(self, command, addr): 43 | """Sends a JSON string of the command and addr when a command is received type""" 44 | pay = {"command": command, "addr": addr} 45 | payload = json.dumps(pay, ensure_ascii=True) 46 | self.__dgram_send(payload) 47 | 48 | def log_data(self, data, addr, **params): 49 | """Sends a JSON string of the data set name and the list of data as named parameters""" 50 | pay = {"data": data, "addr": addr} 51 | for i in params.keys(): 52 | pay[i] = params[i] 53 | payload = json.dumps(pay, ensure_ascii=True) 54 | self.__dgram_send(payload) 55 | 56 | def log_signal(self, signal): 57 | """Sends a JSON string of the signal received.""" 58 | payload = json.dumps({"signal": str(retVal)}, ensure_ascii=True) 59 | self.__dgram_send(payload) 60 | 61 | 62 | def __dgram_send(self, payload): 63 | self.sock.sendto(payload, (self.log_ip, self.log_port)) 64 | -------------------------------------------------------------------------------- /grapevine/src/gfuzzd/gfuzzd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | from fuzzd.gvfuzz import FuzzD 4 | from fuzzd.gvcallingmechanisms import XNUCallingMechanism, TestCallingMechanism 5 | from common.fuzzprofile.gvparser import GrapevineParser 6 | from fuzzlogger.gvlogger import LoggerClient 7 | 8 | UDP_IP="0.0.0.0" 9 | UDP_PORT=10001 10 | log_ip = "127.0.0.1" 11 | log_port = 5001 12 | 13 | def main(): 14 | #change paths accordingly 15 | # Get syscall profile first 16 | bsd_syscalls_master = "/home/jaybles/grapevine/grapevine/res/syscalls.master" 17 | mach_syscall_sw = "/home/jaybles/grapevine/grapevine/res/syscall_sw.c" 18 | 19 | # Obtain the syscall profile 20 | gp = GrapevineParser() 21 | syscall_profile = gp.parse(bsd_syscalls_master, mach_syscall_sw) 22 | 23 | # New Logger 24 | logger = LoggerClient(log_ip, log_port) 25 | 26 | #change TestCallingMechanism to XNUCallingMechanism() for fuzzing 27 | # Create our fuzzd instance 28 | fuzzd = FuzzD(logger, TestCallingMechanism(), syscall_profile, UDP_IP, UDP_PORT) 29 | fuzzd.listen() 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /grapevine/src/ghost/common: -------------------------------------------------------------------------------- 1 | ../common/ -------------------------------------------------------------------------------- /grapevine/src/ghost/generators/__init__.py: -------------------------------------------------------------------------------- 1 | def _import_package_files(): 2 | """ dynamically import all the public attributes of the python modules in 3 | this file's sub directory 4 | """ 5 | import os 6 | import sys 7 | import traceback 8 | 9 | package_path = os.path.split(__file__)[0] 10 | package_directory = os.path.split(package_path)[1] 11 | 12 | for fn in os.listdir(package_directory): 13 | globals_, locals_ = globals(), locals() 14 | # process all python files in directory that don't start with underscore 15 | if fn[0] != '_' and fn.split('.')[-1] in ('py', 'pyw'): 16 | modulename = fn.split('.')[0] # filename without extension 17 | subpackage = ".".join([package_directory, modulename]) 18 | try: 19 | module = __import__(subpackage, globals_, locals_, [modulename]) 20 | except: 21 | traceback.print_exc(file=sys.stdout) 22 | raise # reraise exception 23 | for attr_name in dir(module): 24 | if attr_name[0] != '_': # public name? 25 | globals_[attr_name] = module.__dict__[attr_name] 26 | 27 | _import_package_files() 28 | -------------------------------------------------------------------------------- /grapevine/src/ghost/generators/common: -------------------------------------------------------------------------------- 1 | ../../common/ -------------------------------------------------------------------------------- /grapevine/src/ghost/generators/random_fi.py: -------------------------------------------------------------------------------- 1 | from common.fuzzgenerator.gvgenerator import Generator 2 | import random 3 | import binascii 4 | class RandomFI(Generator): 5 | profile = None 6 | state = None 7 | seed = None 8 | 9 | def __init__(self, profile, seed): 10 | self.state = 0 11 | pass 12 | 13 | def getNext(self): 14 | args = [] 15 | args.append(self.__getsyscall()) 16 | for _ in range(0,8): 17 | args.append(self.__getarg()) 18 | return args 19 | 20 | def affectState(self, data): 21 | self.state = self.state + 1 22 | print "Generator got %s back. (State %d)" % (data, self.state) 23 | 24 | def __getsyscall(self): 25 | ignore = [8, 11, 17, 19, 21, 22, 38, 40, 45, 62, 63, 64, 67, 26 | 68, 69, 70, 71, 72, 76, 77, 84, 87, 88, 91, 94, 99, 27 | 101, 102, 103, 107, 108, 109, 110, 112, 113, 114, 28 | 115, 119, 125, 129, 130, 141, 143, 144, 145, 146, 29 | 148, 149, 150, 156, 160, 162, 163, 164, 166, 168, 30 | 170, 171, 172, 174, 175, 177, 178, 179, 186, 193, 31 | 198, 213, 214, 215, 216, 217, 218, 219, 224, 246, 32 | 249, 257, 312, 321, 323, 326, 335, 352, 373, 374, 33 | 375, 376, 377, 378, 379, 401, 402, 403, 404, 409, 34 | 413, 418, 419, 423, 432, 433, 35 | 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, 36 | -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, 37 | -30, -40, -41, -42, -47, -50, -54, -55, -56, -57, -63, -64, 38 | -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, 39 | -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, 40 | -95, -96, -97, -98, -99, -100] 41 | 42 | while True: 43 | random.seed(self.__getseed()) 44 | temp_sys = random.randint(-100, 433) 45 | if temp_sys not in ignore: 46 | return temp_sys 47 | 48 | def __getseed(self): 49 | return int(binascii.hexlify(open("/dev/urandom", "r").read(5).rstrip()),16) 50 | 51 | def __getrand(self): 52 | random_file = open('/dev/urandom', 'r') 53 | data = random_file.read(128).rstrip() 54 | random_file.close() 55 | return data 56 | 57 | def __getnumber(self): 58 | state = random.randrange(0,5) 59 | if state == 0: 60 | random.seed(1) 61 | return random.randrange(2147483647) 62 | elif state == 1: 63 | random.seed(1) 64 | # C-like random 65 | return (0xffffff00 | (random.randrange(2147483647) % 256)) 66 | elif state == 2: 67 | return 0x8000 68 | elif state == 3: 69 | return 0xffff 70 | elif state == 4: 71 | return 0x80000000 72 | 73 | def __getarg(self): 74 | state = random.randrange(0,5) 75 | if state == 0: 76 | return 0x0804fd00 #userland addr 77 | elif state == 1: 78 | return 0x0000a000 #unmapped addr 79 | elif state == 2: 80 | return 0xc01fa0b6 #kernel addr, a guess 81 | elif state == 3: 82 | return self.__getnumber() #some number 83 | elif state == 4: 84 | return self.__getrand() 85 | -------------------------------------------------------------------------------- /grapevine/src/ghost/ghost.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import re 5 | #from host.gvhost import HostsController 6 | import threading 7 | from logger.gvloglistener import LogListener 8 | #import host.vm.vbcontrol as VBControl 9 | #import host.vm.vbinfo as VBInformation 10 | import time 11 | def prompt(): 12 | """Helper function""" 13 | try: 14 | sys.stdout.write( "ghost> ") 15 | uin = raw_input().rstrip() 16 | return uin 17 | except KeyboardInterrupt: 18 | return "SIGINT" 19 | 20 | 21 | def unable_to_connect_callback(): 22 | print "Unable to connect." 23 | 24 | def __handle(msg, ghost): 25 | msg = msg.strip() 26 | 27 | # Warning: Ugly regex ahead. 28 | con_match = re.compile("connect\s+((?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s+(\d+)").match(msg) 29 | log_match = re.compile("log\s+((?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s+(\d+)").match(msg) 30 | 31 | if con_match: 32 | ghost.connect(con_match.group(1), con_match.group(2)) 33 | print "Connecting to %s:%d." % (con_match.group(1), 34 | int(con_match.group(2))) 35 | elif log_match: 36 | ghost.set_log(log_match.group(1), log_match.group(2)) 37 | print "Logging to %s:%d." % (ghost.log_ip, ghost.log_port) 38 | elif msg == "SIGINT": 39 | logger.stop_logging() 40 | ghost.safe_exit("Interrupt signal detected, terminating program.") 41 | elif msg == "hoststatus": 42 | states = { 43 | '0': "UNINITIALISED", 44 | '1': "CONNECTED", 45 | '2': "WAITING_FOR_PING", 46 | '3': "LOST_CONNECTION", 47 | '-1': "TERMINATED", 48 | '-2': "UNCONNECTED", 49 | } 50 | for i in ghost.hosts: 51 | print "%s:%d - %s" % (i.ip, i.port, states[str(i.state)]) 52 | elif msg == "help": 53 | sys.stdout.write( "Grapevine Host Control alpha\nCommands:\n\tcurrenthost:\t displays IP and PORT of currently connected HOST\n\tconnect:\t prompts for new connection details\n\tfuzz:\t\t start fuzzing in the connected host.\n\texit:\t\t exits the program.\n\tstopfuzz:\t\t Stops fuzzing.\n\tdumpstate:\t\t Stuff.\n\tloadgen:\t\tStuff.\n\thelp:\t\t Prints this help message.\n" ) 54 | elif msg == "exit": 55 | logger.stop_logging() 56 | ghost.safe_exit("User exited, terminating program.") 57 | elif ghost.current_host != None: 58 | if msg == "fuzz": 59 | print "Fuzzing %s:%d." % (ghost.current_host.ip, 60 | ghost.current_host.port) 61 | ghost.current_host.fuzz() 62 | elif msg == "stopfuzz": 63 | print "We stopped fuzzing %s:%d." % (ghost.current_host.ip, 64 | ghost.current_host.port) 65 | ghost.current_host.stopfuzz() 66 | elif msg == "loadgen": 67 | generator_name = raw_input("Generator Name: ") 68 | seed = raw_input("Seed: ") 69 | generator_file = raw_input("Generator File: ") 70 | try: 71 | generator_code = file(generator_file).read() 72 | except: 73 | print "Reading from %s has failed." % generator_file 74 | ghost.current_host.loadgen(generator_name, seed, generator_code) 75 | elif msg == "shutdown": 76 | ip = ghost.current_host.ip 77 | port = ghost.current_host.port 78 | ghost.current_host.shutdown() 79 | ghost.remove_current_host() 80 | print "We shut down %s:%d. Removed from tracking." % (ip, port) 81 | elif msg == "dumpstate": 82 | ghost.current_host.dumpstate() 83 | elif msg == "currenthost": 84 | sys.stdout.write("We are currently connected to %s:%d\n" % (ghost.current_host.ip, ghost.current_host.port)) 85 | else: 86 | sys.stdout.write("Command not supported for this host.\n") 87 | else: 88 | sys.stdout.write("Connect to a host to continue.\n") 89 | 90 | def __unable_to_connect_callback(addr): 91 | sys.stdout.write("\nError: We were unable to connect to %s:%d. Removing host from tracked hosts.\nghost> " % addr) 92 | ghost.remove_host(addr[0], addr[1]) 93 | sys.stdout.flush() 94 | 95 | def __lost_connection_callback(addr): 96 | sys.stdout.write("\nError: We lost our connection to %s:%d. Attempting to reconnect.\nghost> " % addr) 97 | #Bad function that restarts VM even though connection has been regained. 98 | #vbi = VBInformation.Information() 99 | #vbc = VBControl.Controller() 100 | #dead = vbi.getCrashedMachines() 101 | #to implement grab system logs, track ip to vmid 102 | #if not dead: 103 | # sys.stdout.write( "No dead machine. Lost connection due to network error or PANIC." ) 104 | # live = vbi.getAllLiveMachinesID() 105 | # sys.stdout.write("Attempting fix.") 106 | # if not live or live[0] == 0: 107 | # sys.stdout.write("Network error") 108 | # elif live == None: 109 | # sys.stdout.write("Network error") 110 | # else: 111 | # for livemachineid in live: 112 | # vbc.dumpGuestCore(livemachineid) 113 | # time.sleep(30) 114 | # vbc.shutdownMachine(livemachineid) 115 | # time.sleep(30) 116 | # vbc.activateMachine(livemachineid, True) 117 | # sys.stdout.write("Restarting possible Panic machines. This will take some time ") 118 | #else: 119 | # sys.stdout.write( "Restarting dead machines. " ) 120 | # for deadmachineid in dead: 121 | # vbc.dumpGuestCore(deadmachineid) 122 | # time.sleep(30) 123 | # vbc.shutdownMachine(deadmachinemid) 124 | # time.sleep(30) 125 | # vbc.activateMachine(deadmachinemid, True) 126 | # time.sleep(5) 127 | # 128 | # sys.stdout.write( "Restarting dead machines." ) 129 | 130 | sys.stdout.flush() 131 | 132 | def __reconnected_callback(addr): 133 | sys.stdout.write("\nWe regained our connection to %s:%d.\nghost> " % addr) 134 | sys.stdout.flush() 135 | 136 | def __connected_callback(addr): 137 | sys.stdout.write("\nSuccessfully connected to %s:%d.\nghost> " % addr) 138 | sys.stdout.flush() 139 | 140 | def __data_received_callback(addr, data): 141 | no_print = ['pong'] 142 | if not data.startswith("hello") and not data.startswith("bye") and not data in no_print: 143 | sys.stdout.write("\nNotice: We have received data from %s:%d.\n" % addr) 144 | sys.stdout.write("%s\nghost> " % data) 145 | sys.stdout.flush() 146 | 147 | def main(): 148 | callbacks = { 149 | 'unable_to_connect': __unable_to_connect_callback, 150 | 'lost_connection': __lost_connection_callback, 151 | 'reconnected': __reconnected_callback, 152 | 'data_received': __data_received_callback, 153 | 'connected': __connected_callback, 154 | } 155 | 156 | global logger 157 | logger = LogListener("0.0.0.0", 5001) 158 | logger_thread = threading.Thread(target=logger.listen) 159 | logger_thread.start() 160 | 161 | global ghost 162 | ghost = HostsController(callbacks=callbacks) 163 | 164 | while True: 165 | msg = prompt() 166 | __handle(msg, ghost) 167 | 168 | if __name__ == "__main__": 169 | main() 170 | 171 | -------------------------------------------------------------------------------- /grapevine/src/ghost/host/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/ghost/host/__init__.py -------------------------------------------------------------------------------- /grapevine/src/ghost/host/gvhost.py: -------------------------------------------------------------------------------- 1 | #/usr/bin/python 2 | 3 | import socket 4 | import select 5 | from threading import Thread 6 | import time 7 | import signal 8 | import sys 9 | 10 | 11 | class Host: 12 | """Host does monitoring of the host and allows control through callbacks.""" 13 | # Instance Variables 14 | ip = "127.0.0.1" 15 | port = 10001 16 | state = 0 # Uninitialised 17 | sock = None 18 | callback_set = {} 19 | mon_timeout = 0.02 20 | mon_ticks = 0 21 | mon_pings_missed = 0 22 | 23 | # Constants 24 | UNINITIALISED = 0 25 | CONNECTED = 1 26 | WAITING_FOR_PING = 2 27 | LOST_CONNECTION = 3 28 | TERMINATED = -1 29 | UNCONNECTED = -2 30 | 31 | def __init__(self, ip, port, callback_set = {}): 32 | self.ip = ip 33 | self.port = int(port) 34 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 35 | self.sock.setblocking(0) 36 | if callback_set == {}: 37 | self.callback_set = { 38 | 'unable_to_connect': self.__default_unable_to_connect_callback, 39 | 'lost_connection': self.__default_lost_connection_callback, 40 | 'data_received': self.__default_data_received_callback, 41 | 'reconnected': self.__default_reconnected_callback, 42 | 'connected': self.__default_connected_callback, 43 | } 44 | else: 45 | self.callback_set = callback_set 46 | 47 | 48 | # Internal host functions 49 | 50 | def __send_cmd(self, data): 51 | self.sock.sendto(data, (self.ip, self.port)) 52 | 53 | def __call_callback(self, event, *args): 54 | self.callback_set[event](*args) 55 | 56 | @staticmethod 57 | def __default_lost_connection_callback(addr): 58 | print "Not implemented." 59 | 60 | @staticmethod 61 | def __default_unable_to_connect_callback(addr): 62 | print "Advice: Not implememnted." 63 | 64 | @staticmethod 65 | def __default_reconnected_callback(addr): 66 | print "Advice: Reconnected event is not handled." 67 | 68 | @staticmethod 69 | def __default_connected_callback(addr): 70 | print "Advice: Connected event is not handled." 71 | 72 | @staticmethod 73 | def __default_data_received_callback(addr, data): 74 | print "\nData is Received:\n", data 75 | 76 | def start(self): 77 | Thread(target=self.monitor, name="monitor").start() 78 | self.hello() 79 | 80 | def monitor(self): 81 | """Run in a separate thread to block on select calls. On the first run the timeout is set to 5 seconds, otherwise it takes a minute to timeout. Pings should be sent every 2 seconds so if there is no response in a minute, it is assumed that a crash has occured and the crash_detected callback will be called. On the first run, it will call the unable_to_connect callback.""" 82 | while self.state >= 0: 83 | self.mon_ticks = self.mon_ticks + 1 84 | ready = select.select([self.sock], [], [], self.mon_timeout) 85 | if ready[0]: 86 | data = self.sock.recv(4092) 87 | self.__handle(data) 88 | ready = None 89 | self.__tick_check() 90 | 91 | def __tick_check(self): 92 | ticks_per_sec = 1/self.mon_timeout 93 | secs_elapsed = self.mon_ticks/ticks_per_sec 94 | if secs_elapsed > 5.0 and self.state == self.UNINITIALISED: 95 | self.__call_callback("unable_to_connect", 96 | (self.ip, self.port)) 97 | self.state = self.UNCONNECTED 98 | if secs_elapsed % 2 == 0: 99 | self.ping() 100 | if self.state == self.CONNECTED: 101 | self.state = self.WAITING_FOR_PING 102 | if self.state == self.WAITING_FOR_PING: 103 | self.mon_pings_missed = self.mon_pings_missed + 1 104 | if (self.mon_pings_missed/(1/self.mon_timeout)) > 5 and self.state == self.WAITING_FOR_PING: 105 | self.__call_callback("lost_connection", (self.ip, self.port)) 106 | self.state = self.LOST_CONNECTION 107 | 108 | def __handle(self, data): 109 | self.__call_callback('data_received', (self.ip, self.port), data) 110 | if data.startswith("hello from "): 111 | self.state = self.CONNECTED 112 | self.__call_callback("connected", (self.ip, self.port)) 113 | self.mon_pings_missed = 0 114 | elif data == "pong": 115 | if self.state == self.WAITING_FOR_PING: 116 | self.state = self.CONNECTED 117 | elif self.state == self.LOST_CONNECTION: 118 | self.state = self.UNINITIALISED 119 | self.__call_callback("reconnected", (self.ip, self.port)) 120 | self.mon_ticks = 0 121 | self.hello() 122 | self.mon_pings_missed = 0 123 | 124 | def stop(self): 125 | self.state = self.TERMINATED 126 | 127 | def is_host(self, ip, port): 128 | if self.ip == ip and self.port == int(port): 129 | return True 130 | else: 131 | return False 132 | 133 | # Command sending functions 134 | 135 | def shutdown(self): 136 | self.__send_cmd("exit") 137 | self.state = self.TERMINATED 138 | 139 | def bye(self): 140 | self.__send_cmd("bye") 141 | 142 | def hello(self): 143 | self.__send_cmd("hello") 144 | 145 | def ping(self): 146 | self.__send_cmd("ping") 147 | 148 | def fuzz(self): 149 | self.__send_cmd("fuzz") 150 | 151 | def stopfuzz(self): 152 | self.__send_cmd("stopfuzz") 153 | 154 | def loadgen(self, gen_name, seed, code): 155 | self.__send_cmd("loadgen") 156 | self.__send_cmd(gen_name) 157 | self.__send_cmd(seed) 158 | self.__send_cmd(code) 159 | 160 | def log(self, ip, port): 161 | self.__send_cmd("log") 162 | self.__send_cmd("%s %d" % (ip, int(port))) 163 | 164 | def dumpstate(self): 165 | self.__send_cmd("dumpstate") 166 | 167 | class HostsController: 168 | hosts = [] # A list of Hosts 169 | hostVMID = [] 170 | log_ip = "127.0.0.1" # Externally accessible host IP address. 171 | log_port = 5000 172 | sock = None 173 | current_host = None 174 | callbacks = {} 175 | 176 | def __init__(self, hosts = [], log_ip = "127.0.0.1", log_port = 5000, callbacks = {}): 177 | # hosts is to be a list of tuples in the form (addr, port) 178 | for i in hosts: 179 | ip, port = i 180 | self.add_new_host(ip, port) 181 | self.log_ip = log_ip 182 | self.log_port = log_port 183 | self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 184 | self.callbacks = callbacks 185 | 186 | def connect(self, ip, port): 187 | new_host = True 188 | for i in self.hosts: 189 | if i.is_host(ip, port): 190 | new_host = False 191 | if new_host: 192 | self.add_new_host(ip, port) 193 | self.set_current_host(ip, port) 194 | 195 | def add_new_host(self, ip, port): 196 | for i in self.hosts: 197 | if i.is_host(ip, port): 198 | return False 199 | new_host = Host(ip, port, self.callbacks) 200 | self.hosts.append(new_host) 201 | new_host.start() 202 | 203 | def remove_host(self, ip, port): 204 | for i in self.hosts: 205 | if i.is_host(ip, port): 206 | i.stop() 207 | if self.current_host.is_host(ip, port): 208 | self.remove_current_host() 209 | else: 210 | self.hosts.remove(i) 211 | 212 | def remove_current_host(self): 213 | self.hosts.remove(self.current_host) 214 | self.current_host = None 215 | 216 | def set_current_host(self, ip, port): 217 | for i in self.hosts: 218 | if i.is_host(ip, port): 219 | self.current_host = i 220 | 221 | def set_log(self, ip, port): 222 | self.log_ip = ip 223 | self.log_port = int(port) 224 | self.broadcast("log", self.log_ip, self.log_port) 225 | 226 | def __interrupt_handler(self, sig_no, stack_frame): 227 | self.__safe_exit("Interrupt signal detected, terminating program.") 228 | 229 | def broadcast(self, fun_name, *args): 230 | try: 231 | for i in self.hosts: 232 | getattr(i, fun_name)(*args) 233 | return True 234 | except AttributeError: 235 | return False 236 | 237 | # Ensuring a thread safe exit. 238 | def safe_exit(self, reason): 239 | print reason 240 | for i in self.hosts: 241 | i.bye() 242 | i.state = Host.TERMINATED 243 | time.sleep(0) 244 | sys.exit() 245 | -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/ghost/host/vm/__init__.py -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Web UI 10 | 11 | 12 | 206 | 207 | 208 |
209 |
210 |
211 | 212 |
213 |
214 |
215 |
216 |
Add Host
217 |
Show History
218 |
219 | 222 |
223 | 382 | 383 | -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/html/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | 6 | html, body, div, span, applet, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | a, abbr, acronym, address, big, cite, code, 9 | del, dfn, img, ins, kbd, q, s, samp, 10 | small, strike, strong, sub, sup, tt, var, u, center, 11 | dl, dt, dd, ol, ul, li, 12 | fieldset, form, label, legend, 13 | table, caption, tbody, tfoot, thead, tr, th, td, 14 | article, aside, canvas, details, embed, 15 | figure, figcaption, footer, header, hgroup, 16 | menu, nav, output, ruby, section, summary, 17 | time, mark, audio, video { 18 | margin: 0; 19 | padding: 0; 20 | border: 0; 21 | font-size: 100%; 22 | font: inherit; 23 | vertical-align: baseline; 24 | } 25 | /* HTML5 display-role reset for older browsers */ 26 | article, aside, details, figcaption, figure, 27 | footer, header, hgroup, menu, nav, section { 28 | display: block; 29 | } 30 | body { 31 | line-height: 1; 32 | } 33 | ol, ul { 34 | list-style: none; 35 | } 36 | blockquote, q { 37 | quotes: none; 38 | } 39 | blockquote:before, blockquote:after, 40 | q:before, q:after { 41 | content: ''; 42 | content: none; 43 | } 44 | table { 45 | border-collapse: collapse; 46 | border-spacing: 0; 47 | } -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/html/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/ghost/host/vm/html/title.png -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/vbcontrol.py: -------------------------------------------------------------------------------- 1 | # This file contains parts of code taken from VBox SDK samples: 2 | # Copyright (C) 2009-2010 Oracle Corporation, 3 | # part of VirtualBox Open Source Edition (OSE), as 4 | # available from http://www.virtualbox.org. This file is free software; 5 | # you can redistribute it and/or modify it under the terms of the GNU 6 | # General Public License (GPL) as published by the Free Software 7 | # Foundation, in version 2 as it comes in the "COPYING" file of the 8 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the 9 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 10 | # 11 | import os 12 | import sys 13 | import vboxapi 14 | import time 15 | 16 | class Controller(object): 17 | 18 | def __init__(self): 19 | try: 20 | self.virtualBoxManager = vboxapi.VirtualBoxManager(None, None) 21 | self.virtualBox = self.virtualBoxManager.vbox 22 | except Exception, e: # This error occurs when the PYTHONPATH is not set to virtualbox directory 23 | sys.exit("Please run the following command before re-running this program :\n\nexport PYTHONPATH=$PYTHONPATH:/usr/lib/virtualbox/:/usr/lib/virtualbox/sdk/bindings/xpcom/python/") 24 | 25 | 26 | def getMachineById(self, mid): 27 | try: 28 | machine = self.virtualBox.getMachine(mid) 29 | except: 30 | machine = self.virtualBox.findMachine(mid) 31 | 32 | return machine 33 | 34 | def activateMachine(self, mid, gui): 35 | virtualMachine = self.getMachineById(mid) 36 | self.session = self.virtualBoxManager.mgr.getSessionObject(self.virtualBox) 37 | if gui: 38 | progress = virtualMachine.launchVMProcess(self.session, "gui", "") 39 | else: 40 | progress = virtualMachine.launchVMProcess(self.session, "vrdp", "") 41 | progress.waitForCompletion(-1) 42 | self.session.unlockMachine() 43 | 44 | 45 | def commandMachine(self, vmID, command, arguments): 46 | machine = self.getMachineById(vmID) 47 | session = self.virtualBoxManager.mgr.getSessionObject(self.virtualBox) 48 | machine.lockMachine(session, self.virtualBoxManager.constants.LockType_Shared) 49 | if session.state != self.virtualBoxManager.constants.SessionState_Locked: 50 | session.unlockMachine() 51 | 52 | console = session.console 53 | options = { 54 | 'shutdown': lambda: console.powerDown(), 55 | 'takeSnapshot': lambda: console.takeSnapshot(), 56 | 'deleteSnapshot': lambda: console.deleteSnapshot(arguments), 57 | 'restoreSnapshot': lambda: console.restoreSnapshot(arguments), 58 | 'pause': lambda: console.pause(), 59 | 'resume': lambda: console.resume(), 60 | 'getDumpFiles': lambda: console.debugger.dumpGuestCore(arguments, None) 61 | } 62 | 63 | try: 64 | executionProgress = options[command]() 65 | if executionProgress: 66 | while not executionProgress.completed: 67 | executionProgress.waitForCompletion(-1) 68 | if executionProgress.completed and int(executionProgress.resultCode) == 0: 69 | print 'Completed' 70 | else: 71 | session.unlockMachine() 72 | return False 73 | except Exception, e: 74 | print e 75 | 76 | session.unlockMachine() 77 | return True 78 | 79 | def shutdownMachine(self, vbID): 80 | self.commandMachine(vbID, 'shutdown', None) 81 | 82 | def dumpGuestCore(self, vbID): 83 | filename = str(int(time.time())) 84 | filename += ".dump" 85 | self.commandMachine(vbID, 'getDumpFiles', filename) 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/vbinfo.py: -------------------------------------------------------------------------------- 1 | # This file contains parts of code taken from VBox SDK samples: 2 | # Copyright (C) 2009-2010 Oracle Corporation, 3 | # part of VirtualBox Open Source Edition (OSE), as 4 | # available from http://www.virtualbox.org. This file is free software; 5 | # you can redistribute it and/or modify it under the terms of the GNU 6 | # General Public License (GPL) as published by the Free Software 7 | # Foundation, in version 2 as it comes in the "COPYING" file of the 8 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the 9 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 10 | # 11 | import vboxapi 12 | import sys 13 | import os 14 | 15 | class Information(object): 16 | 17 | def __init__(self): 18 | try: 19 | self.virtualBoxManager = vboxapi.VirtualBoxManager(None, None) 20 | self.virtualBox = self.virtualBoxManager.vbox 21 | except Exception, e: # This error occurs when the PYTHONPATH is not set to virtualbox directory 22 | sys.exit("Please run the following command before re-running this program :\n\nexport PYTHONPATH=$PYTHONPATH:/usr/lib/virtualbox/:/usr/lib/virtualbox/sdk/bindings/xpcom/python/") 23 | 24 | def listAllMachines(self): 25 | print "List of availabe VirtualBox machines :\n" 26 | virtualBoxConstants = self.virtualBoxManager.constants 27 | for machine in self.virtualBoxManager.getArray(self.virtualBox, 'machines'): 28 | print "[%s]" %(machine.name) 29 | print "'--State: %s" %(self.enumToString(virtualBoxConstants, "MachineState", machine.state)) 30 | print "'--Session state: %s" %(self.enumToString(virtualBoxConstants, "SessionState", machine.sessionState)) 31 | print "'--ID: %s\n" %machine.id 32 | 33 | def jsonifyMachinesData(self): 34 | jsonString = "[" 35 | virtualBoxConstants = self.virtualBoxManager.constants 36 | for machine in self.virtualBoxManager.getArray(self.virtualBox, 'machines'): 37 | jsonString += "{" 38 | jsonString += "'MachineState' : '" + str(self.enumToString(virtualBoxConstants, "MachineState", machine.state)) + "'," 39 | jsonString += "'SessionState' : '" + str(self.enumToString(virtualBoxConstants, "SessionState", machine.state)) + "'," 40 | jsonString += "'MachineID' : '" + str(machine.id) + "'," 41 | jsonString += "'MachineOS' : '" + str(machine.OSTypeId) + "'," 42 | jsonString += "'MachineMemSize' : '" + str(machine.memorySize) + "'," 43 | jsonString += "'MachineName' : '" + str(machine.name) + "'" 44 | jsonString += "}," 45 | 46 | jsonString += "]" 47 | return jsonString 48 | def getAllLiveMachinesID(self): 49 | livemachinesID = [] 50 | virtualBoxConstants = self.virtualBoxManager.constants 51 | for machine in self.virtualBoxManager.getArray(self.virtualBox, 'machines'): 52 | machineState = self.enumToString(virtualBoxConstants, "MachineState", machine.state) 53 | if machineState == "Running": 54 | livemachinesID.append(machine.id) 55 | if livemachinesID == None: 56 | return [0] 57 | else: 58 | return livemachinesID 59 | 60 | def getCrashedMachines(self): 61 | ## ToDo to return a list of vbID that hanged 62 | crashedMachinesID = [] 63 | virtualBoxConstants = self.virtualBoxManager.constants 64 | for machine in self.virtualBoxManager.getArray(self.virtualBox, 'machines'): 65 | machineState = self.enumToString(virtualBoxConstants, "MachineState", machine.state) 66 | if machineState == "Aborted": 67 | crashedMachinesID.append(machine.id) 68 | elif machineState == "Paused": 69 | crashedMachinesID.append(machine.id) 70 | 71 | if crashedMachinesID != None: 72 | return crashedMachinesID 73 | else: 74 | return "0" ## For JavaScript to interpret 75 | 76 | def checkIfAlive(self, IPAddress): 77 | commandString = "ping -c 1 " + IPAddress 78 | resultVariable = os.system(commandString) 79 | 80 | if resultVariable == 0: 81 | return True 82 | else: 83 | return False 84 | 85 | # 86 | # Converts an enumeration to a printable string. 87 | # 88 | def enumToString(self, constants, enumerate, element): 89 | all = constants.all_values(enumerate) 90 | for key in all.keys(): 91 | if str(element) == str(all[key]): 92 | return key 93 | 94 | -------------------------------------------------------------------------------- /grapevine/src/ghost/host/vm/vbwebui.py: -------------------------------------------------------------------------------- 1 | import json 2 | import vboxapi 3 | import vbinfo as VBInformation 4 | from twisted.web import server, resource 5 | from twisted.internet import reactor 6 | 7 | class WebInterface(resource.Resource): 8 | isLeaf = True 9 | VBInfo = VBInformation.Information() 10 | 11 | def generateJSONResponse(self): 12 | VirtualBoxObject = "{ 'Machines' : " + self.VBInfo.jsonifyMachinesData() + ", " 13 | VirtualBoxObject += "'crashedMachines' : '" + self.VBInfo.getCrashedMachines() + "' }" 14 | VirtualBoxObjectJSON = json.dumps(eval(VirtualBoxObject), sort_keys=True, indent=3) 15 | return VirtualBoxObjectJSON 16 | 17 | def render_GET(self, request): 18 | request.setHeader("content-type", "text/plain") 19 | request.setHeader("Access-Control-Allow-Origin", "*") 20 | return self.generateJSONResponse() 21 | 22 | reactor.listenTCP(8080, server.Site(WebInterface())) 23 | reactor.run() -------------------------------------------------------------------------------- /grapevine/src/ghost/logger/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nnamon/grapevine/63829f2d127e2e5ccd2c2327991e3b05971ae48e/grapevine/src/ghost/logger/__init__.py -------------------------------------------------------------------------------- /grapevine/src/ghost/logger/gvloglistener.py: -------------------------------------------------------------------------------- 1 | #!usr/bin/python 2 | 3 | import socket 4 | import time 5 | import select 6 | 7 | class LogListener: 8 | 9 | ip = "0.0.0.0" 10 | port = 5001 11 | sock = None 12 | logging = True 13 | 14 | def __init__(self, ip, port): 15 | self.ip = ip 16 | self.port = int(port) 17 | 18 | def listen(self): 19 | self.sock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM ) 20 | self.sock.bind((self.ip, self.port)) 21 | filename = str(int(time.time())) 22 | log_file = open(filename, 'w') 23 | while self.logging: 24 | ready = select.select([self.sock], [], [], 0.025) 25 | if ready[0]: 26 | data, addr = self.sock.recvfrom(10240) 27 | log_file.write("HOST (%s:%d)\n" % addr) 28 | log_file.write(data) 29 | log_file.write("\nNEWSET\n") 30 | log_file.flush() 31 | 32 | def stop_logging(self): 33 | self.logging = False 34 | 35 | --------------------------------------------------------------------------------