Memory management method for security, and electronic device therefor

The software-based memory management method in electronic devices generates and encrypts random keys to secure return addresses, effectively preventing malicious attacks and ensuring secure function execution, addressing the limitations of hardware-based solutions.

WO2025005502A1PCT designated stage expired Publication Date: 2025-01-02SAMSUNG ELECTRONICS CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/KR2024/007372
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-04
Filing Date
2024-05-30
Publication Date
2025-01-02

Smart Images

  • Figure KR2024007372_02012025_PF_FP_ABST
    Figure KR2024007372_02012025_PF_FP_ABST
Patent Text Reader

Abstract

An electronic device according to one embodiment of the present invention comprises at least one processor and a memory connected to the at least one processor. The memory can store instructions that, when executed by the at least one processor, cause the electronic device to: generate a random key when a first program is executed; store the generated random key in a register included in the at least one processor; perform a first function included in the first program; store, in the memory, a first return address for the first function in response to a second function being called from the first function; store, in the register, a first key value generated by randomizing, through the first return address, a random key stored in the register; store, in the memory, a second return address generated by encrypting the first return address with the first key value; perform the second function; decrypt the second return address; and, when the decrypted second return address is the same as the first return address, restore the first key value to the first return address so as to store the restored first key value in the register; and terminate the second function and return to the first function.
Need to check novelty before this filing date? Find Prior Art

Description

Memory management method for security and electronic device therefor

[0001] Various embodiments relate to a memory management method for security and an electronic device therefor.

[0002] The variety of services and additional features offered through electronic devices, such as smartphones, is steadily increasing. To enhance the utility of these devices and satisfy the diverse needs of users, telecommunications service providers and electronic device manufacturers are competitively developing electronic devices that offer diverse features and differentiate themselves from competitors. Consequently, the various functions offered through electronic devices are also becoming increasingly sophisticated. While users of these devices have access to a variety of services, this also raises various security issues.

[0003] Electronic devices can execute applications and system processes based on software instructions stored in memory. However, these processes can be maliciously modified by external attacks. For example, if an application containing malicious code inserted by an attacker is executed, the malicious code may corrupt data in memory or alter the stack pointer or return address, potentially leading to the execution of unintended software instructions.

[0004] For example, return-oriented programming (ROP) can be exploited by attackers to gain control over computer systems or other electronic devices, and by manipulating the return address, the system can be prevented from operating normally and perform actions desired by the attacker, and jump-oriented programming (JOP) can control the flow of the program as desired by manipulating the jump address instead of the return address.

[0005] Although various methods have been proposed to prevent such attacks from attackers in hardware, memory security techniques to prevent them in software may be necessary.

[0006] According to various embodiments of the present disclosure, a software memory management method and an electronic device therefor are provided.

[0007] The technical problems to be achieved in the present disclosure are not limited to the technical problems mentioned above, and other technical problems not mentioned will be clearly understood by a person having ordinary skill in the technical field to which the present invention pertains from the description below.

[0008] An electronic device according to one embodiment may include at least one processor and a memory connected to the at least one processor. The memory may store instructions that, when executed by the at least one processor, cause the electronic device to generate a random key at the time of executing a first program, store the generated random key in a register included in the at least one processor, perform a first function included in the first program, and, when a second function is called from the first function, store a first return address for the first function in the memory, randomize the random key stored in the register with the first return address, generate a first key value, store a second return address generated by encrypting the first return address with the first key value in the register, perform the second function, decrypt the second return address, and, if the decrypted second return address and the first return address are the same, restore the first key value with the first return address, store the restored first key value in the register, terminate the second function, and return to the first function.

[0009] A method for managing memory in an electronic device according to one embodiment may include: generating a random key at the time of executing a first program, storing the generated random key in a register included in the at least one processor, performing a first function included in the first program, storing a first return address for the first function in a memory when a second function is called from the first function, storing a first key value generated by randomizing the random key stored in the register with the first return address in the register, storing a second return address generated by encrypting the first return address with the first key value in the memory, performing the second function, decrypting the second return address, restoring the first key value with the first return address when the decrypted second return address and the first return address are the same, and storing the restored first key value in the register, and terminating the second function and returning to the first function.

[0010] In one embodiment, a non-transitory computer-readable medium having recorded thereon computer-executable instructions may be configured to perform, when executed, an operation of generating a random key at the time of executing a first program and storing the generated random key in a register included in the at least one processor, an operation of performing a first function included in the first program, an operation of storing a first return address for the first function in a memory when a second function is called from the first function, an operation of randomizing the random key stored in the register with the first return address and storing a first key value generated by encrypting the first return address with the first key value in the register, an operation of storing a second return address generated by encrypting the first return address with the first key value in the memory, an operation of performing the second function, an operation of decrypting the second return address, an operation of restoring the first key value with the first return address if the decrypted second return address and the first return address are the same, and an operation of terminating the second function and returning to the first function.

[0011] FIG. 1 is a block diagram of an electronic device within a network environment according to one embodiment.

[0012] FIG. 2 is a drawing for explaining an example of a configuration of an electronic device according to one embodiment.

[0013] FIG. 3 is a diagram illustrating a memory management method for security according to one embodiment.

[0014] FIG. 4 is a flowchart illustrating an example of the operation of an electronic device according to one embodiment.

[0015] FIG. 5 is a diagram illustrating an example of program code for setting an initial value in a key register to a random value according to one embodiment.

[0016] FIG. 6 is a diagram illustrating an example of source code of a program for protecting a return address according to one embodiment.

[0017] FIG. 7 is a diagram illustrating program source code and a stack for protecting a return address according to one embodiment.

[0018] FIGS. 8A and 8B are diagrams illustrating a procedure for writing source code of a program for protecting a return address according to one embodiment.

[0019] FIG. 1 is a block diagram of an electronic device (101) within a network environment (100), according to one embodiment.

[0020] Referring to FIG. 1, in a network environment (100), an electronic device (101) may communicate with an electronic device (102) via a first network (198) (e.g., a short-range wireless communication network), or may communicate with at least one of an electronic device (104) or a server (108) via a second network (199) (e.g., a long-range wireless communication network). According to one embodiment, the electronic device (101) may communicate with the electronic device (104) via the server (108). According to one embodiment, the electronic device (101) may include a processor (120), a memory (130), an input module (150), an audio output module (155), a display module (160), an audio module (170), a sensor module (176), an interface (177), a connection terminal (178), a haptic module (179), a camera module (180), a power management module (188), a battery (189), a communication module (190), a subscriber identification module (196), or an antenna module (197). In some embodiments, the electronic device (101) may omit at least one of these components (e.g., the connection terminal (178)), or may have one or more other components added. In some embodiments, some of these components (e.g., the sensor module (176), the camera module (180), or the antenna module (197)) may be integrated into one component (e.g., the display module (160)).

