A computer system having a memory protection function according to the present invention (referred to as the “system of the present invention” hereinafter) will be described with reference to the drawings hereinafter.
In addition, according to this embodiment, it is assumed that in the memory area 19, a program code area to store a program code and a fixed data area to store fixed data are formed in the ROM 11 and the nonvolatile memory 13 and a stack area to store dynamic data and another heap area in the memory area to be used in executing the program are formed in the RAM 12 in which data can be read and programmed at high speed.
The memory map circuit 15 comprises a RAM or a register and stores an access control memory map which defines whether the CPU 10 has an access right for executing the program (referred to as the “execution right” occasionally hereinafter) with respect to each address of the memory area 19 or not, and outputs the information of the access control memory map to the access right determination circuit 16. According to this embodiment, since the input/output of the memory map circuit 15 is separated from the data bus 17 and they are not connected directly, the contents of the access control memory map are prevented from being altered carelessly or illegally by the execution of the program by the CPU 10.
The access right determination circuit 16 determines whether there is the execution right to the memory area 19 specified by an execution program storage address Spc designated by the value of a program counter 20 in the CPU 10 or not with respect to each execution program storage address.
By the access prohibition signal SC, the CPU 10 accesses an address area in the memory area 19 specified by the execution program storage address Spc designated by the value of the program counter 20 and executes a process in which an illegal program stored in the address area is prevented from being executed as will be described below. As a result, in the whole address area of the memory area 19, the program illegally programmed in the non-executable address range specified by the access control memory map stored in the memory map circuit 15 cannot be executed, so that secret data stored in the memory area 19 is prevented from being erased, altered, or leaked by the execution of the illegal program.
Furthermore, according to this system 1 in the present invention, as shown in
Next, a description will be made of one example of a protective operation of the system 1 of the present invention when a buffer overflow attack occurs as shown in
#13: The operations when the buffer overflow attack occurs are the same as #6 to #8 shown in
#14: The CPU 10 tries to move the control to the malicious illegal program buried in the stack area set in the non-executable address range by an altered return address. Here, the access right determination circuit 16 detects that the execution program storage address Spc designated by the value of the program counter 20 exists in the non-executable address range of the access control memory map stored in the memory map circuit 15, and the access prohibition signal SC is enabled.
#15: When the access prohibition signal SC is enabled, the execution of the illegal program is detected and when the access prohibition signal SC is used as an interruption request signal to the CPU 10, an interruption process is started in the CPU 10. In this interruption process, internal secret data is prevented from being erased, altered, or leaked by the malicious, illegal program, by performing an appropriate operation such as clear (data erase) of the stack area.
Here, when data in the heap area is written beyond the stack area previously set as shown in #12 in
However, since the designated value of the stack pointer is moved in the heap area by data programming beyond the stack area, the upper limit address signal SA1 showing the upper limit of the non-executable address range is also moved in the heap area and the execution right of the heap area eroded by the buffer overflow attack is changed from its original effective state to an ineffective state. Therefore, similar to the case of the #14, the access right determination circuit 16 detects that the execution program storage address Spc designated by the value of the program counter 20 is in the non-executable address range of the access control memory map stored in the memory map circuit 15, and the access prohibition signal SC is enabled. Then, the interrupting operation at the #15 is performed and the malicious illegal program buried in the heap area becomes non-executable and the internal secret data is prevented from being erased, changed or leaked.
In addition, by separating the address ranges of the stack area and the heap area set in the RAM 12 so as not to be continuous, more specifically by setting the address range of the interface between the stack area and the heap area to the address range of the ROM 11 or the nonvolatile memory 13, the heap area is prevented from being eroded by the buffer overflow attack, which is effective in protecting the area from the buffer overflow attack.
Next, another example of the protective operation in the system 1 of the present invention in the case where the buffer overflow attack occurs as shown in
#16: The operations when the buffer overflow attack occurs are the same operations as those #6 to #8 shown in
#17: The CPU 10 tries to move the control to the malicious illegal program buried in the stack area set in the non-executable address range by the altered return address. Here, the access right determination circuit 16 detects that the execution program storage address Spc designated by the value of the program counter 20 is in the non-executable address range of the access control memory map stored in the memory map circuit 15, and the access prohibition signal SC is enabled (similar to the #14 in the example 1).
#18: When the access prohibition signal SC is enabled, the execution of the illegal program is detected and when the access prohibition signal SC is used as a reset request signal to the CPU 10, the reset process is started in the CPU 10 and the CPU 10 restarts. When the CPU 10 restarts, the malicious illegal program is further surely prevented from being executed.
Here, in the case where the data has been written in the heap area beyond the previously set stack area as shown in the #12 in
However, since the value designated by the stack pointer is moved to the heap area by data writing beyond the stack area, the upper limit address signal SA1 designating the upper limit of the non-executable address range is also moved into the heap area and the execution right of the heap area eroded by the buffer overflow attack is changed from the original effective state to an ineffective state. Therefore, similar to the case of the #17 (#14), the access right determination circuit 16 detects that the execution program storage address Spc designated by the value of the program counter 20 exists in the non-executable address range of the access control memory map stored in the memory map circuit 15, and the access prohibition signal SC is enabled. Thus, the reset operation of the above #18 is performed and the malicious illegal program buried in the heap area cannot be executed and the internal secret data can be prevented from being erased, altered or leaked.
According to the first embodiment, the memory map circuit 15 comprises the RAM or the register, the non-executable address range defined by the access control memory map stored therein can vary physically and according to the constitution example shown in
According to the second embodiment, an access control memory map is stored in a memory map circuit 15 such that it cannot be written by a hardware or software operation. Since the access control memory map cannot be written, the circuit constitution of the memory map circuit 15 can be simplified as compared with the first embodiment. In addition, the whole constitution of the system 1 of the present invention is the same as that shown in
When the memory map circuit 15 comprises a ROM, although the non-executable address range is already fixed before shipment and cannot be changed after shipment, when the memory map circuit 15 comprises a RAM or a register, it can be set by the CPU 10 from the side of a tester together with a shipment test after manufacturing or according to a special program (stored in a nonvolatile memory 13 and the like). In the case of the latter, the executable range after manufacturing can be set with any means as long as there is no risk of altering the set contents by erasing the program after setting and the like.
According to the second embodiment, when the non-executable address range is fixed, the non-executable address range can be used as a perfect data only area by previously ensuring a storage area for secret information such as private information and setting the storage area to an area having absolutely no execution right.
Furthermore, when the function of the memory map circuit 15 in the first embodiment and the function of the memory map circuit 15 in the second embodiment are combined, that is, when the fixed non-executable address range and variable non-executable address range are combined, the malicious illegal program can be surely prevented from being executed.
Next, a variation of the system 1 according to the first or second embodiment of the present invention will be described.
Next, another embodiment of the system of the present invention will be described hereinafter.
(1) Although it is assumed that the address range of the stack area expands in the upper address direction according to the writing of the data and the value of the stack pointer 22 is used as the upper address signal SA1 designating the upper limit of the non-executable address range in the first embodiment, when the address range of the stack area expands in a lower address direction, the value of the stack pointer 22 may be used as the lower limit address signal SA2 designating the lower limit of the non-executable address range.
(2) Although the constitutions shown in
(3) Although the memory map circuit 15 is provided separately in
(4) Although the IC card has been described as the variation of the system 1 of the present invention in the third embodiment, the variation of the system 1 of the present invention is not limited to the IC card.
The computer system according to the present invention can be applied to a computer system requiring access control in which secret data stored in a memory area is prevented from being erased, altered or leaked due to carelessness of a user or illegal usage.
Although the present invention has been described in terms of the preferred embodiment, it will be appreciated that various modifications and alternations might be made by those skilled in the art without departing from the spirit and scope of the invention. The invention should therefore be measured in terms of the claims which follow.
Number | Date | Country | Kind |
---|---|---|---|
2006-133949 | May 2006 | JP | national |