COMPUTER SYSTEM CONFIGURED TO RUN A COMPUTER PROGRAM
The computer system addresses ROP attack vulnerabilities by duplicating and comparing return addresses and stack pointers, offering a simple, cost-effective, and secure defense mechanism for embedded systems.
Patent Information
- Application Number
- FR2023002932
- Authority / Receiving Office
- FR · FR
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-03-28
- Publication Date
- 2024-10-04
AI Technical Summary
Existing solutions to protect against Return-Oriented Programming (ROP) attacks are either too complex, expensive, or vulnerable to modification by attackers, particularly in embedded systems like microcontrollers.
A computer system with a memory circuit that duplicates the return address and stack pointer values during function calls and returns, comparing these values to ensure integrity, and implements countermeasures if discrepancies are detected, using simple and secure registers or memory to store duplicates.
This approach effectively detects and counters ROP attacks by ensuring the integrity of return addresses and stack pointers, providing a robust and cost-effective defense mechanism for embedded systems.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Title of the invention: COMPUTER SYSTEM CONFIGURED TO EXECUTE A COMPUTER PROGRAM
[0001] Embodiments and implementations relate to computer systems, and more particularly to the execution of programs on such computer systems.
[0002] Computer programs comprise instructions that can be executed by a computer.
[0003] A computer program includes functions (also called "subprograms" or "subroutines"). A function is a sequence of instructions used to perform a specific task. For example, the task of a function may be to perform a given calculation, to write a file to a hard disk, or to communicate with a peripheral, etc.
[0004] In order to use a function, a program is configured to call that function. Calling a function involves executing a branch whose destination memory address is that of the function. A function ends with a branch, which allows the computer to return to the memory address, called the return address, corresponding to the address of the instruction following the function call branch.
[0005] This return address is stored when the function is called so as to be retrieved to perform, at the end of the execution of this function, a return from said function to continue the execution of the program. More particularly, the program uses a call stack (also referred to as the "execution stack") of the computer at each function call. The call stack is used to store the information required to perform the function call: the return address, the arguments / parameters, the backup copy of the processor registers, the local variables, etc.
[0006] Depending on the function being performed, the call stack may be adapted to receive data from outside the computer. For example, the call stack may be used to store data received from a sensor, via UART (Universal Asynchronous Receiver Transmitter) communication, or via Wi-Fi communication.
[0007] It is possible for an attacker to modify this call stack by injecting data from outside the computer to force the computer to execute malicious code. In particular, an advanced exploitation technique of the stack overflow type is known. This technique is designated by the acronym "ROP" for "Return-Oriented Programming". This technique is used by the attacker to gain control of the call stack of a program. by modifying the return address stored in the stack. The attacker uses this modification of the return address to execute a series of instructions located in the executable memory area. These instructions are referred to by the Anglo-Saxon expression "gadget". The attacker can thus assemble several gadgets so that the computer executes unprogrammed operations.
[0008] This technique makes it possible to carry out a denial of service attack, for example, because the computer can no longer execute programs correctly.
[0009] Several known solutions provide more or less robust protection against “ROP” attacks.
[0010] For example, it is possible to duplicate the call stack in order to obtain an additional stack. The additional stack then serves as a reference to check whether the call stack has not been modified undesirably. The additional stack is stored in a random access memory (RAM). This additional stack has the disadvantage of occupying a relatively large space in the random access memory. Thus, the use of such an additional stack may be too costly, in view of its occupation of the random access memory, for embedded systems, such as microcontrollers. This additional stack also has the disadvantage of being complex to implement, whether by software or hardware. In addition, this additional stack has the disadvantage of also being able to be modified by an attacker.
[0011] There is therefore a need to propose a simple and robust solution against “ROP” type attacks.
[0012] According to one aspect, a computer system is proposed - in particular a microcontroller - comprising: - a memory configured to store a computer program product, - a processor configured to execute said computer program product, - a memory circuit, said computer program product comprising instructions which, when the program is executed by said processor, cause the latter to execute at least one function configured to receive data from outside the computer system, said instructions comprising instructions configured to perform a call and a return of said at least one function, the instructions for calling said at least one function comprising an instruction configured to store a return address in a call stack, and at least one additional instruction configured to duplicate said return address in said memory circuit, and the return instructions of said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, and at least one additional instruction configured to compare the value of the return address stored in the call stack to the value of the return address duplicated in said memory circuit and to allow said branch to be performed only if these two values are identical.
[0013] Such a computer system makes it possible to execute a computer program comprising said additional instructions solely for calling and returning said at least one function configured to receive data from outside the computer system.
[0014] In particular, the computer program includes additional instructions for verifying that the value of the return address used to return the function corresponds to the value duplicated in the memory circuit. This ensures that the value of the return address has not been modified during the execution of the function.
[0015] If the value of the return address differs from the value duplicated in the memory circuit, then this may mean that the computer system has undergone the start of a "ROP" type attack during the execution of said function. In this case, the computer system may implement countermeasures to oppose the "ROP" type attack.
[0016] Such a program is therefore configured to prevent an attacker from taking control of a link register or an instruction pointer upon function return.
[0017] Preferably, the memory circuit comprises a register configured to store the duplicated return address. Such a memory circuit has the advantage of having a simple and inexpensive structure for storing the duplicated return address. Furthermore, such a register is difficult to modify by an attacker.
[0018] In an advantageous embodiment, the computer program comprises instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the return address in the call stack is different from the duplicated value of the return address in the memory circuit.
[0019] In this way, the computer program makes it possible to take countermeasures when the value of the return address in the call stack is different from the duplicated value of the return address in the memory circuit, in particular when the computer system is subject to the start of a “ROP” type attack.
[0020] Advantageously, the instructions for calling said at least one function further comprise at least one additional instruction configured to duplicate a value of a call stack pointer (in English “stack pointer”) defined when the return address is added to the call stack. The return instructions of said at least one function comprise at least one additional instruction configured to compare the value of the call stack pointer defined during a retrieval of the return address from the call stack to perform said branch to the value of the call stack pointer duplicated in said memory circuit and to allow said branch to be performed only if these two values are identical.
[0021] The computer program thus includes additional instructions for checking whether the value of the stack pointer when retrieving the return address upon return of the function corresponds to the value duplicated in the memory circuit. This makes it possible to ensure that the stack size has not been modified during the execution of said function.
[0022] If the value of the stack pointer when retrieving the return address differs from the value duplicated in the memory circuit, then this may mean that the computer system is experiencing the beginning of a "ROP" type attack. In this case, the computer system can implement countermeasures to oppose the "ROP" type attack.
[0023] Checking the value of the stack pointer when returning from a function makes it possible to know whether the address of the memory location in the call stack that contains the return address has been modified during the execution of the function. This makes it possible to improve the detection of "ROP" type attacks.
[0024] Preferably, the memory circuit comprises a register configured to store the value of the duplicated stack pointer. Such a memory circuit has the advantage of having a simple and inexpensive structure for storing the value of the duplicated stack pointer. Furthermore, such a register is difficult to modify by an attacker.
[0025] In an advantageous embodiment, the computer program comprises instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicated value of the stack pointer.
[0026] In this way, the computer program can itself take countermeasures when the value of the stack pointer upon return is different from the duplicate value of the stack pointer, in particular when the computer system is subject to the start of a “ROP” type attack. Alternatively, the computer program can generate an exception code. This exception code can then be detected to implement countermeasures.
[0027] According to another aspect, there is provided a computer program product comprising instructions which, when the program is executed by said processor of a computer system as described above, cause it to execute at least one function configured to receive data from outside the computer system, said instructions comprising an instruction configured to perform a call and a return of said at least one function, the instructions for calling said at least one function comprising an instruction configured to store a return address in a call stack, and at least one additional instruction configured to duplicate said return address in said memory circuit of the computer system, and the return instructions of said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, and at least one additional instruction configured to compare the value of the return address stored in the call stack to the value of the return address duplicated in said memory circuit and to allow said branch to be performed only if these two values are identical.
[0028] Preferably, said at least one additional instruction configured to duplicate said return address is configured to store the duplicated return address in a register of said memory circuit.
[0029] In an advantageous embodiment, the computer program product further comprises instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the return address in the call stack is different from the duplicated value of the return address in the memory circuit.
[0030] Advantageously, the call instructions of said at least one function further comprise at least one additional instruction configured to duplicate a value of a call stack pointer defined when the return address is added to the call stack. The return instructions of said at least one function comprise at least one additional instruction configured to compare the value of the call stack pointer defined during a retrieval of the return address from the call stack to perform said branch to the value of the call stack pointer duplicated in said memory circuit and to allow said branch to be performed only if these two values are identical.
[0031] Preferably, said at least one additional instruction configured to duplicate a value of a call stack pointer is configured to store this value in a register of the memory circuit.
[0032] In an advantageous embodiment, the computer program product further includes instructions that allow the execution of the program to be stopped or the return branch to be performed according to the duplicate value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicate value of the stack pointer.
[0033] According to another aspect, there is provided a method implemented by a computer - in particular by a computer system as described previously - comprising an execution of a computer program product as described previously.
[0034] According to another aspect, there is provided a computer-implemented method of generating a computer program, the method comprising generating instructions which, when the program is executed by a processor of a computer system, cause the latter to execute at least one function configured to receive data from outside the computer system, said instructions comprising instructions configured to perform a call and a return from said at least one function, the instructions for calling said at least one function comprising an instruction configured to store a return address in a call stack, the instructions for returning said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, the method also comprising: - an addition of at least one additional instruction for calling said at least one function, said at least one additional call instruction being configured to duplicate said return address in a memory circuit of the computer system for calling said at least one function, - an addition of at least one additional function return instruction, said at least one additional function return instruction being configured to compare the value of the return address stored in the call stack with the value of the return address duplicated in said memory circuit of the computer system and to allow said branch to be made only if these two values are identical.
[0035] Preferably, said at least one additional instruction configured to duplicate said return address is configured to store the duplicated value of the return address in a register of said memory circuit.
[0036] In an advantageous embodiment, the method further comprises an addition of instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the return address in the call stack is different from the value duplicated return address in memory circuit.
[0037] Advantageously, the method further comprises: - an addition of at least one additional instruction for calling said at least one function configured to duplicate a value of a call stack pointer defined when the return address is added to the call stack, and - an addition of at least one additional return instruction from said at least one function configured to compare the value of the call stack pointer defined during a recovery of the return address of the call stack to carry out said connection to the value of the call stack pointer duplicated in said memory circuit and to allow said connection to be carried out only if these two values are identical.
[0038] Preferably, said at least one additional instruction configured to duplicate a value of a call stack pointer is configured to store this value in a register of the memory circuit.
[0039] In an advantageous embodiment, the method further comprises an addition of instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicated value of the stack pointer.
[0040] According to another aspect, there is provided a computer program product comprising instructions which, when the program is executed by a computer, cause the latter to implement a method of generating a computer program as described above.
[0041] Other advantages and characteristics of the invention will appear on examining the detailed description of embodiments, which are in no way limiting, and the appended drawings in which:
[0042] [Fig.l]
[0043] [Fig.2]
[0044] [Fig.3] illustrate embodiments and implementations of the invention.
[0045] [Fig.l] illustrates an embodiment of a computer system SYS. The computer system SYS can be a microcontroller for example.
[0046] The computer system SYS comprises a processor PROC and a memory MEM. The memory MEM is used to store a computer program PRG. The computer program PRG comprises instructions that can be executed by the processor PROC of the computer system SYS.
[0047] When the processor PROC executes the computer program PRG, the processor PROC uses an instruction pointer (in English "instruction pointer" or "program counter"). This instruction pointer is a register that contains the memory address of the instruction currently being executed or soon to be executed depending on the processor architecture. This instruction pointer is incremented as soon as an instruction is loaded into the processor so as to point to the memory address of the next instruction.
[0048] The PRG computer program comprises several functions. In order to be able to execute these functions, the PRG program comprises instructions for making a function call as well as instructions for making a function return.
[0049] The execution of the functions of the PRG computer program uses a call stack. The call stack is notably implemented in a part of a random access memory of the SYS computer system. The call stack is used to store a return address, arguments / parameters, local variables required to execute said function.
[0050] The computer system SYS has a stack pointer. The stack pointer is a register that is used to store the topmost address of the call stack.
[0051] The instructions for making a function call include a branch instruction whose destination address is that of the first instruction of the function. Thus, when a function is called, the value of the instruction pointer is modified so as to point to the memory address of the first instruction of said function.
[0052] The instructions for performing a function call comprise at least one “push” type instruction. This instruction makes it possible to add the value of a register to the call stack. In particular, the instructions for performing a function call comprise a “push{LR]” type instruction making it possible to add the contents of a link register LR to the call stack. The contents of the LR register correspond to a return address for executing the rest of the program once said function has been executed. This “push{LR]” instruction is configured to be executed at the start of a function call.
[0053] The instructions for performing a function return include at least one instruction for restoring a context of the function. The context is a space in the call stack for storing, for example, parameters, a result of the function, the return address and local variables.
[0054] The instructions for performing a function return also include at least one “POP” type instruction. This instruction makes it possible to remove a value from a register in the call stack. In particular, the instructions for performing a function call include a “pop{pc]” type instruction making it possible to retrieve the value of the LR register stored in the stack and corresponding to the return address to put it in the instruction pointer.
[0055] The PRG program also includes additional instructions for making calls to certain functions. These additional instructions are used to protect these functions against stack overflow attacks, in particular ROP attacks (Return-Oriented Programming).
[0056] These additional instructions are used for functions configured to receive data from outside the computer system, in particular from the microcontroller, such as data obtained via a “UART” communication, a Wi-Fi communication, or from a sensor, etc. “ROP” type attacks are initialized during the execution of such functions, by adding data received from outside to the call stack so as to cause a stack overflow.
[0057] The additional instructions are therefore only integrated to execute this type of function. This makes it possible to increase the execution time of the program only when such a function is called. The execution of the other functions of the program does not use these additional instructions.
[0058] In particular, the additional instructions are executed during calls and returns from functions configured to receive data from outside.
[0059] More particularly, the instructions for performing a function call comprise at least one additional instruction for duplicating the return address in a memory circuit CMEM of the computer system SYS.
[0060] The instructions for making a function call also include at least one additional instruction for duplicating in the memory circuit CMEM of the computer system SYS the value of the stack pointer when adding the return address to the stack.
[0061] The memory circuit CMEM may comprise two registers REGI, REG2 of the computer system SYS. A first register REGI is then used to store the duplicated value of the return address defined when the function was called. A second register REG2 is used to store the duplicated value of the stack pointer. This second register REG2 is optional. The registers REGI, REG2 may be registers of the processor PROC. These registers may be additional registers of the processor or initial registers of the processor PROC. The functionality of these initial registers is therefore modified to dedicate them to the storage of the duplicated value of the return address and the duplicated value of the stack pointer. For example, in the case where the processor PROC has an ARM® architecture, it is possible to use the registers R4 and R5.It is also possible to use the R9 register if no position-independent code is used. It is also possible to use floating-point registers. (S0 to S31 for ARM® architecture) if floating point is not used.
[0062] Alternatively, the registers may be registers of a dedicated secure circuit of the computer system (for example having a “TrustZone” type architecture on ARM®).
[0063] Further, a dedicated circuit may also be configured to store multiple duplicate stack pointer values and multiple duplicate return address values, each duplicate stack pointer value being associated with a unique duplicate return address value.
[0064] Alternatively, the memory circuit CMEM comprises a portion of the RAM. This portion of the RAM is then used to store the duplicate value of the stack pointer and the duplicate value of the return address defined during the function call.
[0065] The CMEM memory circuit is configured to receive data only from the LR register or from the stack pointer register. The values stored in the CMEM memory circuit are therefore difficult for an attacker to modify.
[0066] The instructions for performing a function return include additional instructions for comparing the value of the stack pointer when retrieving the return address to the duplicate value of the stack pointer stored in the CMEM memory circuit.
[0067] This comparison makes it possible to verify that the value of the stack pointer has not been modified during the execution of said function. This comparison can be carried out by the processor or by a dedicated circuit.
[0068] The instructions for performing a function return include additional instructions for comparing the value of the return address of the LR register to the duplicate value of the return address stored in the CMEM memory circuit.
[0069] This comparison makes it possible to verify that the value of the return address of the LR register has not been modified during the execution of said function.
[0070] If the value of the stack pointer when retrieving the return address matches the duplicate value of the stack pointer and if the value of the return address of the LR register matches the duplicate value of the return address, then this means that the value of the return address in the call stack has not been modified. In this case, the PRG program is configured to continue execution by performing the function return branch.
[0071] If the value of the stack pointer when retrieving the return address is different from the duplicate value of the stack pointer and / or if the value of the return address of the LR register is different from the duplicate value of the return address, this means that the call stack has been modified in an unwanted way. This modification can be the result of a "ROP" attack or because an attacker has managed to move the stack pointer to a memory area (also known as a "fake stack") controlled by the attacker. Thus, in this case, instructions in the PRG program are configured to be executed in such a way as to take countermeasures. For example, these instructions, when executed, can either stop the execution of the PRG program or replace the value of the return address with the duplicate value of the return address so as to return to the desired return address when the function returns.These instructions can also generate an alert signal to inform the user of the computer system that the call stack has been modified and that the computer system is potentially subject to a "ROP" type attack. Such a computer system SYS is therefore configured to simply detect "ROP" stack overflow attacks. In particular, such a computer system SYS has a simple architecture for storing the duplicate values of the stack pointer and the return address. For example, the computer system SYS uses a CMEM memory circuit simply comprising two registers to store the duplicate values of the stack pointer and the memory address. Alternatively, the use of a dedicated circuit as a CMEM memory circuit makes it possible to perform the monitoring of the values of the stack pointer and the return address in parallel with the execution of the computer program PRG.
[0072] [Fig.2] illustrates a method of executing a PRG program as described above. cededly.
[0073] The method comprises a call 20 of at least one function configured to receive data from outside the computer system SYS executing the PRG program.
[0074] The call 20 of such a function comprises the execution 20a of an instruction of type “push{LR]” making it possible to add to a function call stack the contents of a link register LR (in English “link register”) which corresponds to a return address to execute the rest of the program once said function has been executed.
[0075] In particular, the call 20 also comprises an execution 20b of additional instructions making it possible to duplicate in a memory circuit of the computer system the value of the stack pointer during the function call when the return address is added to the stack, the call 20 also comprises an execution 20c of additional instructions making it possible to duplicate the return address in the memory circuit of the computer system.
[0076] The method then comprises the execution 21 of the instructions of the function.
[0077] The method then comprises a return 22 of the function.
[0078] The return 22 of the function comprises an execution 22a of at least one instruction making it possible to restore a context of the function. The context is a space in the call stack making it possible to store, for example, parameters, a result of the function, the return address and local variables.
[0079] The return 22 of the function also includes an execution 22b of instructions making it possible to compare the value of the stack pointer when retrieving the return address to the duplicate value of the stack pointer and to compare the value of the return address of the LR register to the duplicate value of the return address
[0080] If the value of the stack pointer when retrieving the return address corresponds to the duplicate value of the stack pointer and if the value of the return address of the LR register corresponds to the duplicate value of the return address, then the return of the function includes the execution 22c of a “pop{pc]” instruction making it possible to retrieve the value of the LR register stored in the stack and corresponding to the return address to put it in the instruction pointer so as to exit the function and execute the rest of the program.
[0081] If the value of the stack pointer when retrieving the return address is different from the duplicate value of the stack pointer and / or if the value of the return address of the LR register is different from the duplicate value of the return address, then the method comprises executing 23 instructions configured to be executed so as to take countermeasures, described previously.
[0082] [Fig. 3] illustrates a computer-implemented method of generating a PRG computer program as described above. In particular, a compilation computer program may comprise instructions which, when executed by a computer, cause the computer to implement such a PRG computer program generation method.
[0083] Such a method can be implemented during a compilation of a source code so as to obtain said program. The source code makes it possible to define the different functions of the program. At least one function of the program defined in the source code is configured to receive data coming from outside the computer system intended to execute the program.
[0084] The source code is configured to signal each function of the program adapted to receive data from the outside.
[0085] In particular, to identify such a function, the source code may include a tag placed at the beginning of this function. This tag may be inserted by the person who wrote the source code. A tag may consist of a succession of characters.
[0086] The method for generating the computer program comprises a transformation 30 by a compiler of the source code into a sequence of instructions executable by the computer system. This sequence of instructions is therefore generated by the com- stacker from source code.
[0087] In particular, the method for generating the computer program PRG comprises a detection 31, by the compiler, of each function of the program configured to receive data from the outside. This detection can be carried out by detecting the tag in the source code which identifies such a function.
[0088] Then, for each detected function configured to receive data from the outside, the method comprises an addition 32, by the compiler, of additional instructions to be executed when calling and returning said function. These additional instructions can therefore only be added for the functions identified by said tag in the source code. These additional instructions are therefore generated without intervention by a developer.
[0089] As seen previously, these additional instructions serve to protect these functions against stack overflow attacks, in particular "ROP" attacks (Return-Oriented Programming).
[0090] In particular, the additional instructions added for calling the function make it possible to duplicate, in a memory circuit of the computer system intended to execute the program, the return address in this memory circuit of the computer system. These additional instructions also make it possible to duplicate in this memory circuit of the computer system the value of the stack pointer when adding the return address to the stack.
[0091] The additional instructions added for function return include additional instructions for comparing the value of the return address of the LR register with the duplicate value of the return address stored in the CMEM memory circuit. This comparison makes it possible to verify that the value of the return address of the LR register has not been modified during the execution of said function. As seen previously, these additional instructions also include instructions for taking countermeasures if the value of the stack pointer when retrieving the return address is different from the duplicate value of the stack pointer and / or if the value of the return address of the LR register is different from the duplicate value of the return address.
Claims
Claims
1. A computer system comprising: - a memory (MEM) configured to store a computer program product (PRG), - a processor (PROC) configured to execute said computer program product, - a memory circuit (CMEM), said computer program product (PRG) comprising instructions which, when the program is executed by said processor (PROC), cause the latter to execute at least one function configured to receive data from outside the computer system, said instructions comprising instructions configured to perform a call and a return from said at least one function, the instructions for calling said at least one function comprising an instruction configured to store a return address in a call stack, and at least one additional instruction configured to duplicate said return address in said memory circuit (CMEM),and the return instructions of said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, and at least one additional instruction configured to compare the value of the return address stored in the call stack with the value of the return address duplicated in said memory circuit (CMEM) and to allow said branch to be performed only if these two values are identical.,
2. A computer system according to claim 1, wherein the memory circuit (CMEM) comprises a register (REGI) configured to store the duplicated return address.
3. A computer system according to any one of claims 1 or 2 wherein the computer program (PRG) comprises instructions which make it possible to stop the execution of the program or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the return address in the call stack is different from the value duplicated return address in memory circuit.
4. Computer system according to one of claims 1 to 3 wherein the call instructions of said at least one function further comprise at least one additional instruction configured to duplicate a value of a call stack pointer defined when the return address is added to the call stack, and wherein the return instructions of said at least one function comprise at least one additional instruction configured to compare the value of the call stack pointer defined during a retrieval of the return address from the call stack to carry out said branch to the value of the call stack pointer duplicated in said memory circuit (CMEM) and to allow said branch to be carried out only if these two values are identical.
5. Computer system according to claim 4 wherein the memory circuit (CMEM) comprises a register (REG2) configured to store the value of the duplicated stack pointer.
6. A computer system according to any one of claims 4 or 5 wherein the computer program (PRG) comprises instructions which make it possible to stop the execution of the program or to perform the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicated value of the stack pointer.
7. Computer program product comprising instructions which, when the program is executed by said processor (PROC) of a computer system (SYS) according to one of claims 1 to 6, cause the latter to execute at least one function configured to receive data from outside the computer system (SYS), said instructions comprising instructions configured to perform a call and a return of said at least one function, the call instructions of said at least one function comprising an instruction configured to store a return address in a call stack, and at least one additional instruction configured to duplicate said return address in said memory circuit (CMEM) of the computer system (SYS), and the return instructions of said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, and at least one additional instruction configured to compare the value of the return address stored in the call stack with the value of the return address duplicated in said memory circuit (CMEM) and to allow said branch to be performed only if these two values are identical.
8. Computer program product according to claim 7, wherein said at least one additional instruction configured to duplicate said return address is configured to store the duplicated value of the return address in a register (REGI) of said memory circuit (CMEM).
9. A computer program product according to any one of claims 7 or 8, further comprising instructions which make it possible to stop the execution of the program (PRG) or to carry out the return branch according to the duplicated value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the return address in the call stack is different from the duplicated value of the return address in the memory circuit.
10. Computer program product according to one of claims 7 to 9, wherein the call instructions of said at least one function further comprise at least one additional instruction configured to duplicate a value of a call stack pointer defined when the return address is added to the call stack, and wherein the return instructions of said at least one function comprise at least one additional instruction configured to compare the value of the call stack pointer defined during a retrieval of the return address from the call stack to perform said branch to the value of the call stack pointer duplicated in said memory circuit (CMEM) and to allow said branch to be performed only if these two values are identical.
11. Computer program product according to claim 10, wherein said at least one additional instruction configured to duplicate a value of a call stack pointer is configured to store this value in a register (REG2) of the memory circuit (CMEM).
12. A computer program product according to any one of claims 10 or 11, further comprising instructions which allow the execution of the program to be stopped or the branching of return according to the duplicate value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicate value of the stack pointer.
13. A computer-implemented method comprising executing a computer program product according to one of claims 7 to 12.
14. A computer-implemented method for generating a computer program (PRG), the method comprising generating instructions which, when the program is executed by a processor of a computer system, cause the latter to execute at least one function configured to receive data from outside the computer system, said instructions comprising instructions configured to perform a call and a return from said at least one function, the instructions for calling said at least one function comprising an instruction configured to store a return address in a call stack, the instructions for returning said at least one function comprising an instruction configured to perform a branch from the return address stored in the call stack, the method also comprising: - adding at least one additional instruction for calling said at least one function,said at least one additional call instruction being configured to duplicate said return address in a memory circuit of the computer system for calling said at least one function, - an addition of at least one additional function return instruction, said at least one additional function return instruction being configured to compare the value of the return address stored in the call stack with the value of the return address duplicated in said memory circuit (CMEM) of the computer system (SYS) and to allow said connection to be carried out only if these two values are identical.,
15. The method of claim 14, wherein said at least one additional instruction configured to duplicate said return address is configured to store the duplicated value of the return address in a register (REGI) of said memory circuit (CMEM).
16. Method according to one of claims 14 or 15, further comprising an addition of instructions which make it possible to stop the execution of the program or to carry out the return branch according to the value duplicated return address if execution of said at least one additional function return instruction detects that the value of the return address in the call stack is different from the duplicated value of the return address in the memory circuit.
17. Method according to claim 14 to 16, further comprising: - an addition of at least one additional instruction for calling said at least one function configured to duplicate a value of a call stack pointer defined when the return address is added to the call stack, and - an addition of at least one additional instruction for returning said at least one function configured to compare the value of the call stack pointer defined during a retrieval of the return address from the call stack to carry out said branch to the value of the call stack pointer duplicated in said memory circuit (CMEM) and to allow said branch to be carried out only if these two values are identical.
18. Method according to claim 17 wherein said at least one additional instruction configured to duplicate a value of a call stack pointer is configured to store this value in a register (REG2) of the memory circuit (CMEM).
19. A method according to any one of claims 17 or 18, further comprising adding instructions that allow the execution of the program (PRG) to be stopped or the return branch to be performed according to the duplicate value of the return address if the execution of said at least one additional function return instruction makes it possible to detect that the value of the stack pointer upon return is different from the duplicate value of the stack pointer.
20. Computer program product comprising instructions which, when the program is executed by a computer, cause the latter to implement a method according to one of claims 14 to 19.
Citation Information
Patent Citations
Processors, methods, systems, and instructions to protect shadow stacks
US20160381050A1
Hardware apparatuses and methods to switch shadow stack pointers
WO2017112232A1