[0021] The processor (120) may, for example, execute software (e.g., a program (140)) to control at least one other component (e.g., a hardware or software component) of the electronic device (101) connected to the processor (120) and perform various data processing or calculations. According to one embodiment, as at least a part of the data processing or calculations, the processor (120) may store commands or data received from other components (e.g., a sensor module (176) or a communication module (190)) in a volatile memory (132), process the commands or data stored in the volatile memory (132), and store result data in a non-volatile memory (134). According to one embodiment, the processor (120) may include a main processor (121) (e.g., a central processing unit or an application processor) or a secondary processor (123) (e.g., a graphics processing unit, a neural processing unit (NPU), an image signal processor, a sensor hub processor, or a communication processor)) that can operate independently or together therewith. For example, if the electronic device (101) includes a main processor (121) and a secondary processor (123), the secondary processor (123) may be configured to use less power than the main processor (121) or to be specialized for a specified function. The secondary processor (123) may be implemented separately from the main processor (121) or as a part thereof.

[0022] The auxiliary processor (123) may control at least a portion of functions or states associated with at least one component (e.g., a display module (160), a sensor module (176), or a communication module (190)) of the electronic device (101), for example, on behalf of the main processor (121) while the main processor (121) is in an inactive (e.g., sleep) state, or together with the main processor (121) while the main processor (121) is in an active (e.g., application execution) state. In one embodiment, the auxiliary processor (123) (e.g., an image signal processor or a communication processor) may be implemented as a part of another functionally related component (e.g., a camera module (180) or a communication module (190)). In one embodiment, the auxiliary processor (123) (e.g., a neural network processing unit) may include a hardware structure specialized for processing artificial intelligence models. The artificial intelligence models may be generated through machine learning. This learning can be performed, for example, on the electronic device (101) itself where the artificial intelligence model is executed, or can be performed through a separate server (e.g., server (108)). The learning algorithm can include, for example, supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning, but is not limited to the examples described above. The artificial intelligence model can include multiple artificial neural network layers.The artificial neural network may be one of a deep neural network (DNN), a convolutional neural network (CNN), a recurrent neural network (RNN), a restricted Boltzmann machine (RBM), a deep belief network (DBN), a bidirectional recurrent deep neural network (BRDNN), a deep Q-network, or a combination of two or more of the above, but is not limited to the examples described above. In addition to, or alternatively to, a hardware structure, an artificial intelligence model may include a software structure.

[0023] The memory (130) can store various data used by at least one component (e.g., processor (120) or sensor module (176)) of the electronic device (101). The data can include, for example, software (e.g., program (140)) and input data or output data for commands related thereto. The memory (130) can include volatile memory (132) or non-volatile memory (134).

[0024] The program (140) may be stored as software in the memory (130) and may include, for example, an operating system (142), middleware (144), or an application (146).

[0025] The input module (150) can receive commands or data to be used in a component of the electronic device (101) (e.g., a processor (120)) from an external source (e.g., a user) of the electronic device (101). The input module (150) can include, for example, a microphone, a mouse, a keyboard, a key (e.g., a button), or a digital pen (e.g., a stylus pen).

[0026] The audio output module (155) can output audio signals to the outside of the electronic device (101). The audio output module (155) can include, for example, a speaker or a receiver. The speaker can be used for general purposes, such as multimedia playback or recording playback. The receiver can be used to receive incoming calls. In one embodiment, the receiver can be implemented separately from the speaker or as part of the speaker.

[0027] The display module (160) can visually provide information to an external party (e.g., a user) of the electronic device (101). The display module (160) may include, for example, a display, a holographic device, or a projector and a control circuit for controlling the device. In one embodiment, the display module (160) may include a touch sensor configured to detect a touch, or a pressure sensor configured to measure the intensity of a force generated by the touch.

[0028] The audio module (170) can convert sound into an electrical signal, or vice versa, convert an electrical signal into sound. According to one embodiment, the audio module (170) can acquire sound through the input module (150), output sound through the sound output module (155), or an external electronic device (e.g., electronic device (102)) (e.g., speaker or headphone) directly or wirelessly connected to the electronic device (101).

[0029] The sensor module (176) can detect the operating status (e.g., power or temperature) of the electronic device (101) or the external environmental status (e.g., user status) and generate an electrical signal or data value corresponding to the detected status. According to one embodiment, the sensor module (176) can include, for example, a gesture sensor, a gyro sensor, a barometric pressure sensor, a magnetic sensor, an acceleration sensor, a grip sensor, a proximity sensor, a color sensor, an IR (infrared) sensor, a biometric sensor, a temperature sensor, a humidity sensor, or an illuminance sensor.

[0030] The interface (177) may support one or more designated protocols that may be used to directly or wirelessly connect the electronic device (101) with an external electronic device (e.g., the electronic device (102)). In one embodiment, the interface (177) may include, for example, a high definition multimedia interface (HDMI), a universal serial bus (USB) interface, an SD card interface, or an audio interface.

[0031] The connection terminal (178) may include a connector through which the electronic device (101) may be physically connected to an external electronic device (e.g., electronic device (102)). According to one embodiment, the connection terminal (178) may include, for example, an HDMI connector, a USB connector, an SD card connector, or an audio connector (e.g., a headphone connector).

[0032] A haptic module (179) can convert electrical signals into mechanical stimuli (e.g., vibration or movement) or electrical stimuli that a user can perceive through tactile or kinesthetic sensations. In one embodiment, the haptic module (179) can include, for example, a motor, a piezoelectric element, or an electrical stimulation device.

[0033] The camera module (180) can capture still images and videos. According to one embodiment, the camera module (180) may include one or more lenses, image sensors, image signal processors, or flashes.

[0034] The power management module (188) can manage power supplied to the electronic device (101). According to one embodiment, the power management module (188) can be implemented, for example, as at least a part of a power management integrated circuit (PMIC).

[0035] A battery (189) may power at least one component of the electronic device (101). In one embodiment, the battery (189) may include, for example, a non-rechargeable primary battery, a rechargeable secondary battery, or a fuel cell.

