Resource Control of Untrusted Code in an Open Network Environment
Total Page:16
File Type:pdf, Size:1020Kb
UCAM-CL-TR-561 Technical Report ISSN 1476-2986 Number 561 Computer Laboratory Resource control of untrusted code in an open network environment Paul B. Menage March 2003 15 JJ Thomson Avenue Cambridge CB3 0FD United Kingdom phone +44 1223 763500 http://www.cl.cam.ac.uk/ c 2003 Paul B. Menage This technical report is based on a dissertation submitted June 2000 by the author for the degree of Doctor of Philosophy to the University of Cambridge, Magdalene College. Some figures in this document are best viewed in colour. If you received a black-and-white copy, please consult the online version if necessary. Technical reports published by the University of Cambridge Computer Laboratory are freely available via the Internet: http://www.cl.cam.ac.uk/TechReports/ Series editor: Markus Kuhn ISSN 1476-2986 Summary Current research into Active Networks, Open Signalling and other forms of mobile code have made use of the ability to execute user-supplied code at locations within the network infrastructure, in order to avoid the inherent latency associated with wide area networks or to avoid sending excessive amounts of data across bottleneck links or nodes. Existing research has addressed the design and evaluation of programming environments, and testbeds have been implemented on traditional operating systems. Such work has deferred issues regarding resource control; this has been reasonable, since this research has been conducted in a closed environment. In an open environment, which is required for widespread deployment of such technologies, the code supplied to the network nodes may not be from a trusted source. Thus, it cannot be assumed that such code will behave non-maliciously, nor that it will avoid consuming more than its fair share of the available system resources. The computing resources consumed by end-users on programmable nodes within a network are not free, and must ultimately be paid for in some way. Programmable networks allow users substantially greater complexity in the way that they may consume network resources. This dissertation argues that, due to this complexity, it is essential to be able control and account for the resources used by untrusted user-supplied code if such technology is to be deployed effectively in a wide-area open environment. The Resource Controlled Active Node Environment (Rcane) is presented to facilitate the control of untrusted code. Rcane supports the allocation, scheduling and accounting of the resources available on a node, including CPU and network I/O scheduling, memory allocation, and garbage collection overhead. A prototype implementation of Rcane over the Nemesis Operating System is described; an experimental evaluation is undertaken to demonstrate the value of such an approach. Sample implementations of existing active network systems that have been adapted to use Rcane's resource control interfaces are presented. 3 Acknowledgements I would like to thank my supervisor, Simon Crosby, for his enthusiastic yet unstifling advice and encouragement during my time at the University of Cambridge Computer Laboratory. Many Systems Research Group members, past and present, have provided helpful discussions and infrastructure without which this work would not have been possible. In particular, thanks are due to Neil Stratford, Tim Harris, Richard Mortier, Dickon Reed, Steven Hand, Andrew Moore, Austin Donnelly, Stephen Early, Ian Pratt, Paul Barham and Richard Black. For reading and commenting on drafts of this dissertation I am indebted to Simon Crosby, Steven Hand, Dickon Reed, Ian Leslie, Richard Mortier, Tim Harris, Austin Donnelly, Steven McKellar and Rebecca Isaacs. For her 2am colour printing heroics, Melissa Ho deserves to be canonised. Thanks also go to the Computer Laboratory system administrators for their tireless work. I would like to thank Jonathan Smith for his substantial encouragement and advice, and for the very rewarding summer that I spent in the Distributed Systems Laboratory at the University of Pennsylvania. Scott Alexander, Angelos Keromytis, Marianne Shaw, Mike Hicks and Jonathan Moore also helped make my time there enjoyable and worthwhile. This work was supported by a grant from the EPSRC. I am also very grateful to the Computer Laboratory for supporting me for an additional term beyond the end of my EPSRC grant. Finally, I would like to thank all those friends who made my six years in Cambridge so enriching, memorable and fulfilling { this dissertation is dedicated to them, and in particular to Clare, Sean and Paul. 4 Contents List of Figures 9 List of Tables 11 1 Introduction 12 1.1 Motivation . 12 1.1.1 The Case for Mobility . 12 1.1.2 Programmable Networks . 14 1.1.3 Untrusted Code . 15 1.1.4 Issues of Resource Control . 15 1.2 Contribution . 16 1.3 Outline . 17 2 Background 19 2.1 Evolution of Network Services . 19 2.1.1 Passive Networks . 19 2.1.2 Programmable Networks . 20 2.2 Safe Execution of Untrusted Code . 29 2.2.1 Overview . 29 2.2.2 Language-based control . 29 2.2.3 Low-level control . 31 2.2.4 Security . 32 2.2.5 Operating System Extensions . 33 2.3 Resource Control and Accounting . 34 2.3.1 Resource Control in Operating Systems . 34 2.3.2 Resource Control in Mobile Code and Safe Languages . 36 2.4 Summary . 37 3 Resource Control Requirements 38 3.1 The Case for Resource Reservations . 38 3.1.1 Resource Reservations in Passive Networks . 38 3.1.2 Resource Reservations in a Programmable Network . 39 3.2 Approaches to Resource Control . 41 3.2.1 Control through proof . 41 3.2.2 Control through scheduling/accounting . 42 3.3 Resources requiring control . 43 3.3.1 CPU cycles . 43 5 3.3.2 Memory Usage . 44 3.3.3 Network Bandwidth . 47 3.3.4 Summary . 47 4 Nemesis 48 4.1 Overview . 48 4.2 Operating System Structure . 49 4.2.1 Traditional Systems . 49 4.2.2 Vertical Structure . 50 4.3 CPU Scheduling . 50 4.4 Interprocess Communication . 51 4.5 Device Architecture . 52 4.6 Network I/O . 53 4.7 Summary . 53 5 The RCANE Architecture 54 5.1 Introduction . 54 5.2 Architectural Principles . 55 5.2.1 System Structure . 55 5.2.2 Security . 59 5.2.3 Code Safety . 60 5.2.4 Modules . 63 5.3 CPU Management . 64 5.3.1 Events . 66 5.4 Network I/O . 67 5.5 Memory . 69 5.5.1 Multiple Virtual Machines . 70 5.5.2 Single Tagged Heap . 71 5.5.3 Multiple Independent Heaps . 73 5.5.4 RCANE memory architecture . 75 5.6 Inter-Session Services . 75 5.6.1 Types of RPC . 76 5.6.2 Priority Inversion . 80 5.6.3 Recovery from Client Failure . 81 5.6.4 RCANE Services . 83 5.6.5 Abnormal Termination . 86 5.6.6 Service Modules . 87 5.7 Accounting and Accountability . 88 5.7.1 Pricing and Charging . 88 5.7.2 Dealing with Denial of Service Attacks . 89 5.8 Summary . 91 6 Prototype RCANE Implementation 92 6.1 Overview . 92 6.2 OCaml Deficiencies . 94 6.2.1 Thread Model . 95 6.2.2 Bytecode linker . 95 6 6.2.3 Confusion of interface and implementation . 97 6.2.4 Representation of exceptions . 98 6.2.5 Access to unsafe features . 99 6.2.6 Just-in-time compilation . 99 6.2.7 Lack of bytecode verifier . 100 6.3 CPU management . 100 6.3.1 CPU Scheduling . 100 6.3.2 Events and Thread pools . 101 6.4 Memory management . 102 6.4.1 Heap Management . 102 6.4.2 Garbage Collection . 104 6.4.3 Low-memory conditions . 105 6.5 Network I/O . 107 6.5.1 Enhancements to Nemesis network subsystems . 109 6.6 Bytecode Librarian . 110 6.6.1 Linking . 110 6.7 Service Implementation . ..