N/A
1. Background and Relevant Art
As computerized systems have increased in popularity, so have the various application programs used on the computerized systems. In particular, there are now a wide range of applications programs configured for any number of purposes, whether to function as complex operating systems, databases, and so forth, or as a simple calculator. In many cases, software developers will write new application programs with a particular operating system in mind, using any number of appropriate languages. Once the software is complete, the developer will compile the application into machine-executable code, which can then be installed on a computer system with the appropriate operating system.
One will appreciate, therefore, that there are a number of considerations that often must considered by developers of operating systems as well as of the individual application programs. Many of these interests may even be competing. For example, many application program developers may have interests related to quick and fast operation, while many operating system developers may have interests related to security and stability. In some cases, the security and stability requirements can cause some application programs to have slower execution and/or lower-performance.
For example, the operating system may be configured to have application programs run in a less-trusted “user” level, but have other system components run in a trusted “kernel” level. As a result, an application program running in a user level might only be able to perform certain types of functions by requesting the given function through an intermediary, trusted component. The intermediate component can then validate the request and then pass the request for the function to a kernel level component, which can then execute the request.
Other ways of managing security are to limit the various applications and components to specific readable, writable, and/or executable permission spaces. For example, an operating system might allow certain application programs to run only in a read/execute address space. This might allow the application programs to execute any existing instructions, but would prohibit the application from performing any write operations. By contrast, the operating system might allow other sensitive system components to operate only in a read/write address space. This might allow the sensitive components to make new writes, but would prohibit those writes from being executed.
In still other cases, an operating system might allow only certain types of application programs conforming to certain code standards to run in a space that is readable, writable, and executable. For example, the operating system might only allow “type-safe” applications to run in a read/write/execute address space. One example of a type-safety rule might be to require an integer value to be added only to other integer values, rather than to floating point values. A type-safe compiler could then be used to compile only that executable program code that is type-safe, and thus trusted by the operating system.
Unfortunately, some recent trends in application program developing complicates various aspects of the above-mentioned security management approaches. For example, a wide range of application developers are now creating video game application programs using “managed code.” In general, managed code includes executable program code, as well as intermediate language code that can be compiled on an as-needed basis. For example, a developer of an application program might include one or more references (in the compiled, executable code) to intermediate code. Thus, when the executable code comes to a point where it needs to use a function that is available only in intermediate language code, a JIT (just-in-time) compiler is used to compile certain intermediate language code into executable instructions.
One can appreciate, therefore, that operating systems will sometimes limit the use of managed code to type-safe applications. In particular, since the JIT compiler will need to write, and since the application will need to execute, and further since the application program will need to access the compiled code written by the JIT compiler, the JIT compiler and the executing application program will typically operate in the same address space, which is readable, writable, and executable. Thus, if the intermediate language code were not type-safe (or conforming to some other program code restrictions), a malicious party could trick the JIT compiler into generating harmful instructions that are executed.
Unfortunately, program code restrictions such as type-safety are often believed to conflict with speed and performance considerations. This can be particularly problematic for video game applications, where speed and performance considerations are placed at a premium. In some cases, therefore, the developers of video game applications may find it better or more efficient to ignore specific code specifications, such as type-safety.
Implementations of the present invention provide systems, methods, and computer program products configured to allow for the use of managed code in an operating system, where the managed code may not necessarily conform to any particular code standard. In one implementation, for example, an operating system provides access to a memory location in two different address spaces, and sets the permissions in the address spaces, such that the memory location is accessible with different permissions from the two different address spaces. In one implementation, a JIT compiler operating in one address space passes compiled code into a shared memory heap. Executable program code, in turn, accesses the compiled code from the memory heap, and executes it in the other memory address space.
For example, a method of executing managed code so that untrusted program code can be compiled and executed in a manner that does not threaten or otherwise compromise system security can involve executing an application program in a first address space of a memory location. The method can also involve receiving one or more requests from the application program to compile one or more sets of intermediate language instructions. In addition, the method can involve compiling the one or more sets of intermediate language instructions into newly compiled code using a JIT compiler running in a second address space of the memory location. Furthermore, the method can involve passing the newly compiled code to a shared memory heap. The application program can then retrieve the newly compiled code from the shared memory heap into the first address space.
Similarly, another method of generating computer executable program code in a manner that uses JIT compilation while avoiding security violations can involve receiving application program code that includes executable code and code to be compiled. The method can also involve executing the executable code in a lower-privilege mode and in a first address space. In addition, the method can involve identifying one or more pointers in the executable code for at least some code to be compiled. Furthermore, the method can involve switching to a higher-privilege mode. Still further, the method can involve compiling the at least some code in a different address space using a compiler operating in the higher-privilege mode.
This Summary is provided to introduce a selection of concepts in a simplified form that are further described below in the Detailed Description. This Summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the invention. The features and advantages of the invention may be realized and obtained by means of the instruments and combinations particularly pointed out in the appended claims. These and other features of the present invention will become more fully apparent from the following description and appended claims, or may be learned by the practice of the invention as set forth hereinafter.
In order to describe the manner in which the above-recited and other advantages and features of the invention can be obtained, a more particular description of the invention briefly described above will be rendered by reference to specific embodiments thereof which are illustrated in the appended drawings. Understanding that these drawings depict only typical embodiments of the invention and are not therefore to be considered to be limiting of its scope, the invention will be described and explained with additional specificity and detail through the use of the accompanying drawings in which:
Implementations of the present invention extend to systems, methods, and computer program products configured to allow for the use of managed code in an operating system, where the managed code may not necessarily conform to any particular code standard. In one implementation, for example, an operating system provides access to a memory location in two different address spaces, and sets the permissions in the address spaces, such that the memory location is accessible with different permissions from the two different address spaces. In one implementation, a JIT compiler operating in one address space passes compiled code into a shared memory heap. Executable program code, in turn, accesses the compiled code from the memory heap, and executes it in the other memory address space.
As will be understood more fully herein, implementations of the present invention can provide a secure system without necessarily needing to verify that the generated code does not violate the security constraints of the system. This can be done at least partly by “sandboxing” the compiled code, as well as any other code that is being executed. In particular, implementations of the present invention can define a “sandbox, ” which is essentially a predefined set of boundaries in which any type of code can be executed. Specifically, the sandbox boundaries described herein will result in malicious request(s) made by the executing code being either denied by the operating system (as coming from a user mode component), or limited to actions or functions only within the predefined permissions (e.g., denying a write to a read/execute address space).
As a result, code that is compiled by a JIT compiler (e.g., 105), or even the application program (e.g., 110) ultimately invoking the JIT compiler, can be executed within the sandbox without necessarily being “type-safe,” or conforming to some other security consideration. One will appreciate that this can free a given developer to write application program code in a manner that is potentially less constrained, and potentially faster and performance driven than previously possible.
In addition to ensuring that code is executed properly, implementations of the present invention also provide mechanisms that ensure that the JIT compiler, itself, cannot be “hijacked,” such as when receiving and compiling intermediate language code. In particular, implementations of the present invention include a JIT compiler that is configured for type-safe execution, rather than necessarily checking incoming code for type-safety or compiling only type-safe code. As such, the JIT compiler in accordance with implementations of the present invention can be protected against requests that would cause the JIT compiler itself to violate safety definitions (e.g., type-safe definitions).
In one implementation, for example, the JIT compiler can be configured with type-safety definitions that restrict the JIT compiler from reaching outside of its own data structures, or the data structures that are defined as part of the system 100 runtime. For example, the JIT compiler can be configured to perform a series of checks to ensure that only valid casts are performed whenever performing casts from one type to another. Similarly, the JIT compiler can be configured so that, whenever asked to read out of arrays, the JIT compiler performs one or more boundary checks to ensure that the JIT compiler is within the bounds of the array. With respect to use within the C programming language, for example, the JIT compiler can also be configured to ensure that whenever using a “union,” the JIT compiler reads or writes to the proper part of the union. Furthermore, the JIT compiler can be configured to ensure the JIT compiler never overflows or underflows while reading or writing the type-stack (the type-stack within the JIT compiler).
In general, the JIT compiler's type-stack is an internal data structure that is generally important to maintain correctness, etc. For example, intermediate language code is typically a stack-based system in which the JIT compiler operates on objects in a stack in order, and places results back into the stack in order. The JIT compiler in accordance with implementations of the present invention is thus configured to simulate a stack to ensure that the JIT compiler is operating as expected. For example, the JIT compiler can perform stack simulation while compiling intermediate language code. If the simulated stack deviates significantly from what the JIT compiler is being fed, the JIT compiler can quit compilation or generate an error. This helps the JIT compiler ensure that it is operating within prescribed boundaries, and thus protected from violating one or more security rules.
There are any number of different ways that application program 10 will or can be executed in computer system 100. For example, a user might load a storage device onto another device on which the system 100 is installed. The storage device may include binary executable code for application program 110, as well as managed code in the form of intermediate language code 115. Both the executable code and intermediate language code of application program 110 could then be loaded into computerized system 100. In other cases, a user, such as a developer, may upload the application program 110, including intermediate language code 115 through a network connection. In such a case, the user might be executing application program 110 for testing newly developed application programs (e.g., 110).
In any event,
Accordingly, as the runtime for application program 110 executes each of the compiled instructions 135, 145 in user 113 mode, the runtime will come across any of one or more pointers to intermediate language code. For example, during execution, the runtime for application program 110 comes across pointer 140 to intermediate language code 120. Since pointer 140 references code that can only be accessed in kernel 103 mode, the runtime will break out of user mode and system 100 will switch to kernel 103 mode.
The request 143 will then be handled by security component 155, which operates in kernel 103 mode. In general, security component 155 can comprise any number or type of components or modules configured to receive a user mode 113 component request (e.g., 143), and then validate whether the request is appropriate. This is done since user mode 113 is untrusted, and since application program 110 may or may not represent (or otherwise include) dangerous or malicious code.
Thus, to ensure that requests from user mode 113 execution will not damage system 100, security component 155 can perform any number or type of validation functions. For example, security component 155 can review message 143 for any number of handles, tokens, or the like. Furthermore, security component 155 can review request 143 for application instructions that could be used to compromise system 100, such as specific memory address requests, or requests that could result in a buffer overrun, etc. Upon validating request 143, security component 155 can initiate JIT compiler 105 in kernel mode.
Once operating in kernel mode, JIT compiler can then be fed the requested code (i.e., 120) and begin compilation. For example,
As will be understood more fully with respect to
In general, one or more kernel layer 103 components of operating system 100 will maintain a memory page table 180 for any given address location and corresponding address spaces. For example,
In any event,
As previously mentioned, one of the ways that system 100 can enforce the permission and security layer boundaries is through memory heap 160, which straddles the described security/permission boundaries. In general, a “memory heap” comprises a set of memory addresses set aside by system 100 during or just prior to runtime. In this particular example, system 100 can allocate and configure memory heap 160 so that only kernel layer components (e.g., JIT compiler 105) can write to memory heap 160 (e.g., via page table 180), while user layer components can only read from memory heap 160. As a result, application program 110 cannot execute any compiled code from JIT compiler 105 in memory heap 160, but, rather, must do so only in address space 175.
One will appreciate, therefore, that a “sandbox” can be set by requiring operation of an application only in user mode, and by requiring the application and JIT compiler to access certain components or data structures from a memory address associated with different permission sets. Accordingly,
As previously mentioned, this type of distributed address space configuration can provide a number of different benefits to program execution and development. At the outset, for example, an application program developer can write virtually any type of code without worrying about safety considerations (e.g., type-safety) In addition, an operating system developer need not speed exhaustive resources developing the runtime verification code that would force all executing program code to be safe (e.g., type-safe).
In addition to the foregoing, implementations of the present invention can also be described in terms of flow charts having one or more acts in a method for accomplishing a particular result. In particular,
Accordingly,
In addition,
Furthermore,
In addition to the foregoing,
In addition,
Furthermore,
Still further,
As such,
The embodiments of the present invention may comprise a special purpose or general-purpose computer including various computer hardware, as discussed in greater detail below. Embodiments within the scope of the present invention also include computer-readable media for carrying or having computer-executable instructions or data structures stored thereon. Such computer-readable media can be any available media that can be accessed by a general purpose or special purpose computer.
By way of example, and not limitation, such computer-readable media can comprise RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store desired program code means in the form of computer-executable instructions or data structures and which can be accessed by a general purpose or special purpose computer. When information is transferred or provided over a network or another communications connection (either hardwired, wireless, or a combination of hardwired or wireless) to a computer, the computer properly views the connection as a computer-readable medium. Thus, any such connection is properly termed a computer-readable medium. Combinations of the above should also be included within the scope of computer-readable media.
Computer-executable instructions comprise, for example, instructions and data which cause a general purpose computer, special purpose computer, or special purpose processing device to perform a certain function or group of functions. Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
The present invention may be embodied in other specific forms without departing from its spirit or essential characteristics. The described embodiments are to be considered in all respects only as illustrative and not restrictive. The scope of the invention is, therefore, indicated by the appended claims rather than by the foregoing description. All changes which come within the meaning and range of equivalency of the claims are to be embraced within their scope.