[0036] The communication module (190) may support the establishment of a direct (e.g., wired) communication channel or a wireless communication channel between the electronic device (101) and an external electronic device (e.g., electronic device (102), electronic device (104), or server (108)), and the performance of communication through the established communication channel. The communication module (190) may operate independently from the processor (120) (e.g., application processor) and may include one or more communication processors that support direct (e.g., wired) communication or wireless communication. According to one embodiment, the communication module (190) may include a wireless communication module (192) (e.g., a cellular communication module, a short-range wireless communication module, or a global navigation satellite system (GNSS) communication module) or a wired communication module (194) (e.g., a local area network (LAN) communication module, or a power line communication module). Among these communication modules, the corresponding communication module can communicate with an external electronic device (104) via a first network (198) (e.g., a short-range communication network such as Bluetooth, wireless fidelity (WiFi) direct, or infrared data association (IrDA)) or a second network (199) (e.g., a long-range communication network such as a legacy cellular network, a 5G network, a next-generation communication network, the Internet, or a computer network (e.g., a LAN or WAN)). These various types of communication modules can be integrated into a single component (e.g., a single chip) or implemented as multiple separate components (e.g., multiple chips). The wireless communication module (192) can verify or authenticate the electronic device (101) within a communication network such as the first network (198) or the second network (199) by using subscriber information (e.g., an international mobile subscriber identity (IMSI)) stored in the subscriber identification module (196).

[0037] The wireless communication module (192) can support 5G networks and next-generation communication technologies following the 4G network, such as NR access technology (new radio access technology). The NR access technology can support high-speed transmission of high-capacity data (eMBB (enhanced mobile broadband)), minimization of terminal power and connection of multiple terminals (mMTC (massive machine type communications)), or high reliability and low latency (URLLC (ultra-reliable and low-latency communications)). The wireless communication module (192) can support, for example, a high-frequency band (e.g., mmWave band) to achieve a high data transmission rate. The wireless communication module (192) can support various technologies for securing performance in a high-frequency band, such as beamforming, massive multiple-input and multiple-output (MIMO), full dimensional MIMO (FD-MIMO), array antenna, analog beam-forming, or large scale antenna. The wireless communication module (192) can support various requirements specified in the electronic device (101), an external electronic device (e.g., the electronic device (104)), or a network system (e.g., the second network (199)). According to one embodiment, the wireless communication module (192) can support a peak data rate (e.g., 20 Gbps or more) for eMBB realization, a loss coverage (e.g., 164 dB or less) for mMTC realization, or a U-plane latency (e.g., 0.5 ms or less for downlink (DL) and uplink (UL), or 1 ms or less for round trip) for URLLC realization.

[0038] The antenna module (197) can transmit or receive signals or power to or from an external device (e.g., an external electronic device). In one embodiment, the antenna module (197) may include an antenna including a radiator formed of a conductor or a conductive pattern formed on a substrate (e.g., a PCB). In one embodiment, the antenna module (197) may include a plurality of antennas (e.g., an array antenna). In this case, at least one antenna suitable for a communication method used in a communication network, such as the first network (198) or the second network (199), may be selected from the plurality of antennas by, for example, the communication module (190). A signal or power may be transmitted or received between the communication module (190) and an external electronic device through the selected at least one antenna. In some embodiments, in addition to the radiator, another component (e.g., a radio frequency integrated circuit (RFIC)) may be additionally formed as a part of the antenna module (197).

[0039] According to various embodiments, the antenna module (197) may form a mmWave antenna module. According to one embodiment, the mmWave antenna module may include a printed circuit board, an RFIC disposed on or adjacent a first side (e.g., a bottom side) of the printed circuit board and capable of supporting a designated high frequency band (e.g., a mmWave band), and a plurality of antennas (e.g., an array antenna) disposed on or adjacent a second side (e.g., a top side or a side side) of the printed circuit board and capable of transmitting or receiving signals in the designated high frequency band.

[0040] At least some of the above components can be interconnected and exchange signals (e.g., commands or data) with each other via a communication method between peripheral devices (e.g., a bus, GPIO (general purpose input and output), SPI (serial peripheral interface), or MIPI (mobile industry processor interface)).

[0041] According to one embodiment, commands or data may be transmitted or received between the electronic device (101) and an external electronic device (104) via a server (108) connected to a second network (199). Each of the external electronic devices (102 or 104) may be the same or a different type of device as the electronic device (101). According to one embodiment, all or part of the operations executed in the electronic device (101) may be executed in one or more of the external electronic devices (102, 104, or 108). For example, when the electronic device (101) is to perform a certain function or service automatically or in response to a request from a user or another device, the electronic device (101) may, instead of or in addition to executing the function or service itself, request one or more external electronic devices to perform the function or at least a part of the service. One or more external electronic devices that receive the request may execute at least a portion of the requested function or service, or an additional function or service related to the request, and transmit the result of the execution to the electronic device (101). The electronic device (101) may process the result as is or additionally and provide it as at least a portion of a response to the request. For this purpose, cloud computing, distributed computing, mobile edge computing (MEC), or client-server computing technology may be used, for example. The electronic device (101) may provide an ultra-low latency service by using distributed computing or mobile edge computing, for example. In another embodiment, the external electronic device (104) may include an Internet of Things (IoT) device. The server (108) may be an intelligent server utilizing machine learning and / or a neural network. According to one embodiment, the external electronic device (104) or the server (108) may be included in the second network (199).The electronic device (101) can be applied to intelligent services (e.g., smart home, smart city, smart car, or healthcare) based on 5G communication technology and IoT-related technology.

[0042] An electronic device according to an embodiment disclosed in this document may take various forms. The electronic device may include, for example, a portable communication device (e.g., a smartphone), a computer device, a portable multimedia device, a portable medical device, a camera, a wearable device, or a home appliance. The electronic device according to an embodiment of this document is not limited to the aforementioned devices.

[0043] It should be understood that the embodiments of this document and the terminology used herein are not intended to limit the technical features described in this document to specific embodiments, but include various modifications, equivalents, or substitutes of the embodiments. In connection with the description of the drawings, similar reference numerals may be used for similar or related components. The singular form of a noun corresponding to an item may include one or more of the items, unless the context clearly indicates otherwise. In this document, each of the phrases "A or B", "at least one of A and B", "at least one of A or B", "A, B, or C", "at least one of A, B, and C", and "at least one of A, B, or C" can include any one of the items listed together in the corresponding phrase among those phrases, or all possible combinations thereof. Terms such as "first," "second," or "first" or "second" may be used merely to distinguish one component from another, and do not limit the components in any other respect (e.g., importance or order). When a component (e.g., a first component) is referred to as "coupled" or "connected" to another component (e.g., a second component), with or without the terms "functionally" or "communicatively," it means that the component can be connected to the other component directly (e.g., wired), wirelessly, or through a third component.

[0044] The term "module" used in one embodiment of this document may include a unit implemented in hardware, software, or firmware, and may be used interchangeably with terms such as logic, logic block, component, or circuit. A module may be an integral component, or a minimum unit or part of such a component that performs one or more functions. For example, according to one embodiment, a module may be implemented in the form of an application-specific integrated circuit (ASIC).

