This application claims priority of China application No. 202210942345.3, filed on Aug. 8, 2022, which is incorporated by reference in its entirety.
The present disclosure relates to computing device and, more particularly, to a computing device capable of detecting return-oriented programming attacks.
In general, when a program code executed by a computing device has to call another program or jump to another program, the computing device will store, from the bottom of a call stack, input parameters of the new program and a return address that the computing device should return to once the new program is completed. Furthermore, the computing device will further reserve storage space in the call stack for data required by the computation of the new program. Since the computing device will sequentially use the storage spaces of the call stack from top to bottom for storing the data generated or received during the execution of the new program, the return addresses might be overlapped by other data if the computing device does not perform check the boundary condition while storing the data to the call stack. In such case, after executing the new program, the computing device will not be able to go back to the initial program, and may even end up entering a wrong code segment, which causes system failure.
Return-oriented programming (ROP) is an attack technique that controls the computing device to execute malicious code by overwriting the return addresses stored in the call stack. To resist return-oriented programming attacks, prior art entails backing up return addresses when compiling the program code, and detecting the return-oriented programming attack by checking if the return address in the call stack is identical to the return address backed up when reading the return addresses from the call stack. However, compilation of the program code is mostly related to the operating system (OS) of the computing device, and thus, not only involves plenty modifications but also fails to protect low-level function libraries. Therefore, it is imperative to provide a computing device capable of effectively detecting return-oriented programming attacks.
One embodiment of the present disclosure discloses a computing device. The computing device includes at least one storage block, a processor, and an access detection unit. The processor is configured to execute a program and comprising a load/store unit, wherein, when the processor exits the program and enters another program, the load/store unit stores a return address that the processor should return to after the another process finishes to the at least one storage block. The access detection unit includes a store-once stack, and a comparison logic circuit. The store-once stack is configured to store a storage address of the return address in the at least one storage block when the at least one storage block stores the return address. The comparison logic circuit is configured to, before the load/store unit performs a storage operation on the at least one storage block to store a value, compare a write address of the storage operation with at least one storage addresses of at least one return address stored in the store-once stack to determine whether the storage operation is about to modify the at least one return address, and, upon an affirmative determination, and issue an error-alert signal to prevent the load/store unit from performing the storage operation and storing the value to the write address of the at least one storage block.
Another embodiment of the present disclosure discloses a method for a computing device. The computing device includes at least one storage block and a store-once stack. The method includes: storing, upon completion of a program and ensuing commencement of execution of another program, a return address of the another program to the at least one storage block; storing, when at least one storage block stores the return address, a storage address of the return address in the at least one storage block to the store-once stack; executing the another program; comparing, prior to performing a storage operation on the at least one storage block to push in a value, a write address of the at least one storage block with at least one storage address of at least one return address stored in the store-once stack to determine whether the storage operation is about to modify the at least one return address; and issuing, upon an affirmative determination, an error-alert signal to prevent the value from being stored to the write address of the at least one storage block.
The computing devices and the methods for the computing device, as provided by the present disclosure, are effective in storing a storage address of a return address in a call stack to a store-once stack when storing a return address of a program to the call stack, effective in determining, in the course of execution of the program with a comparison logic circuit, whether a storage operation performed on the call stack will modify the return address, and thus effective in detecting return-oriented programming attacks and precluding modification of the return address in the call stack.
Persons skilled in the art can better understand various aspects of the disclosure by referring to the accompanying drawings and embodiments of the disclosure. In view of conventional standards and practice, the accompanying drawings are not drawn to scale. In fact, for the sake of illustration, the drawing scale of the accompanying drawings is adjustable as needed.
The following disclosure provides various different embodiments or examples for implementing different features of the present disclosure. Specific examples of components and arrangements are described below to simplify the present disclosure. These are, of course, merely examples and are not intended to be limiting. For example, the formation of a first feature over or on a second feature in the description that follows may include embodiments in which the first and second features are formed in direct contact and may also include embodiments in which additional features may be formed between the first and second features, such that the first and second features may not be in direct contact. In addition, the present disclosure may repeat reference numerals and/or letters in the various embodiments. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed.
Notwithstanding that the numerical ranges and parameters setting forth the broad scope of the invention are approximations, the numerical values set forth in the specific examples are reported as precisely as possible. Any numerical value, however, inherently contains certain errors necessarily resulting from the standard deviation found in the respective testing measurements. Also, as used herein, the term “about” generally means within 10%, 5%, 1%, or 0.5% of a given value or range. Alternatively, the term “generally” means within an acceptable standard error of the mean when considered by one of ordinary skill in the art. As could be appreciated, other than in the operating/working examples, or unless otherwise expressly specified, all of the numerical ranges, amounts, values, and percentages (such as those for quantities of materials, duration of times, temperatures, operating conditions, portions of amounts, and the likes) disclosed herein should be understood as modified in all instances by the term “generally.” Accordingly, unless indicated to the contrary, the numerical parameters set forth in the present disclosure and attached claims are approximations that can vary as desired. At the very least, each numerical parameter should at least be construed in light of the number of reported significant digits and by applying ordinary rounding techniques. Here, ranges can be expressed herein as from one endpoint to another endpoint or between two endpoints. All ranges disclosed herein are inclusive of the endpoints, unless specified otherwise.
Furthermore, in the present embodiment, the computing device 100 stores a storage address ARA1 in the storage block 120 where the return address RA1 is stored to a store-once stack 132. Thus, in the subsequent course of execution of the new program by the processor 110, whenever the load/store unit 112 has to perform a storage operation on the storage block 120 to store new data therein, the comparison logic circuit 134 would compare the write address of the storage operation with the storage address ARA1 in the store-once stack 132 and determine whether the storage operation to be performed on the storage block 120 will modify the return address RA1 stored in the storage block 120 and thus determines whether to permit such storage operation. As a result, the return address RA1 can be protected from being overwritten, thereby protecting the computing device 100 from being compelled to execute malware and causing information security breaches or system damage.
In some embodiments, the computing device 100 may include a memory (not shown in
In order to protect the return address RA1 from being overwritten, in step S120, when the return address RA1 is stored to the storage block 120, the computing device 100 can further store the storage address ARA1 of the return address RA1 in the storage block 120 to the store-once stack 132, so as to serve as a basis for determining whether the return address RA1 will be overwritten in the future operations.
In step S130, the processor 110 begins to execute a new program. When the processor 110 needs to store data to the storage block 120 in the course of execution of the new program, the processor 110 may perform steps S140 and S150 to determine whether such storage operation will modify the return address RA1 and, upon a negative determination, perform the storage operation to store the data to the storage block 120.
As shown in
In step S150, when it is determined that the value of return address RA1 is about to be modified, it may imply that the return-oriented programming attack is detected. At this point, step S160 can be performed to issue an error-alert signal and stop pushing the value V1 in write address WADD of the storage block 120. However, if in step S150 it is determined that the value of the return address RA1 is unlikely to be modified, step S170 will be carried out to store the value V1 to the write address WADD of the storage block 120, thereby finishing the storage operation.
However, it is possible that the return address RA1 does not take up the whole storage space corresponding to storage address ARA1. For instance, the storage address ARA1 may be corresponding to a storage space for storing 32 bits of data, but the data of return address RA1 includes only 16 bits in length. In such case, if the data length of the value V1 is also 16 bits, while the return address RA1 is stored to the lower 16 bits, then it is feasible to store the value V1 in the higher 16 bits in the storage address ARA1 without modifying the return address RA1. Thus, when the write address WADD and the storage address ARA1 are identical, it is feasible to further compare a valid bit mask MSK_V1 of the value V1 with a valid bit mask MSK_RA1 of the return address RA1 to determine whether they are identical and thus further confirm whether they correspond to the same bit in the same address, so as to confirm whether allowing the value V1 to be pushed in the storage block 120 will lead to overwriting the contents of return address RA1.
For instance, the method M1 may not only entail storing the storage address ARA1 of the return address RA1 to the store-once stack 132 in step S120, but also entail storing the valid bit mask MSK_RA1 that corresponds to the return address RA1 to the store-once stack 132. Thus, the method M1 can not only entail comparing the write address WADD with the storage address ARA1 in step S140, but also entail comparing the valid bit mask MSK_V1 of the value V1 and the valid bit mask MSK_RA1 of the return address RA1 with the comparison logic circuit 134, thereby allowing step S150 to determine whether the storage operation is about to modify return address RA1 even more precisely.
As shown in
Then, the logic AND gates AND1˜ANDN can perform logic AND operations on output values of the comparators CMP1˜CMPN and output values of the comparators CMP1‘˜CMPN’, and the logic OR gate OR1 can perform a logic OR operation on output values of the logic AND gates AND1‘˜ANDN’, thereby outputting an overwrite determination signal SIGOVW.
In the present embodiment, when any one of the storage addresses ARA1˜ARAN is identical to the write address WADD, and the valid bit mask of the return address corresponding to the storage address identical to the write address WADD is identical to valid bit mask MSK_V1 of value V1, the comparison logic circuit 134 can output the overwrite determination signal SIGOVW with a value of 1, indicating that the comparison logic circuit 134 determines that the storage operation to execute is about to cause modification of the return address stored in the storage block 120. By contrast, if the write address WADD is identical to none of the storage addresses ARA1˜ARAN, it means that the storage operation to be performed will not cause modification of the return address stored in the storage block 120, and thus the comparison logic circuit 134 can output overwrite determination signal SIGOVW with a value of 0.
Furthermore, if the write address WADD is identical to one of storage addresses ARA1˜ARAN but there is mutual exclusion between the valid bit mask of the return address corresponding to the storage address identical to write address WADD and the valid bit mask MSK_V1 of the value V1, it may imply that both the value V1 and the return address RA1 can be stored to the same storage address ARA1 while the value V1 will not overwrite the value of the return address RA1. Therefore, the storage operation to be performed will not cause modification of the return address stored in the storage block 120. In such case, the comparison logic circuit 134 can output the overwrite determination signal SIGOVW with a value of 0 to indicate that the comparison logic circuit 134 determines that the storage operation to be performed will not cause modification of the return address of the storage block 120.
Since the computing device 100 can use the hardware of the comparison logic circuit 134 to detect whether the return address will be modified, it can effectively detect the return-oriented programming attacks and protect the return addresses from being modified without making great changes to operating systems.
In the embodiment illustrated by
Furthermore, in the computing device 100 shown in
As shown in
In step S120, when the reorder buffer 214 commits a storage instruction for storing the return address RA1 to the storage block 220A, the reorder buffer 214 can send the storage instruction ID RID1 to the load/store unit 212 so as to allow the load/store unit 212 to accordingly send the storage address ARA1 of the return address RA1 involved in the storage instruction to the store-once stack 232 via the storage pipeline SP1. Furthermore, when committing the storage instruction, the reorder buffer 214 can further determine whether the storage address ARA1 of return address RA1 corresponds to a pointer of the call stack, i.e., the storage block 220A. If the storage address ARA1 of the return address RA1 is corresponding to the pointer of the call stack, it means that the return address is corresponding to a function call instruction, and the reorder buffer 214 would issue a first-type storage request RQS1 to the store-once stack 232, such that the store-once stack 232 can store a first-type bit TB1 along with the storage address ARA1 and, thereby indicating that the storage address ARA1 corresponds to the call stack.
Furthermore, in the present embodiment, when committing the storage instruction, the reorder buffer 214 can further have the load/store unit 212 send the storage address ARA1 and the valid bit mask MSK_RA1 that are corresponding to the return address RA1 to the store-once stack 232 via the storage pipeline SP1. As a result, in steps S140 and S150, the comparison logic circuit 234 can read the storage addresses ARA1˜ARAN of the return addresses RA1˜RAN and the valid bit masks MSK_RA1˜MSK_RAN from the store-once stack 232 for according comparison and determination.
Furthermore, owing to the preceding operation, the store-once stack 232 may store both a return address that corresponds to a call stack and a return address that corresponds to a buffer block, therefore, in the embodiment illustrated by
In the present embodiment, if the comparison logic circuit 234 determines that the storage operation will modify return address RA1, it can issue the error-alert signal SIGOVW via the detection pipeline FP1, so as to preclude pushing the value V1 into the storage address ARA1 of the return address RA1. Furthermore, in some embodiments, to provide the system with more error-detecting information, the load/store unit 212 may send the write address WADD and the valid bit mask MSK_V1 to the access detection unit 230 together with the instruction ID RID2 of the storage operation. Thus, the comparison logic circuit 234 can not only issue the error-alert signal SIGOVW to the reorder buffer 214 but also issue the instruction ID RID2 to the reorder buffer 214, allowing the reorder buffer 214 to identify the instruction caused error and perform a corresponding error-tackling procedure.
Furthermore, owing to the preceding operation, the store-once stack 232 may have stored a return address corresponding to a call stack and a return address corresponding to a buffer block, therefore, in the embodiment illustrated by
In the present embodiment, if the comparison logic circuit 234 determines that the storage operation will modify the return address RA2, it can issue the error-alert signal SIGOVW via the detection pipeline FP1, so as to preclude pushing the value V2 into the storage address ARA2 of the return address RA2. Furthermore, in some embodiments, to further provide the system with more error-detecting information, the load/store unit 212 can not only send the write address WADD2 and the valid bit mask MSK_V2 to the access detection unit 230, but also send the instruction ID RID4 of the current storage operation to the access detection unit 230. As a result, when the comparison logic circuit 234 issues the error-alert signal SIGOVW to the reorder buffer 214, it can also issue the instruction ID RID4 to the reorder buffer 214, allowing the reorder buffer 214 to identify the instruction that caused error and execute a corresponding error-tackling procedure.
Upon completion of the execution of the new program, the reorder buffer 214 can control the load/store unit 212 to read the return address RA1 from the storage block 220A or read the return address RA2 from the storage block 220B and prepare for their return to the origin program. In such case, the storage addresses ARA1 and ARA2 of return addresses RA1 and RA2 stored in the store-once stack 232 will become invalid, therefore, to manage the storage space of the store-once stack 232 efficiently, the store-once stack 232 can pop the return addresses RA1 and ARA2 when the return addresses RA1, ARA2 are read, respectively and correspondingly. However, the store-once stack 232 can manage the storage space of the store-once stack 232 in different ways, depending on the type of the initial instruction that triggers the new program.
For instance, the reorder buffer 214 can issue the first-type release request to have the store-once stack 232 pop the storage address ARA1 upon satisfaction of two criteria: the reorder buffer 214 commits a load instruction for reading the return address RA1 from the storage block 220A; and the read address of the load instruction corresponds to the pointer of the call stack. By contrast, if the read address of the load instruction does not correspond to the pointer of the call stack when the reorder buffer 214 commits a load instruction for reading return address RA2 from the storage block 220B, indicating that return address RA2 may correspond to the return address of a jump instruction. Upon the return of the jump instruction, all the storage addresses in the store-once stack 232 will become invalid. Thus, the reorder buffer 214 can issue a second-type release request to have the store-once stack 232 to pop all the storage addresses therein.
Furthermore, in some embodiments, the processor 210 may interrupt the execution of the current program according to the system requirement, and the access detection unit 230 may temporarily transfer the data stored in the store-once stack 232 to another storage space of the memory, allowing the access detection unit 230 to restore the store-once stack 232 with the temporarily-stored data when execution of the otherwise interrupted program resumes.
In summary, the computing devices and the methods for the computing device, as provided by the present disclosure, are effective in storing a storage address of a return address in a call stack to a store-once stack when storing a return address of a program to the call stack, effective in determining, in the course of execution of the program with a comparison logic circuit, whether a storage operation performed on the call stack will modify the return address, and thus effective in detecting return-oriented programming attacks and precluding modification of the return address in the call stack. Furthermore, a store-once stack mechanism of the disclosure can also protect the return address stored in a buffer block of a jump instruction and thereby provide a better protection to the system.
The foregoing description briefly sets forth the features of certain embodiments of the present application so that persons having ordinary skill in the art more fully understand the various aspects of the disclosure of the present application. It will be apparent to those having ordinary skill in the art that they can easily use the disclosure of the present application as a basis for designing or modifying other processes and structures to achieve the same purposes and/or benefits as the embodiments herein. It should be understood by those having ordinary skill in the art that these equivalent implementations still fall within the spirit and scope of the disclosure of the present application and that they may be subject to various variations, substitutions, and alterations without departing from the spirit and scope of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
202210942345.3 | Aug 2022 | CN | national |