[0045] An embodiment of the present document may be implemented as software (e.g., a program (140)) including one or more instructions stored in a storage medium (e.g., an internal memory (136) or an external memory (138)) readable by a machine (e.g., an electronic device (101)). For example, a processor (e.g., a processor (120)) of the machine (e.g., an electronic device (101)) may call at least one instruction among the one or more instructions stored from the storage medium and execute it. This enables the machine to operate to perform at least one function according to the at least one called instruction. The one or more instructions may include code generated by a compiler or code executable by an interpreter. The machine-readable storage medium may be provided in the form of a non-transitory storage medium. Here, "non-transitory" simply means that the storage medium is a tangible device and does not contain signals (e.g., electromagnetic waves), and the term does not distinguish between cases where data is stored semi-permanently or temporarily on the storage medium.

[0046] According to one embodiment, the method according to one embodiment disclosed in the present document may be provided as a computer program product. The computer program product may be traded between sellers and buyers as a product. The computer program product may be distributed in the form of a device-readable storage medium (e.g., compact disc read-only memory (CD-ROM)) or may be provided through an application store (e.g., Play Store). TM ) or directly between two user devices (e.g., smart phones), online distribution (e.g., downloading or uploading). In the case of online distribution, at least a portion of the computer program product may be at least temporarily stored or temporarily created in a machine-readable storage medium, such as the memory of a manufacturer's server, an application store's server, or an intermediary server.

[0047] According to one embodiment, each component (e.g., a module or a program) of the above-described components may include one or more entities, and some of the entities may be separated and placed in other components. According to one embodiment, one or more components or operations of the aforementioned components may be omitted, or one or more other components or operations may be added. Alternatively or additionally, a plurality of components (e.g., a module or a program) may be integrated into a single component. In this case, the integrated component may perform one or more functions of each of the plurality of components identically or similarly to those performed by the corresponding component among the plurality of components prior to the integration. According to one embodiment, the operations performed by a module, program, or other component may be executed sequentially, in parallel, iteratively, or heuristically, or one or more of the operations may be executed in a different order, omitted, or one or more other operations may be added.

[0048] FIG. 2 is a drawing for explaining an example of a configuration of an electronic device (101) according to one embodiment. However, the electronic device (101) is not limited to the configurations illustrated in FIG. 2, and may be implemented to include more or fewer configurations than the configurations illustrated in FIG. 2.

[0049] Referring to FIG. 2, the electronic device (101) may include a processor (210) and a memory (220).

[0050] The processor (210) may include at least one register (211). According to one embodiment, the processor (210) may include a central processing unit (CPU). The operations of the processor (210) described below may be performed by executing modules stored in the memory (220). For example, at least some of the modules may be implemented (e.g., executed) as software, firmware, or a combination of at least two or more thereof. For example, the modules may be implemented in the form of an application, a program, computer code, instructions, a routine, or a process executable by the processor (320). Accordingly, when the modules are executed by the processor (210), the modules may cause the processor (210) to perform an operation associated with the module (or a function that the module can provide). Accordingly, the description below that a specific module performs an operation may be interpreted as the processor (210) performing the operation as the specific module is executed. Alternatively, the modules may be implemented as part of a specific application. Alternatively, without being limited to what is described and / or illustrated, each module may be implemented as separate hardware (e.g., processor, control circuit) from the processor (210). The processor (210) may perform various functions and operations related to the memory management method for security described below by executing instructions stored in the memory (220).

[0051] When a user requests program execution, program information is loaded into the memory (22), and the processor (210) can read the program code stored in the memory (220) and execute instructions. When a function is called while the processor (210) is executing the program code, the processor branches to the called function and executes the function. When the function call is completed, the processor returns to the original function and executes the next instruction. In the part where the function is called, the current program counter (i.e., the return address) and data required for the function call and execution, such as local variables and parameters, may be stored in the stack area. The stack area is a temporary memory area automatically used by the program, allocated with the function call, and destroyed when the function terminates. The return address is the address for returning control to the calling location when the function finishes executing. When a function is called, the address to be executed after the currently executing instruction is stored as the return address. The return address indicates the address of the next instruction of the called function or instruction. The return address is pushed onto the stack when the function is called, and is popped when the function terminates, thereby restoring the program counter. Through this, the processor (210) can execute the instruction stored at the address of the value pointed to by the restored program counter when the function is terminated.

[0052] In one embodiment, the processor (210) may generate a random key at the start of a program to protect the return address, store the random key in a register (211), and perform operations of encrypting and decrypting the return address using the value stored in the register (211) while executing each function. This will be described in more detail below.

[0053] Memory (220) (e.g., memory (130) of FIG. 1) can store data output from an application. In one embodiment, an application is executed by a processor (210), and the processor (210) can store data generated during execution of the application in the memory (220). In one embodiment, the processor (210) can read data required during execution of the application from the memory (220). In one embodiment, the memory (220) can store computer-executable instructions configured to perform various functions and operations related to a memory management method for security. In one embodiment, the memory (220) can store instructions for performing operations of generating a random key at the time of program startup to protect a return address and storing the same in a register (211), and encrypting and decrypting the return address using the value stored in the register (211) while executing each function. In one embodiment, the memory (220) can include a stack area for storing a return address generated by each function when the program is executed.

[0054] The register (211) may be a volatile memory with a low capacity compared to the memory (220). The register (211) may temporarily store a random key and an encrypted return address to be used for encrypting the return address at the start of a program executed by the processor (210). In one embodiment, the register (211) may be a storage space in which data can be read, modified, or deleted in a restricted manner. The electronic device (101) may be configured to allow access to the register (211) only for a specific instruction set. For example, data in the register (211) may be read, modified, or deleted depending on a specific instruction. Information stored in the register (211) may be used to decrypt the encrypted return address. This will be described in more detail below.

[0055] FIG. 3 is a diagram illustrating a memory management method for security according to one embodiment.

[0056] As illustrated in FIG. 3, a ROP attack can cause an overflow of variables stored in the kernel's stack (330) to change the return address to be loaded into the register (340) stored in the stack (330). Meanwhile, in order to prevent the return address from being changed, an ASLR (Address Space Layout Randomization) method can be used, which adds a key to randomly change the address when a program is loaded into memory, or a DEP (Data Execution Prevention) method can be used, which adds an algorithm (320) to prevent code execution in an area other than the memory area where the executable code is located. In this case, an attacker can attack the added key or algorithm (320) to prevent the return address from being changed, and execute the code desired by the attacker. Accordingly, a damaged return address due to the attacker's manipulation can be stored in the register (340).

[0057] In more detail, when the execution of kernel code (or process) is started by the kernel, the processor can sequentially execute the executable code stored in the memory. For example, if function B, which is an internal function of function A, is called while function A at address 1 is being executed, the processor moves to address 3 to execute function B, and can store the return address (address 2) on the stack so that it can return to address 2, which is the address following address 1, after the execution of function B is finished. At this time, if a stack overflow attack occurs and the return address (address 2) stored on the stack is manipulated to another address (address 4), the processor can store the manipulated return address on the stack in a register before completing the operation of function A and returning. Accordingly, the manipulated return address (address 4) may also be stored in the register. Accordingly, the process will not jump to address 2, which is the normal return address, after completing the operation of function A, but will jump to address 4, which is the return address manipulated by the attacker, and a ROP attack may be initiated due to the execution of unintended code.

[0058] To prevent ROP attacks like the above, various control flow integrity (CFI) protection techniques are being used. For example, a shadow stack can be created in hardware as a separate storage space, separate from the existing stack and inaccessible to attackers. Furthermore, by storing the return address in the shadow stack, the return address can be prevented from being manipulated.

[0059] Because the above method requires hardware support, it cannot be applied to low-cost electronic devices that do not support this feature. Therefore, in devices where security is prioritized over performance, it is necessary to consider software-based methods to enhance memory security.

[0060] Below, a memory management method for improving security in memory through software and the operation of an electronic device for this purpose will be described in detail with reference to drawings.

[0061] FIG. 4 is a flowchart (400) illustrating an example of the operation of an electronic device (101) according to one embodiment. The operations illustrated in FIG. 4 are not limited to the illustrated order and may be performed in various orders. Furthermore, according to one embodiment, more operations may be performed than those illustrated in FIG. 4, or at least one operation may be performed less than those illustrated in FIG.

[0062] According to one embodiment, the electronic device (101) (e.g., the processor (210) of FIG. 2) may generate a random key for encrypting a return address at the start of the program, i.e., before starting the main function (main()) in operation 401, and store the random key in a key register (e.g., the register (211) of FIG. 2) in operation 402.

[0063] FIG. 5 illustrates an example of program code for setting an initial value to a random value in a key register according to one embodiment. Referring to FIG. 5, a compiler may insert code for setting an initial value to a random value in a key register, such as 501, into codes executed before performing a main function. According to one embodiment, the random key may have the same value applied to multiple functions, or different values ​​may be generated for each multiple functions. Various methods may be used to generate a random key, and the present disclosure does not place any limitation on the method for generating a random key. According to one embodiment, a key register in which a random key is stored may be compiled to be inaccessible by a program developer or to be inaccessible by codes other than codes specified by the compiler.

[0064] In operation 403, the electronic device (101) (e.g., processor (210)) may call an external function while performing the logic of the main function. In one embodiment, the processor (210) of the electronic device (101) may store a return address (RA1) in a stack when calling the external function and then jump to the external function. The processor (210) of the electronic device (101) may store a previous stack frame in a stack when calling the external function and set a new stack frame for performing the external function logic.

[0065] In operation 404, the electronic device (101) (e.g., processor (210)) may read a random key stored in a key register before performing the logic of an external function, and store a key value randomized with the random key by using a return address (RA1) stored in a stack in the key register. In one embodiment, a key value converted by performing an XOR operation on the random key and the return address (RA1) may be stored in the key register. In addition to the XOR operation, other methods such as addition or subtraction operations may be used as a randomization method.

[0066] In operation 405, the electronic device (101) (e.g., the processor (210)) may store a return address (RA2) generated by encrypting a return address (RA1) stored in a stack with a key value stored in a key register in the stack. In one embodiment, a method of encrypting the return address may include a method of adding or subtracting the return address (RA1) stored in the stack and the key value stored in the key register. In addition, various methods may be used to encrypt the return address (RA1) to generate the return address (RA2), and the present disclosure does not place any restrictions on the encryption method.

[0067] In operation 406, the electronic device (101) (e.g., processor (210)) may allocate a local variable for an external function and perform logic within the external function.

[0068] In operation 407, the electronic device (101) (e.g., processor (210)) may decrypt the encrypted return address (RA2) stored in the stack with the key value stored in the key register before terminating the external function and returning to the calling function, and compare the decrypted return address (RA2) with the return address (RA1) stored in the stack. In one embodiment, as a method of decrypting the return address (RA2), a decryption method corresponding to a method of encrypting the return address (RA1) stored in the stack with the key value stored in the key register may be used. For example, if an addition operation is performed using an encryption method, a subtraction operation may be performed using a decryption method, and if a subtraction operation is performed using an encryption method, an addition operation may be performed using a decryption method.

[0069] The electronic device (101) (e.g., processor (210)) terminates the operation without returning to the calling function if the decrypted return address (RA2) and the return address (RA1) stored in the stack are not the same, and if the decrypted return address (RA2) and the return address (RA1) stored in the stack are the same, the electronic device (101) may randomize the key value stored in the key register again with the return address (RA1) stored in the stack in operation 408 to recover the key value, and store the recovered key value in the key register.

[0070] In operation 409, the electronic device (101) (e.g., processor (210)) may recover the stack pointer and stack frame that were being used by the external function and return to the function that called the external function.

[0071] FIG. 6 illustrates an example of program source code for protecting a return address according to one embodiment. For convenience of explanation, FIG. 6 illustrates a comparison of a general program source code (a) and a program source code (b) according to one embodiment of the present disclosure.

[0072] Referring to FIG. 6, the compiler can compile the program source code to store the return address (RA1) for the function (caller) on the stack before calling the function (callee) while performing the logic of the function (caller), and this program source code can be applied equally to both (a) and (b) of FIG. 6. In one embodiment, the compiler can insert into the program source code a code (601) for storing a key value generated by randomizing a random value stored in a key register with the return address (RA1) stored on the stack before performing the logic of the called function (callee), and a code (603) for storing a return address (RA2) generated by encrypting the return address (RA1) with the key value stored in the key register on the stack. As an example of a method for generating a key value by randomizing a random value stored in a key register with a return address (RA1) in the 601 code, a method of performing an XOR operation on the return address (RA1) stored in the stack and the random value stored in the key register can be used, and another method can be a method of performing an addition or subtraction operation. The present disclosure does not place any limitation on the randomization method. The return address (RA2) generated by encrypting the return address (RA1) with a key value by the 603 code is stored in the stack, and the key value used when encrypting the return address (RA2) is stored in the key register, so that an attacker cannot access it. Therefore, since an attacker cannot know the key value used when encrypting the return address (RA1) to generate the return address (RA2), the return address (RA2) can be prevented from being arbitrarily manipulated by the attacker.In one embodiment, the compiler may insert into the program source code a code (605) to compare the return address (RA2) stored in the stack with the return address (RA1) before performing the logic of the called function (callee) and returning to the calling function (caller), and a code (607) to restore the key value stored in the key register. According to one embodiment, if the XOR operation is used as a randomization method in the 603 code, the key value before randomization can be restored by using the XOR operation again in the 607 code. In one embodiment, the electronic device (101) (e.g., the processor (210)) that confirms that the return address (RA1) and the return address (RA2) are the same by performing the 605 code can confirm that the return address (RA1) has not been tampered with, that the logic is normally executed from the beginning of the function without an attack by an attacker, and that the return address (RA2) is normally generated. In one embodiment, the electronic device (101) (e.g., processor (210)) may terminate the program by handling an exception without returning to the calling function when the return address (RA1) and the return address (RA2) are different.

[0073] Figure 7 illustrates program source code and a stack for protecting a return address according to one embodiment. Figure 7 illustrates program source code and a stack in which function 1 (function 1()) is called by the main function, and function 2 (function 2()) is called by function 1 (function 1()).

[0074] Referring to FIG. 7, 710 is a source code that is executed before performing the main function at the time of program startup. In one embodiment, the compiler may insert code (711) that sets an initial value in the key register (730) to a random value in the codes that are executed before performing the main function at the time of program startup. In one embodiment, the electronic device (101) (e.g., the processor (210)) may store a random value in the key register (730) by executing the source code of 711 before performing the main function at the time of program startup. In one embodiment, the random value may be generated in various ways, such as by reading and using a random value stored in advance in a memory or by setting a random value based on the current time, and the present disclosure does not place any restrictions on the method of generating the random value. The random value stored in the key register (730) may be used to encrypt and protect a return address value that is later stored in the stack (740). In one embodiment, the electronic device (101) (e.g., processor (210)) executes the remaining portion of the main function after executing the source code of 710, and a stack pointer is stored in the stack area (741) of the main function, and function 1 (function 1()) can be called by the main function.

[0075] 720 shows an example of program source code for individual functions (e.g., function 1(), function 2()). The compiler can insert code (721, 726) for randomizing a random value stored in a key register (730) with a return address (RA11, RA21) stored in a stack (740) at the beginning of each function and storing the generated key value in the key register (730), and code (722, 727) for encrypting the return address (RA11, RA21) stored in the stack with the key value stored in the key register (730) to generate a return address (RA12, RA22), and storing the return address (RA12, RA22) in the stack (740). As an example of a method for randomizing a random value stored in a key register (730) with a return address (RA11) in codes 721 and 726, a method of performing an XOR operation on the return address (RA11) stored in a stack area (742) and the random value stored in the key register (730) may be used, and as another method of randomization, an addition or subtraction operation may be used. The present disclosure does not place any limitation on a specific method of randomization.

[0076] When function 1 (function 1()) is called by the main function, the electronic device (101) (e.g., processor (210)) can store a return address (RA11) and a stack pointer in the stack area (742) of function 1 (function 1()). At the beginning of function 1 (function 1()), the electronic device (101) (e.g., processor (210)) randomizes a random value stored in the key register (730) as the return address (RA11) and stores the generated key value in the key register (730) as the key value by executing code 721, and encrypts the return address (RA11) with the key value randomly stored in the key register (730) as the key value and stores it as the return address (RA12) in the stack area (742) of function 1 (function 1()) as the return address (RA12), and can execute the remaining codes of function 1 (function 1()). Various methods can be used as the encryption method, and the present disclosure does not place any limitation on the specific encryption method. The key value used to encrypt the return address (RA11) to generate the return address (RA12) is stored in the key register (730), making it inaccessible to an attacker. Therefore, the attacker cannot know the key value used to encrypt the return address (RA22), preventing the return address (RA12) from being arbitrarily manipulated by the attacker.

[0077] In one embodiment, the compiler may insert code (723) to decrypt the return address (RA12) stored in the stack area (742) of function 1 (function 1()) with a key value stored in a key register (730) before calling function 2 (function 2()) within the logic of function 1 (function 1()), and to compare the decrypted return address (RA12) with the return address (RA11) stored in the stack area (742) of function 1 (function 1()). In one embodiment, the electronic device (101) (e.g., the processor (210)) may decrypt the return address (RA12) stored in the stack area (742) of function 1 (function 1()) with a key value stored in the key register (730) while executing the 723 code, compare the decrypted return address (RA12) with the return address (RA11) stored in the stack area (742) of function 1 (function 1()), and if the two values ​​are different as a result of the comparison, handle an exception and terminate the program. The method of decrypting the return address (RA12) stored in the stack area (742) of function 1 (function 1()) with the key value stored in the key register (730) may use a decryption method corresponding to the method of encrypting the return address (RA12) in the 722 code. For example, if an addition operation is performed using an encryption method, a subtraction operation can be performed using a decryption method, and if a subtraction operation is performed using an encryption method, an addition operation can be performed using a decryption method.

[0078] In one embodiment, the electronic device (101) (e.g., processor (210)) that confirms that the return address (RA11) and the return address (RA12) are the same by executing code 723 can confirm that the return address (RA11) has not been tampered with and that the logic of function 1 (function 1()) has been normally executed from the beginning without an attack by an attacker, thereby normally generating the return address (RA12). In one embodiment, if an attacker arbitrarily jumps to the middle of the function, codes 721 and 722 are not executed, so the two values ​​are not the same. In this case, by handling an exception and terminating the program, it is possible to prevent an attacker from arbitrarily executing a different code.

[0079] When function 2 (function 2()) is called by function 1 (function 1()), the electronic device (101) (e.g., processor (210)) can store a return address (RA21) and a stack pointer in the stack area (743) of function 2 (function 2()). At the beginning of function 2 (function 2()), the electronic device (101) (e.g., processor (210)) can randomize a random value stored in the key register (730) as the return address (RA21) and store the generated key value in the key register (730) as the key value by executing code 726, and can encrypt the return address (RA21) with the key value randomized and stored in the key register (730) as the key value and store it as the return address (RA22) in the stack area (743) of function 2 (function 2()) as the return address (RA22) as the remaining code of function 2 (function 2()). As an example of a method for generating a key value by randomizing a random value to a return address (RA21) in the 726 code, a method of performing an XOR operation on the return address (RA21) stored in the stack area (743) and the random value stored in the key register (730) may be used, and the present disclosure does not place any restrictions on the randomization method.

[0080] In one embodiment, the compiler may insert code (724, 728) that decrypts the return address (RA12, RA22) stored in the stack area of ​​each function into a key value stored in a key register (730) in front of the instruction code (return) that returns each function to the function that called it, and compares the decrypted return address (RA12, RA22) with the return address (RA11, RA21) stored in the stack area of ​​each function, and code (725, 729) that restores the key value stored in the key register (730) to the value before the call of each function using the return address (RA11, RA21) stored in the stack area of ​​each function. According to one embodiment, when the XOR operation is used as a randomization method in the 721 code, the key value before randomization can be restored by using the XOR operation again in the 725, 729 codes.

[0081] In one embodiment, the electronic device (101) (e.g., processor (210)) executes the remaining codes of function 2 (function 2()) after executing code 727, and before returning to function 1 (function 1()), by executing code 728, decrypts the return address (RA22) stored in the stack area (743) of function 2 (function 2()) with the key value stored in the key register (730), compares the decrypted return address (RA22) with the return address (RA21) stored in the stack area (743) of function 2 (function 2()), and if the two values ​​are different as a result of the comparison, an exception may be processed to terminate the program. According to one embodiment, when an XOR operation is used as an encryption method in code 726, the return address before encryption may be restored by using an XOR operation again as a decryption method in code 728. In one embodiment, the electronic device (101) (e.g., processor (210)) that confirms that the return address (RA21) and the return address (RA22) are the same by executing code 728 confirms that the return address (RA21) has not been tampered with and that the logic of function 2 (function 2()) is normally executed from the beginning without an attack by an attacker, thereby normally generating the return address (RA22), and then, by executing code 729, restores the key value stored in the key register (730) to the value before the call of function 2 (function 2()) by using the return address (RA21) stored in the stack area (743) of function 2 (function 2()), and returns to function 1 (function 1()). In one embodiment, if an attacker arbitrarily jumps to the middle of the function, codes 726 and 727 are not executed, so the two values ​​are not the same. In this case, an exception is processed to terminate the program, thereby preventing an attacker from arbitrarily executing another code.

[0082] In one embodiment, the electronic device (101) (e.g., processor (210)) that performs function 2 (function 2()) and returns to function 1 (function 1()) may, before returning to function 1 (function 1()), decrypt the return address (RA12) stored in the stack area (742) of function 1 (function 1()) with the key value stored in the key register (730) by performing code 724, compare the decrypted return address (RA12) with the return address (RA11) stored in the stack area (742) of function 1 (function 1()), and, if the two values ​​are different as a result of the comparison, handle an exception to terminate the program. According to one embodiment, when the XOR operation is used as the encryption method in the 722 code, the return address before randomization can be restored by using the XOR operation again as the decryption method in the 724 code. In one embodiment, the electronic device (101) (e.g., processor (210)) that confirms that the return address (RA11) and the return address (RA12) are the same by executing code 724 confirms that the return address (RA11) has not been tampered with and that the logic of function 1 (function 1()) has been normally executed from the beginning without an attack by an attacker and that the return address (RA12) has been normally generated, and by executing code 725, the value stored in the key register (730) can be restored to the value before the call of function 2 (function 2()) by using the return address (RA11) stored in the stack area (742) of function 1 (function 2()), and returns to the function that called function 1 (function 1()). In one embodiment, if an attacker arbitrarily jumps to the middle of the function, codes 721 and 722 are not executed, so the two values ​​are not the same. In this case, an exception is processed to terminate the program, thereby preventing an attacker from arbitrarily executing another code.

[0083] In one embodiment, a method for protecting a return address according to the present disclosure may be applied even when multiple processes are operating. When multiple processes are operating, context switching may occur between the processes. When context switching occurs, a value generated by a currently executing process (e.g., process 1) and stored in a key register may be safely backed up to memory allocated to process 1, and then, when another process (e.g., process 2) is executed, the key register may be initialized and the key value generated by process 2 may be stored in the key register. When process 2 is stopped or completed and a context switching back to process 1 occurs, the value generated by process 2 and stored in the key register may be safely backed up to memory allocated to process 2, and then, when process 1 is executed, the key register may be initialized and the value backed up in the memory allocated to process 1 may be read and stored in the key register.

[0084] FIGS. 8A and 8B illustrate a procedure for writing program source code to protect a return address at build time, according to an embodiment. FIG. 8A illustrates a procedure for writing code to be executed before the main function starts at the start of a program, according to an embodiment, and FIG. 8B illustrates a procedure for writing code to be executed in an individual function, according to an embodiment. Although FIGS. 8A and 8B illustrate that program source code is written by a compiler, instructions may also be added to already compiled code.

[0085] Referring to FIG. 8A, at operation 801, the compiler may write code that generates a random key value to protect the return address as code executed before the main function starts at the program startup time. According to one embodiment, the random key may have the same value applied to multiple functions, or different values ​​may be generated for each of the multiple functions. Various methods may be used to generate the random key, and the present disclosure does not place any restrictions on the method of generating the random key.

[0086] In operation 802, the compiler may write code to store the generated random key in a key register. In one embodiment, the random key stored in the key register may be used to protect the return address stored on the stack during subsequent function execution. In one embodiment, the key register where the random key is stored may be compiled to be inaccessible to the program developer or to code other than code designated by the compiler.

[0087] Referring to Fig. 8b, in operation 811, the compiler can write code in the prologue part of each function included in the program to randomize the random key stored in the key register with the return address stored in the stack, and store the randomized key value in the key register. Fig. 8b illustrates an example of a randomization method in which the random key stored in the key register and the return address stored in the stack are XOR-operated, and other methods such as addition or subtraction operations can be used as the randomization method.

[0088] In operation 812, the compiler may write code to encrypt the return address (RA1) stored in the stack in the prologue part of each function included in the program and to store the encrypted return address (RA2) in the stack. In one embodiment, the compiler may write code to encrypt the return address (RA1) stored in the stack with a randomized key value stored in a key register and to store the encrypted return address (RA2) in the stack. In one embodiment, a method of encrypting the return address may include a method of adding or subtracting the return address (RA1) stored in the stack and the key value stored in the key register. In addition, various methods may be used to encrypt the return address (RA1) and generate the return address (RA2), and the present disclosure does not place any limitation on the encryption method.

[0089] In operation 813, the compiler may write code to compare the encrypted return address (RA2) with the return address (RA1) stored in the stack before calling the external function in the body part of each function included in the program. In one embodiment, the compiler may write code to decrypt the encrypted return address (RA2) with the key value stored in the key register before calling the external function, compare the decrypted return address with the return address (RA1) stored in the stack, and terminate the program by handling an exception instead of returning to the calling function if the two values ​​are different. In one embodiment, as a method of decrypting the return address, a decryption method corresponding to a method of encrypting the return address (RA2) stored in the stack and the key value stored in the key register may be used. For example, if an addition operation is performed using an encryption method, a subtraction operation can be performed using a decryption method, and if a subtraction operation is performed using an encryption method, an addition operation can be performed using a decryption method.

[0090] In operation 814, the compiler may write code to compare the encrypted return address (RA2) with the return address (RA1) stored in the stack in the epilogue section of each function included in the program. In one embodiment, the compiler may write code to decrypt the encrypted return address (RA2) with a randomized key value stored in the key register, compare the decrypted return address with the return address (RA1) stored in the stack, and terminate the program by handling an exception instead of returning to the calling function if the two values ​​are different as a result of the comparison. In one embodiment, as a method of decrypting the return address, a decryption method corresponding to the method of encrypting the return address (RA2) stored in the stack and the return address stored in the key register may be used. For example, if an addition operation is performed using an encryption method, a subtraction operation can be performed using a decryption method, and if a subtraction operation is performed using an encryption method, an addition operation can be performed using a decryption method.

[0091] In operation 815, the compiler may write code to restore the key value stored in the key register in the epilogue part of each function included in the program. In one embodiment, the compiler may re-randomize the key value stored in the key register with a return address (RA1) stored in the stack and store the restored key value in the key register. In one embodiment, when the XOR operation is used as the randomization method in operation 811, the key value before randomization may be restored by using the XOR operation again in operation 815. In one embodiment, when the addition or subtraction operation is used as the randomization method in operation 811, the key value before randomization may be restored by using the subtraction or addition operation in operation 815.

[0092] The present invention has been described above, focusing on preferred embodiments thereof. Those skilled in the art will appreciate that the present invention can be implemented in modified forms without departing from its essential characteristics. Therefore, the disclosed embodiments should be considered illustrative rather than limiting. The scope of the present invention is set forth in the claims, not the foregoing description, and all differences within the scope equivalent thereto should be construed as being encompassed by the present invention.

Claims

1. In an electronic device (101), at least one processor (210); and It includes a memory (220) connected to at least one processor, The above memory, when executed by the at least one processor, causes the electronic device to: Generating a random key at the time of executing the first program (401), and storing the generated random key in a register (211) included in at least one processor (402), Performing the first function included in the above first program, As the second function is called in the first function (403), the first return address for the first function is stored in the memory (220), The first key value generated by randomizing the random key stored in the register with the first return address is stored in the register (404). A second return address generated by encrypting the first return address with the first key value is stored in the memory (405). Perform the above second function (406), Decrypt the above second return address (407), If the decrypted second return address and the first return address are the same, the first key value is restored with the first return address, and the restored first key value is stored in the register (408). An electronic device storing instructions for terminating the second function and returning to the first function (409).

2. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: An electronic device storing instructions for decrypting the second return address with the first key value, restoring the first key value with the first return address if the decrypted second return address and the first return address are the same, and storing the restored first key value in the register.

3. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: Generate the first key value by performing an XOR operation on the random key stored in the register and the first return address, An electronic device storing instructions for restoring the first key value by performing an XOR operation on the first return address and the first key value.

4. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: Generate the first key value by performing an addition operation on the random key stored in the register and the first return address, An electronic device storing instructions for restoring the first key value by performing a subtraction operation on the first return address and the first key value.

5. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: Generate the first key value by performing a subtraction operation on the random key stored in the register and the first return address, An electronic device storing instructions for restoring the first key value by performing an addition operation on the first return address and the first key value.

6. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: An electronic device storing instructions for terminating the first program if the decrypted second return address and the first return address are different.

7. In paragraph 1, The above memory, when executed by the at least one processor, causes the electronic device to: At the start point of performing the first function, the third return address for the first function is stored in the memory (220), Store the second key value generated by randomizing the random key stored in the register with the third return address in the register, An electronic device storing instructions for decrypting the third return address with the second key value before calling the second function, and terminating the first program if the decrypted third return address is different from the third return address.

8. In a memory management method of an electronic device (101), An operation of generating a random key at the time of executing the first program (401) and storing the generated random key in a register (211) included in at least one processor (402); An action of performing a first function included in the above first program, As the second function is called from the first function (403), an operation of storing the first return address for the first function in the memory (220); An operation (404) of storing a first key value generated by randomizing a random key stored in the register with the first return address in the register; An operation (405) of storing a second return address generated by encrypting the first return address with the first key value in the memory; An operation (406) for performing the above second function; An operation (407) for decrypting the above second return address; If the decrypted second return address and the first return address are the same, an operation (408) of restoring the first key value with the first return address and storing the restored first key value in the register, and A method comprising an action of terminating the second function and returning to the first function (409).

9. In paragraph 8, A method further comprising: decrypting the second return address with the first key value; restoring the first key value with the first return address if the decrypted second return address and the first return address are the same; and storing the restored first key value in the register.

10. In paragraph 8, An operation of generating the first key value by performing an XOR operation on the random key stored in the register and the first return address, and A method further comprising an operation of storing instructions for performing an XOR operation on the first return address and the first key value to restore the first key value.

11. In paragraph 8, An operation of generating the first key value by performing an addition operation on the random key stored in the register and the first return address, and A method further comprising an operation of storing instructions for restoring the first key value by performing a subtraction operation on the first return address and the first key value.

12. In paragraph 8, An operation of generating the first key value by performing a subtraction operation on the random key stored in the register and the first return address, and A method further comprising an operation of storing instructions for restoring the first key value by performing an addition operation on the first return address and the first key value.

13. In paragraph 8, A method further comprising an operation of storing instructions for terminating the first program if the decrypted second return address and the first return address are different.

14. In paragraph 8, At the start point of performing the first function, an operation of storing a third return address for the first function in the memory (220); An operation of storing a second key value generated by randomizing the random key stored in the register with the third return address in the register, and A method further comprising, prior to calling the second function, an action of decrypting the third return address with the second key value, and terminating the first program if the decrypted third return address is different from the third return address.

15. A non-transitory computer-readable medium having computer-executable instructions recorded thereon, wherein the computer-executable instructions, when executed, cause an electronic device including at least one processor to: An operation of generating a random key at the time of executing the first program (401) and storing the generated random key in a register (211) included in at least one processor (402); An action of performing a first function included in the above first program, As the second function is called from the first function (403), an operation of storing the first return address for the first function in the memory (220); An operation (404) of storing a first key value generated by randomizing a random key stored in the register with the first return address in the register; An operation (405) of storing a second return address generated by encrypting the first return address with the first key value in the memory; An operation (406) for performing the above second function; An operation (407) for decrypting the above second return address; If the decrypted second return address and the first return address are the same, an operation (408) of restoring the first key value with the first return address and storing the restored first key value in the register, and A computer-readable medium configured to perform an operation of terminating the second function and returning to the first function (409).

Citation Information

Patent Citations

  • Defense method for destructive attack to business processing program, business processing program and system thereof

    JP2003330563A

  • Method and apparatus for protecting kernel control-flow integrity using static binary instrumentaiton

    KR1020170055933A

  • Return Oriented Programming (ROP) Attack Protection

    US20160171211A1

  • Return address encryption

    US20180089427A1

  • Detection method of control flow attacks based on return address signatures

    US20210133314A1