Electronic apparatus and method for operating same

A kernel compiler segregates vulnerable variables from normal variables and inserts check codes to prevent malicious data from entering the kernel, addressing security vulnerabilities and enhancing system integrity.

WO2026235360A1PCT designated stage Publication Date: 2026-11-12SAMSUNG ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/KR2026/005895
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2025-05-28
Filing Date
2026-05-07
Publication Date
2026-11-12

AI Technical Summary

Technical Problem

Existing operating systems face vulnerabilities during kernel operations due to imperfect data validation and exception handling, leading to potential attacks that can result in user data leakage, hacking, and security disruptions, particularly when external data is copied into the kernel.

Method used

Implementing a kernel compiler that identifies and segregates vulnerable variables from normal variables by analyzing the kernel source code, allocating them to separate memory areas, and inserting check codes to prevent malicious data from being copied into the kernel.

Benefits of technology

Enhances kernel security by preventing unauthorized data access and tampering, thereby reducing the risk of attacks and maintaining system integrity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure KR2026005895_12112026_PF_FP_ABST
    Figure KR2026005895_12112026_PF_FP_ABST
Patent Text Reader

Abstract

An electronic apparatus according to the present disclosure comprises: a memory for storing at least one instruction; and at least one processor including a processing circuit, wherein the at least one instruction, when executed individually or collectively by the at least one processor, causes the electronic apparatus to: execute a kernel on the basis of a kernel image generated by compiling a kernel source including one or more copy codes and one or more inspection codes respectively corresponding to the one or more copy codes, and execute a first inspection code among the one or more inspection codes for determining whether a first copy target variable of a first copy code among the one or more copy codes is included in a potentially vulnerable group, execute the first copy code on the basis of the fact that the first inspection code among the one or more inspection codes corresponds to the first copy code among the one or more copy codes and the first copy target variable of the first copy code among the one or more copy codes is included in the potentially vulnerable group, and stop the kernel on the basis of the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the potentially vulnerable group.
Need to check novelty before this filing date? Find Prior Art

Description

Electronic device and method of operation of electronic device

[0001] The present disclosure relates to an electronic device and a method of operating the electronic device.

[0002] The kernel is a core computer program of the operating system (OS) that plays the role of completely controlling and managing all system resources. The kernel acts as an intermediary between hardware and software and provides various services to ensure the computer system operates normally.

[0003] In most operating systems, the kernel operates with elevated privileges during operation. Because it operates with elevated privileges, unintended (abnormal) behavior can lead to catastrophic consequences (e.g., user data leakage, hacking and rooting, interruption of specific operations, or shutdown of the entire system).

[0004] There are instances where data from outside the kernel is input and utilized during kernel operation. In such cases, if operations such as data validation and exception handling are not perfect, an attacker may attempt to trigger abnormal behavior intended by the attacker within the kernel by exploiting vulnerabilities and transmitting maliciously crafted data. Such abnormal behavior can result in consequences such as user data leakage, hacking, rooting, the disruption of security functions, and security bypasses.

[0005] Since the primary path for real-time kernel attacks occurs when data outside the kernel is copied into the kernel while the electronic device is powered on and the operating system is running, security enhancements may be necessary. Specifically, control data may be introduced into the kernel when functions such as copy_from_user(), which copy data from user space into the kernel, are executed, or when an external device such as a USB is connected.

[0006] The information described above may be provided as related art for the purpose of aiding understanding of the present disclosure. No claim or determination is made as to whether any of the foregoing may be applied as prior art related to the present disclosure.

[0007] One example of the present disclosure may provide an electronic device and a method of operating the electronic device.

[0008] An electronic device according to the present disclosure comprises a communication circuit; a memory for storing at least one instruction; and at least one processor including a processing circuit for executing said at least one instruction, wherein the at least one instruction may cause said data analysis device to perform at least one operation when executed individually or collectively by said at least one processor.

[0009] The above at least one operation may include: an operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of halting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0010] A method of operation of an electronic device according to the present disclosure may include at least one of the following: an operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of interrupting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0011] A computer-readable medium according to the present disclosure may store a program that commands the execution of a method of operation of an electronic device comprising at least one of the following: an operation of executing a kernel based on a kernel image generated by compiling a kernel source including one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group; wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of interrupting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0012] In relation to the description of the drawings, the same or similar reference numerals may be used for identical or similar components.

[0013] FIG. 1 is a block diagram of an electronic device in a network environment according to various examples of the present disclosure.

[0014] FIG. 2 is a diagram for explaining exemplary code and the sequence of operations of said code related to a method of operation of an electronic device according to one example of the present disclosure.

[0015] FIG. 3 is a diagram for explaining a pseudocode and the sequence of operations of the pseudocode related to a method of operation of an electronic device according to an example of the present disclosure.

[0016] FIG. 4 is an example diagram illustrating a memory allocation area of ​​kernel memory when a vulnerable potential group according to one example of the present disclosure is included in kernel memory.

[0017] FIG. 5 is an example diagram illustrating memory allocation areas inside and outside kernel memory when a vulnerable potential group according to one example of the present disclosure is not included in kernel memory.

[0018] FIG. 6 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0019] FIG. 7 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0020] FIG. 8 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0021] FIG. 9 is a flowchart for explaining a method of operation of an electronic device according to an example of the present disclosure.

[0022] FIG. 10 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0023] In the following description, the attached drawings are referenced, and specific examples of implementation are illustrated within the drawings. Additionally, other examples may be used and structural modifications may be made without departing from the scope of the various examples.

[0024] Hereinafter, embodiments of the present disclosure are described in detail with reference to the drawings so that those skilled in the art can easily practice them. However, the present disclosure may be embodied in various different forms and is not limited to the embodiments described herein. In relation to the description of the drawings, the same or similar reference numerals may be used for identical or similar components. Furthermore, in the drawings and related descriptions, descriptions of well-known functions and configurations may be omitted for clarity and brevity.

[0025] FIG. 1 is a block diagram of an electronic device in a network environment according to various embodiments of the present disclosure.

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

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

[0028] The auxiliary processor (123) may control at least some of the functions or states associated with at least one component of the electronic device (101) (e.g., display module (160), sensor module (176), or communication module (190)) 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. According to one embodiment, the auxiliary processor (123) (e.g., image signal processor or communication processor) may be implemented as part of another functionally related component (e.g., camera module (180) or communication module (190)). According to one embodiment, the auxiliary processor (123) (e.g., neural network processing unit) may include a hardware structure specialized for processing an artificial intelligence model. The artificial intelligence model may be generated through machine learning. Such learning may be performed, for example, on the electronic device (101) itself where the artificial intelligence is performed, or through a separate server (e.g., server (108)). The learning algorithm may 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 may include a plurality of artificial neural network layers.An artificial neural network may be 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 the hardware structure, the artificial intelligence model may include a software structure, either additionally or substantially.

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

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

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

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

[0033] The display module (160) can visually provide information to an external (e.g., 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 said device. According to 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 the force generated by said touch.

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

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

[0036] The interface (177) may support one or more specified protocols that can be used for the electronic device (101) to be connected directly or wirelessly to an external electronic device (e.g., electronic device (102)). According to 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.

[0037] The connection terminal (178) may include a connector through which the electronic device (101) can 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).

[0038] The haptic module (179) can convert an electrical signal into a mechanical stimulus (e.g., vibration or movement) or an electrical stimulus that the user can perceive through tactile or kinesthetic senses. According to one embodiment, the haptic module (179) may include, for example, a motor, a piezoelectric element, or an electric stimulation device.

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

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

[0041] The battery (189) can supply power to at least one component of the electronic device (101). According to one embodiment, the battery (189) may include, for example, a non-rechargeable primary battery, a rechargeable secondary battery, or a fuel cell.

[0042] The communication module (190) can support the establishment of a direct (e.g., wired) communication channel or a wireless communication channel between an 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 include one or more communication processors that operate independently of the processor (120) (e.g., application processor) and support direct (e.g., wired) communication or wireless communication. According to one embodiment, the communication module (190) may include a communication module (192) (e.g., cellular communication module, short-range communication module, or GNSS (global navigation satellite system) communication module) or a wired communication module (194) (e.g., LAN (local area network) communication module, or power line communication module). The corresponding communication module among these communication modules can communicate with an external electronic device (104) through a first network (198) (e.g., a short-range communication network such as Bluetooth, WiFi (wireless fidelity) direct, or IrDA (infrared data association)) or a second network (199) (e.g., 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 may be integrated into a single component (e.g., a single chip) or implemented as multiple separate components (e.g., multiple chips). The communication module (192) can identify or authenticate the electronic device (101) within a communication network such as the first network (198) or the second network (199) using subscriber information (e.g., International Mobile Subscriber Identifier (IMSI)) stored in the subscriber identification module (196).

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

[0044] An antenna module (197) can transmit a signal or power to or from an external source (e.g., an external electronic device). According to one embodiment, the antenna module (197) may include an antenna comprising a radiator made of a conductor or a conductive pattern formed on a substrate (e.g., a PCB). According to 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 a first network (198) or a second network (199), may be selected from the plurality of antennas, for example, by a 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. According to some embodiments, in addition to the radiator, other components (e.g., a radio frequency integrated circuit (RFIC)) may be additionally formed as part of the antenna module (197). 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 to a first surface (e.g., bottom surface) of the printed circuit board and capable of supporting a specified high frequency band (e.g., mmWave band), and a plurality of antennas (e.g., array antennas) disposed on or adjacent to a second surface (e.g., top surface or side surface) of the printed circuit board and capable of transmitting or receiving a signal of the specified high frequency band.

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

[0046] According to one embodiment, commands or data may be transmitted or received between the electronic device (101) and an external electronic device (104) through a server (108) connected to a second network (199). Each of the external electronic devices (102, or 104) may be the same or different type of device as the electronic device (101). According to one embodiment, all or part of the operations performed on the electronic device (101) may be performed on one or more of the external electronic devices (102, 104, or 108). For example, if the electronic device (101) needs to perform a function or service automatically or in response to a request from a user or another device, the electronic device (101) may request one or more external electronic devices to perform at least part of the function or service instead of performing the function or service itself or additionally. One or more external electronic devices that receive the above request may execute at least part of the requested function or service, or 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 provide the result as is or additionally processed as at least part of the response to the request. For this purpose, for example, cloud computing, distributed computing, mobile edge computing (MEC), or client-server computing technology may be used. The electronic device (101) may provide ultra-low latency services using, for example, distributed computing or mobile edge computing. In one embodiment, the external electronic device (104) may include an Internet of Things (IoT) device. The server (108) may be an intelligent server using machine learning and / or neural networks. According to one embodiment, the external electronic device (104) or the server (108) may be included within a 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.

[0047] The number of processors (120) may be one or more. For example, the processor (120) may have the structure of a multi-core processor such as a dual core, a quad core, or a hexa core.

[0048] The processor (120) can control the operations of the electronic device (101) by executing instructions stored in memory (130). For example, the processor (120) may correspond to a plurality of processors that divide and collectively perform a plurality of operations among the processors.

[0049] Regarding operating system kernel security, an attacker may attempt to cause abnormal behavior intended by the attacker to occur within the kernel by transmitting maliciously generated input values ​​to the kernel. Developers creating kernels, kernel modules, or drivers can directly implement input validation and exception handling for input values ​​transmitted from outside the kernel to prevent such attacker attempts. However, there is a practical difficulty in fully implementing validation and exception handling for every input value.

[0050] According to one example, by ensuring that input values ​​transmitted from outside the kernel are copied only within allowed areas, the possibility of attacks using malicious abnormal input values ​​from an attacker can be blocked.

[0051] According to one example, when the kernel is running (runtime), copying (writing) to kernel memory can be restricted as follows.

[0052]

[0053] According to one example, a function that can store or point to an input value from outside the kernel in memory inside the kernel can be called a kernel interface function. For example, within the proc_control() function in drivers / usb / core / devio.c, the control variable (ctrl variable) may be a variable belonging to a vulnerable group (vulnerable variable). Within the proc_control() function, USB control-related data (argument input value) can be copied to the control variable from user space, which is outside the kernel, through the copy_from_user() function.

[0054] According to one example, control variables can be classified into a vulnerable group by the compiler during kernel build (compilation). Since control variables can be local variables, they can be allocated a stack area, and control variables can belong to the vulnerable stack group. According to one example, during kernel execution (runtime), a control variable can be allocated stack memory when the line "struct usbdevfs_ctrltransfer ctrl;" is called within the proc_control() function. At this time, the control variable can be allocated memory in the vulnerable stack area.

[0055] According to one example, variables that store or point to external kernel input values ​​can be copied to one another, but copying to other areas (general variables) is blocked. According to the present disclosure, it is possible to block or reduce the possibility of attempting to tamper with an arbitrary area within the kernel or copy malicious data to an arbitrary area through a malicious external kernel input value.

[0056] According to one example, kernel stack memory may include at least one of a vulnerable area (vulnerable stack memory area) or a normal area (normal stack memory area). Kernel heap memory may include at least one of a vulnerable area (vulnerable heap memory area) or a normal area (normal heap memory area). For example, the kernel stack memory area may include a vulnerable stack memory area and a normal stack memory area, and the kernel heap memory area may include a vulnerable heap memory area and a normal heap memory area.

[0057] In the present disclosure, the distinction between stack and heap does not have any significance beyond the distinction between stack memory and heap memory; however, since the operating system provides stack memory and heap memory as memory allocation methods and there is a difference in the memory allocation methods of stack memory and heap memory, vulnerable areas and normal areas can be distinguished for each of stack memory and heap memory as described above. The operating system can process variables by physically and / or logically separating stack memory and heap memory. According to one example, by using a memory allocation method supported by the operating system, the memory area to be allocated to the vulnerable group and the memory area to be allocated to the normal group are distinguished, and a pre-set memory area is allocated to each group, and by checking the memory address of the variable, it is possible to determine whether the variable is a vulnerable variable or a normal variable.

[0058] According to one example, a kernel memory region may include at least one of a vulnerable memory region or a general memory region. A vulnerable memory region may include at least one of a vulnerable stack memory region and a vulnerable heap memory region. A general memory region may include at least one of a general stack memory region and a general heap memory region.

[0059] FIG. 2 is a diagram for explaining exemplary code and the sequence of operations of said code related to a method of operation of an electronic device according to one example of the present disclosure.

[0060] According to one example, a kernel compiler can perform kernel compilation by reviewing and modifying the kernel source before compiling it. The kernel compiler can obtain a list of kernel interface functions, which are copy codes that copy external input values ​​into the kernel. By analyzing the existing kernel source and examining the functions called for control / management when a USB device is connected, the kernel interface function list can be generated in advance. When compiling the kernel source, the kernel compiler obtains this list of kernel interface functions and can identify the kernel interface functions within the kernel source code to be built. For instance, functions that store input values ​​coming from outside the kernel, such as external interface modules like USB and Wi-Fi modules or functions like `copy_from_user()`, can be considered kernel interface functions.

[0061] According to one example, one can obtain a kernel interface function's copy target variable, other copy target variables that copy the value of that copy target variable, other copy target variables that store the address of that copy target variable, and chains of copy target variables extending from other copy target variables. When the compiler compiles the kernel, it can generate a list of copy target variables and designate it as a vulnerable group. The compiler can create a vulnerable group or a list of vulnerable variables by analyzing the kernel source. Users can manually add vulnerable variables they wish to add to a vulnerable group. Users can directly register vulnerable variables or regular variables into a vulnerable group (list of vulnerable variables) or a regular group. To prevent an attacker from forging or tampering with a vulnerable group, the vulnerable group can be included in the kernel code area. If the kernel is compiled with the vulnerable group included in the kernel code area, the vulnerable group can be protected from attacker tampering because, when the kernel image is tampered with by secure boot, the vulnerable group is also checked as part of the kernel image.

[0062] According to one example, a kernel compiler can obtain a list of kernel interface functions. A kernel interface function can be copy code that copies input values ​​from outside the kernel into the kernel. Based on the list of kernel interface functions, the kernel compiler can identify the kernel interface functions called from the kernel source.

[0063] Referring to Figure 2, the process of a kernel compiler analyzing kernel source code and registering a vulnerable variable into a vulnerable group is schematically illustrated. The kernel compiler can identify kernel interface functions within the kernel source code. In operation 230, the kernel interface function copy_from_user(vulnerable_stack, user_addr, 64) is called, and it is known that the contents of the user_addr variable are copied to the vulnerable_stack variable within the copy_from_user() function. At this time, the vulnerable_stack variable can be referred to as the variable to be copied. The kernel compiler can locate the declaration and / or allocation parts of vulnerable_stack to determine whether the variable (vulnerable_stack) is a stack variable or a heap variable. In operation 210, it is confirmed that the vulnerable_stack variable is declared as a stack variable, and the vulnerable_stack variable can be registered into the vulnerable group. "Registering the vulnerable_stack variable to the vulnerable group" means adding the vulnerable_stack variable to the list of vulnerable variables; if the vulnerable_stack variable is already in the vulnerable group, the process of registering it can be omitted instead of adding it redundantly. Even if the target variable is not registered to the vulnerable group, the insertion location of the check code and the input value of the check code (the address of vulnerable_stack) can be stored in order to insert check code that verifies whether the target variable is included in the vulnerable group before the kernel interface function that copies the variable to the target variable.According to the present disclosure, the operation of inserting a check code before a copy code can be performed (1) when registering a copy target variable to a vulnerable group, and (2) a check code insertion operation list can be created by storing the check code insertion location and the input value of the check code, and subsequently, a check code insertion operation can be performed based on the check code insertion list.

[0064] According to one example, the kernel compiler can identify copy code in the kernel source where the vulnerable_stack variable is copied to another target variable. For instance, in operation 260, it can be seen that the vulnerable_stack variable is copied to the vulnerable_heap variable (target variable) by the memcpy function, and in operation 270, it can be seen that the address of the vulnerable_stack variable is copied to the vulnerable_stack_ptr variable. The compiler finds the declaration and / or allocation part of the vulnerable_heap variable in operation 260 and can confirm that the vulnerable_heap variable is declared and allocated in operation 240. The vulnerable_heap variable is registered in the vulnerable potential group, and with the vulnerable_heap variable as the vulnerable potential variable, it can recursively check whether there is copy code (not shown) that copies the vulnerable potential variable to another target variable. In the same way, it can be confirmed that the vulnerable_stack_ptr variable is declared as a pointer variable in operation 270, and after registering the vulnerable_stack_ptr variable to the vulnerable group, it can be recursively checked whether there exists (not shown) copy code that copies the vulnerable_stack_ptr variable (the variable to be copied) to another variable to be copied. Until there are no more vulnerable variables to be registered to the vulnerable group, the task of finding copy code that copies the vulnerable variable to another variable to be copied to another variable and registering the vulnerable variable to the vulnerable group with the other variable to be copied can be performed recursively.

[0065] According to one example, in operation 220, the normal_stack variable is declared and assigned as a stack variable. The normal_stack variable is a normal variable and is not a variable registered in the vulnerable group. In operation 250, the normal_heap variable is declared and assigned as a heap variable. The normal_heap variable is a normal variable and is not a variable registered in the vulnerable group.

[0066] According to one example, the kernel source is compiled so that the kernel can operate according to operation 210, operation 220, operation 230, operation 240, operation 250, operation 260, and operation 270. Specifically, in operation 210, vulnerable_stack can be declared as a stack variable. In operation 220, normal_stack can be declared as a stack variable. The kernel compiler can analyze the kernel source and confirm that the vulnerable_stack variable is a vulnerable variable registered in the vulnerable group, and that the normal_stack variable is a normal variable not registered in the vulnerable group. Therefore, when performing the variable declaration and memory allocation operations of operations 210 and 220, the memory allocation function can be implemented such that the vulnerable variable is allocated to the vulnerable memory area and the normal variable is allocated to the normal memory area. In operation 230, the user_addr, an input value from outside the kernel, can be copied to the vulnerable_stack variable, thereby registering the target variable (vulnerable_stack variable) in the vulnerable group. In operation 240, the vulnerable_heap variable can be declared as a heap variable and memory can be allocated (kmalloc) to that variable. In operation 250, the normal_heap variable can be declared as a heap variable and memory can be allocated (kmalloc) to that variable. Since the kernel compiler can analyze the kernel source to confirm that the vulnerable_heap variable is a vulnerable variable registered in the vulnerable group and that the normal_heap variable is a normal variable not registered in the vulnerable group, when performing the variable declaration and memory allocation operations of operations 240 and 250, the memory allocation function can be implemented such that the vulnerable variable (vulnerable_heap variable) is allocated to the vulnerable memory area and the normal variable (normal_heap variable) is allocated to the normal memory area.In operation 260, the value of the vulnerable_stack variable can be copied to the vulnerable_heap variable, so that the variable to be copied (vulnerable_heap variable) can be registered in the vulnerable group. In operation 270, the vulnerable_stack_ptr variable can be declared, and the address value of the vulnerable_stack variable can be copied to the vulnerable_stack_ptr variable (pointer).

[0067] According to the present disclosure, operations 210, 220, 230, 240, 250, 260, and 270 may be implemented in order in the kernel source, and the order of at least one of operations 210, 220, 230, 240, 250, 260, and 270 may be changed. The vulnerable_stack variable and vulnerable_heap variable declared in operations 210 and 240 may be a stack variable and a heap variable, respectively, and may be referred to as vulnerable variables. The normal_stack variable and normal_heap variable declared in operations 220 and 250 may correspond to variables to which input values ​​from outside the kernel cannot be copied. Vulnerable variables may be registered in a vulnerable group. Normal variables may be registered in the normal group, but there may be no separate procedure for registering normal variables, and variables not registered in the vulnerable group may be referred to as normal variables. In Figure 2, for ease of understanding, variable names were named to include the expression "vulnerable" for variables to be registered in the vulnerable group; however, vulnerable variables and normal variables are not distinguished based on their names. Instead, the copy target variable to which the kernel external input value is copied, and other copy target variables to which the copy target variable is copied, are considered vulnerable variables, and this can be obtained by the compiler analyzing the kernel source. Meanwhile, if a vulnerable group is generated by analyzing the kernel source, a separate memory allocation function can be implemented to allocate the variables belonging to the vulnerable group (vulnerable variables) to memory.Instead of a function that allocates vulnerable variables (e.g., kmalloc), a separately implemented memory allocation function can be applied to the vulnerable variables.

[0068] According to one example, vulnerable variables and ordinary variables can be treated differently during the variable declaration and memory allocation processes. For instance, vulnerable variables and ordinary variables can be declared using different data types, and by using different data types, they can be allocated to different memory regions. Additionally, memory for vulnerable variables and ordinary variables can be allocated using different memory allocation functions. For instance, memory for ordinary variables can be allocated using the existing kernel memory allocation function kmalloc(), while memory for vulnerable variables can be allocated by implementing a separate function called vkmalloc(). For instance, since kmalloc and vkmalloc can allocate memory in different memory regions, it is possible to determine whether a variable is ordinary or vulnerable by examining the allocated memory address.

[0069] According to one example, when normal variables and vulnerable variables are allocated and used in different memory areas, kernel memory can be divided into a vulnerable area and a normal area, and stack variables and heap variables can be allocated within each area. The vulnerable area can be called the vulnerable memory area, and the normal area can be called the normal memory area. Since the compiler can distinguish between vulnerable variables and normal variables when compiling the kernel, and the user can arbitrarily specify vulnerable variables or normal variables as needed, all variables using kernel memory in the kernel source can be classified as vulnerable variables or normal variables by analyzing the kernel source. Vulnerable variables can be grouped and referred to as the vulnerable group (list of vulnerable variables), and normal variables can be grouped and referred to as the normal group (list of normal variables). According to one example, a list of vulnerable variables and a list of normal variables can be created in advance, and a memory allocation function can be implemented that allocates to vulnerable areas and normal areas corresponding respectively to the vulnerable variables and normal variables. For instance, depending on whether a vulnerable variable is a stack variable or a heap variable, it can be allocated to a vulnerable stack memory area or a vulnerable heap memory area within the vulnerable memory areas. Similarly, depending on whether a normal variable is a stack variable or a heap variable, it can be allocated to a normal stack memory area or a normal heap memory area within the normal memory areas. According to one example, a specific area of ​​kernel memory can be set as a vulnerable area, and vulnerable variables can be allocated to the vulnerable area, while normal variables can be processed by distinguishing between normal variables and vulnerable variables using the existing kernel memory allocation method.

[0070] According to one example, since potential vulnerability groups can be generated before kernel compilation, the kernel can acquire these groups during execution, and the kernel can determine whether a variable for which memory is to be allocated belongs to a potential vulnerability group. Therefore, even when using the same memory allocation function, the kernel compiler may allocate memory to the potential vulnerability memory area when allocating memory for a potential vulnerability variable during the compilation process, and allocate it to the general memory area when allocating memory for a non-potential vulnerability variable or a regular variable.

[0071] According to one example, vulnerable variables and ordinary variables are treated identically during the variable declaration and memory allocation processes; however, variables to which external input values ​​are copied are registered in the vulnerable group and treated as vulnerable variables, while variables that do not fall under the vulnerable group are treated as ordinary variables.

[0072] According to one example, a compiler can compile kernel source code to be compiled into an executable program. According to the present disclosure, before compiling the kernel source code, the compiler can analyze the kernel source code, modify the kernel source code to add kernel security features, and then compile the kernel source code.

[0073] According to one example, the compiler can find part of operation 230 within the kernel source to be compiled where a function is executed to store an input value from outside the kernel into a variable inside the kernel. For instance, a function that stores an input value from outside the kernel into a variable inside the kernel could be the copy_from_user function, which copies a variable used in user space into a kernel-in-the-in-the-in-the-in-the-in-the-in-the-in-the-in-the-kernel, which is the source variable (src), is an input value from outside the kernel and is a function that copies the source variable (src), which is an input value from outside the kernel, to the target variable (dest), which is an kernel-in-thekernel, and this can be called copy code.

[0074] According to one example, the declaration or allocation part of the vulnerable variable, which is the input value of the copy_from_user() function, can be found in the kernel source. In operation 210, the part of operation 210 that declares the vulnerable_stack variable, which is the target variable for copying by the copy_from_user() function, or allocates memory can be found. In operation 210, the vulnerable_stack variable is declared as a stack variable, and the vulnerable_stack variable can be registered as a stack variable in the vulnerable group. At this time, the vulnerable group can be divided into stack and heap, and can be divided into other elements other than stack and heap as needed. When registering a vulnerable variable in the vulnerable group, a function (test code) that can check the vulnerable variable can be placed before the function where the vulnerable variable is used (e.g., the copy_from_user function). That is, the compiler can modify the source code before compiling to check for input values ​​outside the kernel before they are copied into the kernel (operation 230). If the variable to be copied does not belong to a vulnerable group (where the vulnerable_stack variable is modified by an attacker when the program is executed), the compiler can prevent copying to the target variable modified by an attacker by not executing the copy code (operation 230) and performing error handling. The error handling operation described above may include at least one of kernel panic operation, violation occurrence, blocking device operation, blocking copy operation, user warning (notification), error report, or logging only.

[0075] According to one example, a specific vulnerable variable registered in a vulnerable group may be copied to another target variable (operation 260), or the address of the vulnerable variable may be copied to another target variable whose address is a pointer variable (operation 270). As described above, operation 260, which is the part where a specific vulnerable variable is copied to another target variable, can be checked, and for the variable to be copied (vulnerable_heap), operation 240, which is the part where the variable is declared or memory is allocated, can be checked. In operation 240, it can be checked that memory is allocated to the vulnerable_heap variable as a heap variable, and the vulnerable heap variable can be registered in the vulnerable heap group. At this time, the vulnerable group may include at least one of the vulnerable stack group and the vulnerable heap group, and may include other groups other than the vulnerable stack group and the vulnerable heap group as needed. A function (check code) that can check whether the vulnerable_heap variable is included in the vulnerable group can be placed before the memcpy function (operation 260). That is, when the compiler modifies the source code before compiling and the program is executed, it checks whether the other copy target variable described above is a vulnerable variable before the vulnerable variable is copied to another copy target variable (operation 260). If the other copy target variable is a variable that does not belong to the vulnerable group (when the vulnerable_heap variable is modified by an attacker when the kernel program is executed), the copy operation (operation 260) is not performed, and error handling is performed to prevent copying to the variable. The error handling operation described above may include at least one of a kernel panic operation or violation occurrence, blocking device operation, blocking copy operation, user warning, or logging only.

[0076] According to one example, when the address of a specific vulnerable variable is copied to another target variable that is a pointer variable as described above (Operation 270), for the target variable (vulnerable_stack_ptr), operation 270, which is either a variable declaration part or a memory allocation part, can be found. In operation 270, the vulnerable_stack_ptr variable is declared as a pointer variable, and since the address of the vulnerable_stack variable is being copied, it can be registered in the vulnerable group. At this time, the vulnerable group may include at least one of the vulnerable stack group and the vulnerable heap group, and the vulnerable_stack_ptr variable can be registered in the vulnerable stack group. A function (check code) that can check whether the vulnerable_stack_ptr variable is included in the vulnerable group can be placed before the line where the pointer is copied. That is, the compiler can modify the source code before compiling so that when the program is executed, it checks whether the other target variable is a vulnerable variable before the pointer of the vulnerable variable is copied to the pointer of another target variable (operation 270). If the other target variable is a variable that does not belong to the vulnerable group (if the vulnerable_stack_ptr variable is modified by an attacker when the program is executed), it does not perform the copy operation (operation 270) and performs error handling to prevent copying to the target variable modified by the attacker. The error handling operation described above may include at least one of kernel panic operation or violation occurrence, blocking device operation, blocking copy operation, user warning, or logging only.

[0077] Figure 2 illustrates an example where an input value from outside the kernel is copied to vulnerable_stack, the vulnerable_stack variable is copied to a heap variable, and a pointer is copied to a pointer variable. If the vulnerable_heap variable or vulnerable_stack_ptr variable in Figure 2 is copied to another target variable or the pointer is copied to another pointer variable, the process of registering the target variable to a vulnerable group and inserting a check code before the copy code will be repeated.

[0078] According to one example, vulnerable variables and normal variables are not distinguished in the variable declaration or memory allocation sections, and targets that are copied recursively starting from external kernel input values ​​are registered as vulnerable variables, while variables not registered as vulnerable variables (e.g., normal_heap variables, normal_stack variables) can be treated as normal variables.

[0079] According to one example, vulnerable variables and ordinary variables can be distinguished in the variable declaration or memory allocation sections. Implementations can be implemented to declare a variable as vulnerable or allocate vulnerable variables to vulnerable memory. In other words, the kernel source can be modified to allocate memory for vulnerable variables or to declare variables as vulnerable variables. In this case, when a variable is declared or memory is allocated as vulnerable, its memory address or storage space is assigned to a specific location in memory, allowing it to be distinguished from the memory of ordinary variables. Because vulnerable variables are allocated to specific memory regions, it is possible to quickly determine whether a variable is vulnerable without having to check the list of vulnerable variables in the vulnerable group.

[0080] If the values ​​or addresses of variables belonging to a vulnerable group are copied to other variables in kernel memory, and the target variable is a regular variable, the copy operation may be blocked. Actions to block the copy operation may include at least one of the following: causing a kernel panic or violation, blocking device operation, blocking the copy operation, issuing a user warning, or logging only. When the kernel compiler compiles the kernel, if there is copy code that copies the value of a variable belonging to a vulnerable group to another target variable, an instruction (check code) that performs a check on the vulnerable variable before the copy operation may be inserted. According to one example, instead of inserting check code, the aforementioned copy code may be replaced with a single integrated code that performs both the check code and the copy code at once. Generally, performing the copy code and the check code as a single instruction (integrated instruction) can be provided by hardware (processors such as CPUs, GPUs, TPUs, and APUs) and can improve performance compared to inserting copy code. If the processor supports integrated instruction capabilities (hardware support), performance can be improved by using hardware-supported acceleration features.

[0081] FIG. 3 is a diagram for explaining a pseudocode and the sequence of operations of the pseudocode related to a method of operation of an electronic device according to an example of the present disclosure.

[0082] The parenthesized characters in Fig. 3 mean the following.

[0083] (1): Check the declaration and allocation parts (action 320) of the target variable (vulnerable_stack) of the copy_from_user function (kernel interface function, copy code).

[0084] (2): Insert a function that validates the target variable (vulnerable_stack) (validation code) (action 350) before the copy_from_user function (copy code) (action 355).

[0085] (3): Check the function (memcpy) (operation 365) that copies the vulnerable_stack variable to the target variable (vulnerable_heap).

[0086] (4): Check the declaration and memory allocation (operation 310) of the target variable (vulnerable_heap) of the memcpy function (copy code) (operation 365).

[0087] (5): Insert a function (validation code) (action 360) that validates the target variable (vulnerable_heap) before the memcpy function (copy code).

[0088] (6): Check the code that copies the pointer to the vulnerable_stack variable (copy code) (action 375).

[0089] (7): Insert the function (operation 370) that validates the target variable (vulnerable_stack_ptr) before operation 375.

[0090] Referring to FIG. 3, in operation 310, the vulnerable_heap variable can be declared as a heap variable and memory for the vulnerable_heap variable can be allocated (kmalloc). In operation 315, the normal_heap variable can be declared as a heap variable and memory for the normal_heap variable can be allocated (kmalloc). In operation 320, the vulnerable_stack variable can be declared as a stack variable. In operation 325, the normal_stack variable can be declared as a stack variable. In operation 350, it can be checked whether the vulnerable_stack variable is a vulnerable variable belonging to a vulnerable group. If the vulnerable_stack variable is a vulnerable variable, the subsequent copy code (operation 355) is executed, and if the vulnerable_stack variable is not a vulnerable variable, the copy code is not executed, and error handling is performed. The above-described error handling operation may include at least one of kernel panic operation or violation occurrence, blocking device operation, blocking copy operation, user warning, or logging only. In operation 355, the user_addr input value from outside the kernel can be copied to the vulnerable_stack variable. In operation 360, it can be checked whether the vulnerable_heap variable is a vulnerable variable belonging to the vulnerable group. If the vulnerable_heap variable is a vulnerable variable, the subsequent copy code (operation 365) will be executed; if the vulnerable_heap variable is not a vulnerable variable, the copy code will not be executed, and error handling will be performed. In operation 365, the value of the vulnerable_stack variable can be copied to the vulnerable_heap variable. In operation 370, it can be checked whether the vulnerable_stack_ptr variable is a vulnerable variable belonging to the vulnerable group.If the vulnerable_stack_ptr variable is a vulnerable variable, the subsequent copy code (operation 375) will be executed, and if the vulnerable_stack variable is not a vulnerable variable, the copy code will not be executed and error handling will be performed. In operation 275, the vulnerable_stack_ptr variable can be declared, and the address of the vulnerable_stack variable can be copied to the vulnerable_stack_ptr variable (pointer).

[0091] According to the present disclosure, operations 310, 315, 320, 325, 350, 355, 360, 365, 370, and 375 may be implemented in order in the kernel source, and the order of at least one of operations 310, 315, 320, 325, 350, 355, 360, 365, 370, and 375 may be changed. The vulnerable_heap variable and vulnerable_stack variable declared in operations 310 and 320 may be a heap variable and a stack variable, respectively, and may be called vulnerable variables. The normal_heap and normal_stack variables declared in operations 315 and 325 may be variables to which input values ​​from outside the kernel cannot be copied. Vulnerable variables may be registered in the vulnerable group. Normal variables may also be registered in the normal group, but there is no separate procedure for registering normal variables, and therefore the normal group may not exist. If the normal group does not exist, variables not registered in the vulnerable group may be considered as normal variables.

[0092] According to one example, a compiler can find a function (operation 355) among the source code to be compiled that stores an input value from outside the kernel into a variable inside the kernel. For instance, a function that stores an input value from outside the kernel into a variable inside the kernel can be called a kernel interface function. The copy_from_user function, which copies a variable used in user space to a kernel internal variable, can be a kernel interface function. The copy_from_user(char *dest, char *src, int size) function can be a function that copies src, an input value from outside the kernel, to dest, a kernel internal variable.

[0093] According to one example, it can be confirmed that the variable to be copied by the copy_from_user function is the vulnerable_stack variable, and operation 320, which is the declaration or memory allocation part of the vulnerable_stack variable to be copied, can be found, and it can be confirmed that the vulnerable_stack variable is declared as a stack variable in operation 320. The vulnerable_stack variable can be registered as a stack variable in a vulnerable group managed by the kernel. At this time, the vulnerable group may include at least one of a vulnerable stack group or a vulnerable heap group. A function (check_write_target function) (check code) (operation 350) that can check whether the vulnerable_stack variable is included in a vulnerable group can be placed before the copy_from_user function. That is, the compiler can modify the kernel source code before compiling so that when the kernel program is executed, the kernel external input value is checked for a vulnerable variable (operation 350) before the kernel internal copy operation (operation 355) is performed. If the variable to be copied is a variable that does not belong to a vulnerable group (if the vulnerable_stack variable is modified by an attacker when the program is executed), the copy operation is not performed, and an error handling (not shown) is performed to prevent copying to that variable.

[0094] According to one example, a specific vulnerable variable registered in a vulnerable group may be copied to another target variable (operation 365), or the address of the vulnerable variable may be copied to another target variable whose address is a pointer variable (operation 375). As described above, when a specific vulnerable variable is copied to another target variable (operation 365 or operation 375), the declaration or memory allocation part of the variable to be copied (vulnerable_heap or vulnerable_stack_ptr) can be found. Since the vulnerable_heap variable can be identified as allocating memory as a heap variable in operation 310, it may be registered in the vulnerable group or registered as a heap variable in the vulnerable group. At this time, stack variables and heap variables may be registered separately in the vulnerable group, or stack variables and heap variables may be registered without distinction. A function (check_write_target function) (action 360) that checks whether the vulnerable_heap variable is included in the vulnerable group can be placed before the memcpy function (copy code). That is, the source code can be modified before the compiler compiles so that when the kernel program is executed, the vulnerable_heap variable is checked (action 360) to be a vulnerable variable before the vulnerable variable is copied to another variable (action 365). If the variable to be copied does not belong to the vulnerable group (if the vulnerable_heap variable is modified by an attacker when the program is executed), the copy code is not executed, and an error is handled to prevent copying to that variable.

[0095] According to one example, when the address of a specific vulnerable variable is copied to another target variable that is a pointer variable as described above (Operation 375), the variable declaration or memory allocation part of the target variable (vulnerable_stack_ptr) can be found. Since the vulnerable_stack_ptr variable is declared as a pointer variable in Operation 375, it can be registered in the vulnerable group. At this time, the vulnerable group can be distinguished between the stack and the heap, and the vulnerable_stack_ptr variable can be registered as a stack variable. A function (check_write_target function) (Operation 370) that checks whether the vulnerable_stack_ptr variable is included in the vulnerable group can be placed before the line where the pointer is copied. That is, the compiler can modify the kernel source code before compiling the kernel so that when the kernel program is executed, it checks whether the other target variable is a vulnerable variable (operation 370) before the pointer of the vulnerable variable is copied to the pointer of another target variable (operation 375). If the target variable is a variable that does not belong to the vulnerable group (when the vulnerable_stack_ptr variable is modified by an attacker when the program is executed), it does not execute the copy code and performs error handling to prevent copying to that variable.

[0096] Figure 3 illustrates an example where an input value from outside the kernel is copied to vulnerable_stack, the vulnerable_stack variable is copied to a heap variable, and a pointer is copied to a pointer variable. Additionally, when the vulnerable_heap variable or vulnerable_stack_ptr variable is copied to another variable or a pointer is copied to another pointer variable, the process of registering to the vulnerable group and inserting checking code before the copying operation will be repeated. Referring to Figure 3, vulnerable variables and normal variables are not distinguished in the variable declaration or memory allocation parts; rather, starting from the input value from outside the kernel, targets that are copied recursively are registered as vulnerable variables in the vulnerable group, and variables that are not registered as vulnerable variables (normal heap variable, normal stack variable) can be treated as normal variables. However, through the process described in Fig. 3, the variables to be registered as vulnerable variables are identified. Therefore, before compiling the kernel, the variable declaration or variable allocation sections of the kernel source can be modified to allocate memory to the vulnerable variables in the vulnerable memory area or to modify the code to declare the variables as vulnerable variables. Alternatively, memory can be allocated by distinguishing between vulnerable variables and ordinary variables, and memory can be allocated by differentiating the memory allocation areas depending on whether the vulnerable variables and ordinary variables are stack variables or heap variables. In this case, the memory address or memory storage space of the vulnerable variable that has been declared or allocated memory can be assigned to a specific location in memory. Since the vulnerable variables are allocated to a specific memory area, it is possible to quickly determine whether the variable is a vulnerable variable without checking the list of vulnerable groups.

[0097] FIG. 4 is an example diagram illustrating a memory allocation area of ​​kernel memory when a vulnerable potential group according to one example of the present disclosure is included in kernel memory.

[0098] According to one example, kernel memory (400) may include a vulnerable area (410), a general area (420), and a vulnerable group (430). The vulnerable area (410) may include a vulnerable stack memory area (413) and a vulnerable heap memory area (416). The general area (420) may include a general stack memory area (423) and a general heap memory area (426). The vulnerable group (430) may include a vulnerable stack group (433) and a vulnerable heap group (436). The vulnerable group (430) may include a list of vulnerable variables (vulnerable variable list). A vulnerable stack group (433) may include a list of stack variables among vulnerable variables (vulnerable stack variable list), and a vulnerable heap group (436) may include a list of heap variables among vulnerable variables (vulnerable heap variable list). According to one example, a vulnerable group (430) may include a list of vulnerable variables (vulnerable variable list) without distinction between the vulnerable stack group (433) and the vulnerable heap group (436).

[0099] According to one example, kernel memory (400) can be divided into a vulnerable area and a normal area, and stack variables and heap variables can be managed and allocated within each area as in the past. According to one example, a stack memory area and a heap memory area can be divided, and within the stack memory, a vulnerable area and a normal area can be divided, and within the heap memory area, a vulnerable area and a normal area can be divided to allocate memory areas. According to one example, a vulnerable group can be included in the kernel code area. If the kernel code area includes a vulnerable group, since a tampering check for the kernel code area is performed by secure boot during booting, the tampering of the vulnerable group can also be checked. According to one example, the vulnerable group can be placed as a file outside the kernel code area. In this case, when the kernel reads the vulnerable group from a file outside the kernel, a tampering check for the vulnerable group can be performed.

[0100] According to one example, if a compiler analyzes the kernel source and an input value from outside the kernel is copied to a vulnerable variable or if a vulnerable variable is copied to another vulnerable variable, the vulnerable variable may be registered in a vulnerable group (430). Vulnerable variables may be forged or modified by an attacker after compilation. A verification function (inspection code) that verifies the vulnerable variable may be inserted before a function that takes the vulnerable variable as the target variable for copying, and the verification function can determine whether the vulnerable variable being verified belongs to a vulnerable group. However, since vulnerable groups may be forged or modified by an attacker, if vulnerable groups are added to the kernel code area during compilation, when a forgery check of the kernel image is performed by secure boot, the vulnerable group is also checked for forgery as part of the kernel image, thus preventing forgery of the vulnerable group.

[0101] According to one example, when a kernel compiler compiles the kernel, it analyzes the kernel source code and can insert check code before the copy code when the copy code is executed and the contents or address are copied to the target variable. If the target variable is not a potentially vulnerable variable, error handling, such as triggering a panic, will be performed.

[0102] The method of operation of an electronic device according to the present disclosure may operate as a build script or as part of the compiler when the compiler compiles the kernel. According to the present disclosure, code in the kernel source code where memory copying occurs may be identified, and whether the variable to be copied belongs to a vulnerable group or a general group may be determined, and a list of variables belonging to each group may be generated. A vulnerable group containing a list of vulnerable variables and / or a general group containing a list of general variables may be generated at the time of building the kernel, and the generated lists may be included in the kernel code area to prevent tampering when the kernel is compiled. When the generated lists are included in the kernel code area when the kernel is compiled, when kernel code tampering checks are performed by secure boot during booting, the lists may also be checked for tampering as part of the kernel code. The generated lists may be stored as separate files outside the kernel, and if they are stored as separate files outside the kernel, a separate method such as an electronic signature or authentication capable of preventing tampering may be applied to the said file. When the kernel executes, it can obtain a list of vulnerable variables and a list of normal variables to determine whether the variable to be copied is a vulnerable variable or a normal variable.

[0103] According to one example, when the kernel is running (runtime), check code (check command) can operate as part of the kernel. The check code is called before copy code that copies to a specific variable is executed, and it can determine whether to permit the copy code by checking whether the target variable is a potentially vulnerable variable.

[0104] FIG. 5 is an example diagram illustrating memory allocation areas inside and outside kernel memory when a vulnerable potential group according to one example of the present disclosure is not included in kernel memory.

[0105] Referring to FIG. 5, kernel memory (500) may include a vulnerable area (510) and a general area (520). Unlike FIG. 4, the vulnerable group (530) may be stored outside the kernel memory. Each of 500, 510, 513, 516, 520, 523, 526, 530, 533, and 536 in FIG. 5 corresponds to 400, 410, 413, 416, 420, 423, 426, 430, 433, and 436 in FIG. 4, but differs from 430, 433, and 436 in FIG. 4 in that 530, 533, and 536 in FIG. 5 exist outside the kernel memory. The vulnerable area (510) may include a vulnerable stack memory area (513) and a vulnerable heap memory area (516). The general area (520) may include a general stack memory area (523) and a general heap memory area (526). The vulnerable group (530) may include a vulnerable stack group (533) and a vulnerable heap group (536). The vulnerable group (530) may include a list of vulnerable variables (vulnerable variable list). The vulnerable stack group (533) may include a list of stack variables among the vulnerable variables (vulnerable stack variable list), and the vulnerable heap group (536) may include a list of heap variables among the vulnerable variables (vulnerable heap variable list).

[0106] According to one example, when a compiler analyzes the kernel source and an input value from outside the kernel is copied to a vulnerable variable or a vulnerable variable is copied to another vulnerable variable, the vulnerable variable that is the target of the copy may be registered in a vulnerable group (530). After compilation, the vulnerable variable may be forged or modified by an attacker's attack. A verification function (inspection code) that verifies the vulnerable variable may be inserted before a function that has the vulnerable variable as the target variable for copying, and the verification function may verify whether the vulnerable variable being verified belongs to a vulnerable group.

[0107] According to one example, a list of vulnerable variables and / or a list of general variables may be included in the kernel code area or stored as a separate file outside the kernel. If the list of vulnerable variables is stored as a separate file outside the kernel, it is necessary to apply tamper-proof methods to prevent an attacker from tampering with the list of vulnerable variables. For instance, methods that make tampering very difficult, or methods that detect tampering when reading the list of vulnerable variables even if tampering occurs, may be applied.

[0108] According to one example, the list can be included in the kernel code area to prevent tampering. If the kernel is built (compiled) with the list of potentially vulnerable variables (potential vulnerability groups) included in the kernel code area, the list can be protected from tampering because, when the kernel image (compiled kernel code) is checked for tampering by secure boot during booting, the list is also checked as part of the kernel image.

[0109] According to one example, the aforementioned secure boot is a technology widely applied to various IT devices, including Android, and can verify whether the boot loader and kernel image have been tampered with when the device boots. The secure boot can perform an operation to verify whether the boot loader and kernel image are the manufacturer's official boot loader and official kernel image.

[0110] According to one example, potential vulnerability groups can be stored outside the kernel rather than within the kernel code area. In this case, since potential vulnerability groups can be forged or altered by an attacker, an electronic signature method can be applied to prevent forgery and alteration of the potential vulnerability groups.

[0111] In the present disclosure, tampering with a potentially vulnerable group can be prevented by performing an electronic signature on a potentially vulnerable group in a hardware security module (HSM) or server, and then receiving a public key from the HSM or server to decrypt the electronic signature.

[0112] According to one example, an electronic signature can be generated using mathematical formula 1 and mathematical formula 2.

[0113]

[0114]

[0115] According to one example, the original message may be a list of vulnerable variables of a vulnerable group. A hash string (H) is generated using a hash function with the list of vulnerable variables as the original message, and a file encrypted using H and a private key as input can be used as a digital signature. An HSM or server may provide a string with the digital signature attached to the original message and may provide a public key capable of decrypting the digital signature.

[0116] According to one example, an electronic signature can be decrypted by mathematical formulas 3 and 4.

[0117]

[0118]

[0119] According to one example, when creating a potential vulnerability group, a string combining a public key and a signature on the original message is received from an HSM or server. The public key can be included in the kernel code area to compile the kernel, and since the kernel image is checked for tampering by Secure Boot, tampering with the public key included in the kernel code area can be prevented. According to one example, public keys can also be managed based on certificates. The string combining the signature on the received original message can be stored as a file outside the kernel.

[0120] According to one example, by decomposing a string, the original message and signature are obtained, and the hash value H' can be obtained from the original message according to Equation 3. Then, by decrypting using the digital signature and the public key included in the kernel code area, H can be obtained. By verifying whether H and H' are identical, it can be confirmed that the original message has not been forged or altered.

[0121] In the present disclosure, the anti-tampering method using mathematical formulas 1 to 4 is exemplary, and various electronic signature methods or encryption techniques capable of preventing tampering may be used.

[0122] FIG. 6 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0123] The method of operation of an electronic device according to the present disclosure may include a method for preventing kernel attacks.

[0124] According to one example, when compiling the kernel, a group of potential vulnerabilities can be generated, and inspection code for that group can be inserted into the kernel source.

[0125] According to one example, a list of kernel interface functions, which are functions that copy external kernel input values ​​into the kernel, can be determined in advance, and a user can generate a list of kernel interface functions by directly examining the kernel interface functions. In operation 605, a list of kernel interface functions including functions that copy external kernel input values ​​into the kernel can be obtained. In operation 610, a kernel compiler or build script can check whether kernel interface functions exist in the kernel source based on the list of kernel interface functions. If kernel interface functions do not exist in the kernel source (No in operation 610), the procedure (modification of kernel source) can be terminated, and the kernel source code can be compiled (not shown).

[0126] According to one example, if kernel interface functions exist in the kernel source (example of operation 610), the variables to be copied by the kernel interface functions can be determined as potentially vulnerable variables (operation 620). The list of kernel interface functions may include functions that copy external input values ​​into the kernel, such as the copy_from_user() function and functions called to control / process the device when a USB device is connected.

[0127] According to one example, in operation 620, the copy target variable can be identified in a function (kernel interface function) that copies an external kernel input value into the kernel. In operation 255 of FIG. 2, the vulnerable_stack variable corresponds to the copy target variable. The declaration part and / or memory allocation part of the copy target variable in the kernel interface function can be identified. Operation 220 of FIG. 2 may correspond to the declaration part and memory allocation part of the vulnerable_stack variable. In operation 620, the copy target variable is determined to be a vulnerable variable, and in operation 630, the vulnerable variable can be registered in a vulnerable group. While registering the vulnerable variable in the vulnerable group, code that checks the copy target variable (check code) can be inserted before the kernel interface function (copy code). However, instead of inserting a check code whenever a copy code is found, a check code list containing the location where the check code is to be inserted and the target (copy target variable) to be checked by the check code can be stored in memory, and then an operation (operation 660) of inserting a check code based on the check code list can be performed for each kernel interface function. The check code can check whether the copy target variable belongs to a vulnerable group, and if it belongs to a vulnerable group, the copy code can be executed, and if it does not belong to a vulnerable group, the copy code can be not executed and error handling can be performed.

[0128] According to one example, in operation 640, it can be checked whether a vulnerable variable is copied to another copy target variable, or whether a pointer to a vulnerable target variable is copied to another copy target variable. In operation 650, based on the confirmation that a copy target variable is copied to another copy target variable or that a pointer to a copy target variable is copied to another copy target variable (example of operation 640), the other copy target variable is determined to be a vulnerable variable, and in operation 630, the vulnerable variable can be registered in the vulnerable group. As described above, a list of check codes containing the location where the check code is to be inserted and the target (copy target variable) to be checked by the check code is stored in memory, and the check code can be inserted before the copy code based on the list of check codes for each kernel interface function (operation 660). That is, by determining the other copy target variable as a vulnerable variable, the operations described above (operations 630, 640, and 650) can be executed recursively. That is, operations 630, 640, and 650 will be performed repeatedly until there are no more copy target variables to be copied from the determined vulnerable potential variables.

[0129] According to one example, if it is determined that a vulnerable variable is being copied to another copy target variable (No in operation 640), the other copy target variable is determined as the new vulnerable variable, and the vulnerable variable can be registered in the vulnerable group in operation 630. Meanwhile, before registering the vulnerable variable in the vulnerable group, the declaration part and / or memory allocation part of the vulnerable variable can be checked. Operation 210 of FIG. 2 shows the declaration part and memory allocation part of the vulnerable_heap variable. The vulnerable_heap variable can be allocated by the kmalloc function, which allocates kernel memory.

[0130] According to one example, if it is determined that the pointer of a copy target variable is being copied to another copy target variable (No in operation 640), the other copy target variable is determined as a new vulnerable variable, and the vulnerable variable can be registered in the vulnerable group in operation 630. Likewise, the declaration part and / or memory allocation part of the vulnerable variable can be checked before registering it in the vulnerable group. Operation 275 of FIG. 2 includes the declaration part of the vulnerable_stack_ptr variable, and the vulnerable_stack_ptr variable will be a pointer pointing to the address of vulnerable_stack.

[0131] According to one example, vulnerable_heap variables and vulnerable_stack_ptr, to which vulnerable_stack variables are copied, are registered in a vulnerable_stack group. When vulnerable_heap variables or vulnerable_stack_ptr variables are copied to other copy target variables, or when a pointer to vulnerable_heap variables or a pointer to vulnerable_stack_ptr variables is copied to other copy target variables, operations corresponding to operations 630, 640, and 650 may be repeatedly performed on the aforementioned other copy target variables. When registering vulnerable variables in a vulnerable group, the vulnerable variable may already be registered in the vulnerable group. In this case, it is not necessary to register the vulnerable variable in the vulnerable group, but the location to insert the check code and the copy target variable to be checked may be added to the check code list in order to insert the check code before the copy code.

[0132] According to one example, when registering a potentially vulnerable variable in a potentially vulnerable group, the location where the check code for the target variable is to be inserted can be stored in a check code list so that a check function for the target variable is executed before a function containing the corresponding target variable is called. Based on the check code list in operation 660, the corresponding check code can be inserted at the location where the check function for the target variable is to be inserted. The check code refers to a function that checks whether the target variable is included in a potentially vulnerable group.

[0133] According to one example, kernel compilation or kernel build can be performed on a build server rather than on a terminal. During kernel compilation or build, a method to determine whether a function to be compiled in the kernel source is a function that copies external input values ​​into the kernel involves examining the kernel source to directly generate a list of kernel interface functions in advance. The `copy_from_user()` function and the function called for device control / management upon USB connection are presented as examples; functions that copy external input values ​​into the kernel can be classified as kernel interface functions. The kernel compiler or build script can verify whether a variable is a target for copy through the kernel source code to be built. For instance, in the case of `memcpy(dest, source, size)`, `dest` can be a target variable for copy. The kernel compiler or build script can also detect from the source code to be built whether a pointer variable pointing to another variable is added. Meanwhile, since various types of copy code may exist, a list of copy codes can be generated directly, similar to the method used to generate the kernel interface list. For instance, `char *pointer = &data;` If code exists, this code could be code that adds a pointer variable so that the pointer variable named 'pointer' points to the address of the data variable.

[0134] According to one example, before compiling the kernel, the kernel source is analyzed to generate a vulnerable group containing a list of potentially vulnerable variables, and check code can be inserted before copy code that copies to a target variable is executed. The kernel source with the inserted check code can be compiled. FIGS. 6, 7, 8, and 10 describe various methods to enable the check code to be executed when the compiled kernel is running.

[0135] According to one example, a list of kernel interface functions can be obtained. A kernel interface function refers to a function that copies an external input value to an internal kernel variable (a target variable). For instance, the `copy_from_user()` function or a function called to control or process a device when a USB device is connected can be kernel interface functions. Kernel interface functions are functions where copying occurs from outside the kernel to inside the kernel, and users can investigate them in advance and create a list of them.

[0136] According to one example, a kernel compiler or build script can check whether a kernel interface function exists in the kernel source based on a list of kernel interface functions. If a kernel interface function exists in the kernel source (Example of Operation 610), the kernel interface function checks for variables to be copied. If a kernel interface function does not exist in the kernel source (No of Operation 610), the procedure can be terminated.

[0137] According to one example, whenever a kernel interface function is called in the kernel source, the memory declaration and / or allocation portion of the copy target variable of the called kernel interface function can be checked to determine whether the copy target variable is a stack variable or a heap variable. For example, referring to operation 210 in FIG. 2, the vulnerable_stack variable is declared as a stack variable and allocated in memory, and referring to operation 240 in FIG. 2, the vulnerable_heap variable is declared as a heap variable and allocated in memory using the kmalloc() function.

[0138] According to one example, by checking the declaration and assignment parts of a variable, a variable to be copied can be considered a vulnerable variable and registered in a vulnerable group. In this case, the vulnerable group can be divided into a vulnerable stack group and a vulnerable heap group. The vulnerable stack group may include a vulnerable stack variable list, and the vulnerable heap group may include a vulnerable heap variable list.

[0139] According to one example, if the value of a vulnerable variable is copied to another target variable (e.g., by calling the memcpy() function), if another target variable (another pointer variable) pointing to the vulnerable variable is added, or if a pointer variable is copied to another target variable (another pointer variable), the other target variable may be treated as a vulnerable variable and registered in a vulnerable group. If the aforementioned other target variable is registered in the vulnerable group as a vulnerable variable, it may be checked whether the registered vulnerable variable is copied to yet another target variable. This operation may be repeated recursively until there is no longer any copy code that copies to another target variable. Check code may be inserted before the copy code in which the vulnerable variable registered in the aforementioned vulnerable group is copied. The check code is code that verifies whether the target variable of the copy code is included in the corresponding vulnerable group. A kernel compiler may compile kernel source code that includes the aforementioned check code.

[0140] According to one example, kernel compilation (build) can be performed on a build server. While kernel compilation can certainly be performed on the terminal, it may be more efficient to compile on a build server that possesses sufficient resources for compilation, and then copy the resulting kernel image to the terminal. According to one example, a list of kernel interface functions that copy external input values ​​can be generated in advance by human investigation. Kernel interface functions, such as the `copy_from_user()` function and functions called for device control / management upon USB connection, are functions where copying occurs from outside the kernel to inside, and a list can be generated through human investigation and analysis. The kernel compiler can obtain the kernel interface list to verify whether kernel interface functions are called within the kernel source. Similarly, a list of copy code that copies potentially vulnerable variables to target variables can be generated in advance by directly analyzing kernel source, user functions, device drivers, etc., and from this list of copy code, the code where potentially vulnerable variables are copied to other target variables can be identified. For instance, the kernel compiler or build script can verify this through the source code that is the build target. For example, in memcpy(dest, src, size), memcpy could be the copy code, and dest could be the variable to be copied. The addition of a pointer variable pointing to a variable can also be identified by the compiler or build script from the source code of the build target. For example, the code "*pointer = &data; " could be copy code that adds a pointer variable named pointer that points to the address of a variable named data.

[0141] According to one example, functions that copy input values ​​from outside the kernel into internal kernel variables, such as functions that copy input values ​​from user space (e.g., the copy_from_user function) or functions called to control or manage a device when a USB device is connected, can be referred to as kernel interface functions. The list of kernel interface functions may be determined in advance. Although the list of kernel interface functions is widely known, new kernel interface functions may be added to improve convenience between user space and the kernel due to the many types of new USB devices; therefore, in order to implement the invention according to the present disclosure, it is necessary to create a list of kernel interface functions and update it periodically.

[0142] According to one example, operations according to the present disclosure may be performed for all kernel interface functions included in the kernel interface function list. Since a kernel interface function may be used two or more times in the kernel source, one kernel interface function may be selected from the kernel interface function list, and operations according to the present disclosure may be performed for each kernel source location where the selected kernel interface function is called. The copy target variable used in the kernel interface function may be identified, and by determining whether the copy target variable is a stack variable or a heap variable, the copy target variable may be registered in a vulnerable group. Depending on whether the copy target variable is a stack variable or a heap variable, the copy target variable may be registered in a vulnerable stack group or a vulnerable heap group. Additionally, while registering the copy target variable in the vulnerable group, the kernel source locations of the functions in which the copy target variable is used may be stored. The vulnerable group may include a list of vulnerable variables, and the list of vulnerable variables may include the kernel source locations of the functions in which the vulnerable variable (copy target variable) is used.

[0143] According to one example, it is possible to check whether the aforementioned target variable has been copied to another target variable. If it has been copied to another target variable, the stack / heap status of that other target variable is checked, and the other target variable is also registered in the potential vulnerability group. The kernel source location of the function that used the registered other target variable can be stored. Additionally, the process of checking whether the registered other target variable is copied again and registering it in the potential vulnerability group by checking for copying until no more copying occurs can be performed recursively. The tasks of storing kernel source locations and registering in the potential vulnerability group can be repeated until there are no more variables determined to be potential vulnerabilities. This process is repeated until there are no more other variables to which the target variable has been copied.

[0144] Starting from an external kernel input value, targets that are copied recursively can be registered as vulnerable variables, and a check function can be inserted so that the check function is executed before the execution of the copy function that copies the registered vulnerable variables.

[0145] FIG. 7 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0146] According to one example, before compiling the kernel, the kernel source can be analyzed to generate a vulnerable group containing a list of potentially vulnerable variables, and check code can be inserted before the copy code that copies to the target variable is executed. The kernel source with the inserted check code can be compiled.

[0147] According to one example, a list of kernel interface functions can be obtained. A kernel interface function refers to a function that copies an external input value to an internal kernel variable (a target variable). For instance, the `copy_from_user()` function or a function called to control or process a device when a USB device is connected can be kernel interface functions. Kernel interface functions are functions where copying occurs from outside the kernel to inside the kernel, and users can investigate them in advance and create a list of them.

[0148] According to one example, a kernel compiler or build script can check whether kernel interface functions exist in the kernel source based on a list of kernel interface functions. If kernel interface functions exist in the kernel source (example of Operation 710), the copy target variable can be checked, the copy target variable can be registered as a potentially vulnerable variable, and the possibility of copying a potentially vulnerable variable can be recursively checked. If kernel interface functions no longer exist in the kernel source (no of Operation 710), for the potentially vulnerable variables registered in the potential vulnerable group, check code can be inserted before the copy code that copies to the copy target variable (potentially vulnerable variable) (Operation 760). After inserting check code before all copy code in the kernel source, the procedure can be terminated, and the modified kernel source can be compiled to generate a kernel image. The check code can check whether the copy target variable belongs to the potential vulnerable group. When the kernel is executed after compilation, if the check code is called, it checks whether the target variable of the copy code belongs to a vulnerable group; if the target variable belongs to a vulnerable group, the copy code is executed, and if it does not belong to a vulnerable group, the copy code is not executed and error handling is performed.

[0149] According to one example, whenever a kernel interface function is called in the kernel source, the memory declaration and / or allocation portion of the copy target variable of the called kernel interface function can be checked to determine whether the copy target variable is a stack variable or a heap variable. For example, referring to operation 210 in FIG. 2, the vulnerable_stack variable is declared as a stack variable and allocated in memory, and referring to operation 240 in FIG. 2, the vulnerable_heap variable is declared as a heap variable and allocated in memory using the kmalloc() function.

[0150] According to one example, by checking the declaration and assignment parts of a variable, a variable to be copied can be considered a vulnerable variable and registered in a vulnerable group. In this case, the vulnerable group can be divided into a vulnerable stack group and a vulnerable heap group. The vulnerable stack group may include a vulnerable stack variable list, and the vulnerable heap group may include a vulnerable heap variable list.

[0151] According to one example, if the value of a vulnerable variable is copied to another target variable (e.g., by calling the memcpy() function), if another target variable (another pointer variable) pointing to the vulnerable variable is added, or if a pointer variable is copied to another target variable (another pointer variable), the other target variable may be treated as a vulnerable variable and registered in the vulnerable group. When the aforementioned other target variable is registered in the vulnerable group as a vulnerable variable, it is possible to check whether the vulnerable variable is copied to yet another target variable. This operation may be recursively repeated to register the vulnerable variable in the vulnerable group until there is no longer any copy code that copies to another target variable.

[0152] FIG. 8 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0153] According to one example, before compiling the kernel, the kernel source can be analyzed to generate a vulnerable group containing a list of potentially vulnerable variables, and check code can be inserted before the copy code that copies to the target variable is executed. The kernel source with the inserted check code can be compiled.

[0154] According to one example, the operation of creating a vulnerability potential group and inserting inspection code during kernel compilation can be performed in various ways. Unlike FIGS. 6 and 7, in the case of FIG. 8, when a function that is copied to a vulnerability potential variable is found, the vulnerability potential variable can be registered in the vulnerability potential group.

[0155] According to one example, a list of kernel interface functions can be obtained. A kernel interface function refers to a function that copies an external input value to an internal kernel variable (a target variable). For instance, the `copy_from_user()` function or a function called to control or process a device when a USB device is connected can be kernel interface functions. Kernel interface functions are functions where copying occurs from outside the kernel to inside the kernel, and users can investigate them in advance and create a list of them.

[0156] According to one example, a kernel compiler or build script can check whether kernel interface functions exist in the kernel source based on a list of kernel interface functions. If kernel interface functions exist in the kernel source (example of operation 810), the copy target variable can be checked, the copy target variable can be registered as a vulnerable variable, and the vulnerable variable can be recursively checked whether it is copied to another copy target variable. For example, in operation 230 of FIG. 2, the vulnerable_stack variable may be a copy target variable. Such a function can be referred to as a kernel interface function. If kernel interface functions no longer exist in the kernel source (No in operation 810), the procedure can be terminated, and the modified kernel source can be compiled to create a kernel image.

[0157] According to one example, whenever a kernel interface function is called in the kernel source, the memory declaration and / or allocation portion of the copy target variable of the called kernel interface function can be checked to determine whether the copy target variable is a stack variable or a heap variable. For example, referring to operation 210 in FIG. 2, the vulnerable_stack variable is declared as a stack variable and allocated in memory, and referring to operation 240 in FIG. 2, the vulnerable_heap variable is declared as a heap variable and allocated in memory using the kmalloc() function.

[0158] According to one example, by checking the declaration and assignment parts of a variable, a variable to be copied may be considered a vulnerable variable and registered in a vulnerable group. In this case, vulnerable groups may be divided into vulnerable stack groups and vulnerable heap groups. A vulnerable stack group may contain a list of vulnerable stack variables, and a vulnerable heap group may contain a list of vulnerable heap variables. For vulnerable variables registered in a vulnerable group, a check code may be inserted before the copy code that copies to the target variable (vulnerable variable) (operation 835). A check code may be inserted before the copy code whenever a vulnerable variable is registered in a vulnerable group. Without storing the locations in the kernel source code where the check code is to be inserted, the target variable of the copy code may be registered in a vulnerable group and the check code may be inserted immediately before the copy code. The check code may check whether the target variable belongs to a vulnerable group. When the kernel is executed after compilation, if the check code is called, it checks whether the target variable of the copy code belongs to a vulnerable group; if the target variable belongs to a vulnerable group, the copy code is executed, and if it does not belong to a vulnerable group, the copy code is not executed and error handling is performed.

[0159] According to one example, check code can be inserted before a function that copies to a target variable (e.g., a kernel interface function or copy code). The check code checks whether the target variable is included in a potential vulnerability group. When the kernel is compiled and executed, if the check code is executed, it checks whether the target variable of the kernel interface function is included in a potential vulnerability group; if the target variable is not included in a potential vulnerability group, error handling is performed so that the kernel interface function or copy code is not executed.

[0160] According to one example, if the value of a vulnerable variable is copied to another target variable (e.g., by calling the memcpy() function), if another target variable (another pointer variable) pointing to the vulnerable variable is added, or if a pointer variable is copied to another target variable (another pointer variable), the other target variable may be treated as a vulnerable variable and registered in the vulnerable group. Once the aforementioned other target variable is registered in the vulnerable group as a vulnerable variable, it is possible to check whether the vulnerable variable is copied to yet another target variable. This operation may be recursively repeated to register the vulnerable variable in the vulnerable group until there is no longer any copy code that copies to the other target variable. As described above, after registering the other target variable (vulnerable variable) in the vulnerable group, a check code may be inserted before the copy code that copies to the other target variable. The check code can determine whether the other target variable is included in the vulnerable group.

[0161] According to one example, by checking the declaration and memory allocation of a target variable, you can determine whether the target variable is a stack variable or a heap variable. Additionally, you can check whether the target variable is being copied to another target variable. By verifying that it becomes another target variable through memcpy or pointer copying, you can check the declaration and memory allocation of the other target variable.

[0162] FIG. 9 is a flowchart for explaining a method of operation of an electronic device according to an example of the present disclosure.

[0163] According to one example, when the compiled kernel is executed (runtime), a check command can be performed on the variables to be copied.

[0164] According to one example, when the kernel is executed, the kernel continues to operate (Operation 910) due to the characteristics of the operating system. If the check code (check command) is not called during the kernel operation (No in Operation 920), the kernel will continue to operate, and if the check code (check command) is called during the kernel operation (Yes in Operation 920), it can determine whether the variable to be copied, which is the input value of the check code, belongs to a vulnerable group (Operation 930). If the variable to be copied does not belong to a vulnerable group (No in Operation 930), it can perform error handling without copying (Operation 940). If the variable to be copied belongs to a vulnerable group (Yes in Operation 930), it can execute the copy code to perform the operation of copying an input value from outside the kernel to the variable to be copied (Operation 935).

[0165] According to one example, a check code (check function) is inserted before a copy function (copy code) before kernel build (compile), and if the check code is called before the copy code is called, the check code can check whether the variable to be copied belongs to a potential vulnerability group. If the variable to be copied does not belong to a potential vulnerability group, error handling can be performed. According to one example, error handling may include at least one of the following actions: kernel panic, kernel violation, blocking device operation, blocking copy operation, user warning, and logging.

[0166] According to one example, the kernel, which is the core of the operating system, may not have a user-friendly user interface (UI). Meanwhile, if code is found where a variable value belonging to a potential vulnerability group is copied to a regular variable, a user interface that notifies the user of this and a user interface that allows managing the potential vulnerability group can be provided to the user.

[0167] FIG. 10 is a flowchart illustrating a method of operation of an electronic device according to an example of the present disclosure.

[0168] According to one example, before compiling the kernel, the kernel source is analyzed to generate a vulnerable group containing a list of potentially vulnerable variables, and the copy code that copies to the target variable can be replaced with a combined instruction code in which the check code and the copy code can be executed together. If the copy code and the check code can be provided as a single combined instruction through the support of hardware such as a processor (CPU, GPU, NPU, TPU, APU), the copy code can be replaced with the aforementioned single combined instruction instead of inserting the check code before the copy code. The kernel compiler can compile the kernel source in which the copy code has been replaced with a single combined instruction.

[0169] In the case of Fig. 10, compared to Fig. 8, there is a difference in that instead of inserting a check code before the copy code, the copy code can be replaced with an integrated command that can execute both the check code and the copy code at once.

[0170] According to one example, a list of kernel interface functions can be obtained. A kernel interface function refers to a function that copies an external input value to an internal kernel variable (a target variable). For instance, the `copy_from_user()` function or a function called to control or process a device when a USB device is connected can be kernel interface functions. Kernel interface functions are functions where copying occurs from outside the kernel to inside the kernel, and users can investigate them in advance and create a list of them.

[0171] According to one example, a kernel compiler or build script can check whether kernel interface functions exist in the kernel source based on a list of kernel interface functions. If kernel interface functions exist in the kernel source (example of operation 810), the copy target variable can be checked, the copy target variable can be registered as a vulnerable variable, and the vulnerable variable can be recursively checked whether it is copied to another copy target variable. For example, in operation 230 of FIG. 2, the vulnerable_stack variable may be a copy target variable. Such a function can be referred to as a kernel interface function. If kernel interface functions no longer exist in the kernel source (No in operation 810), the procedure can be terminated, and the modified kernel source can be compiled to create a kernel image.

[0172] According to one example, whenever a kernel interface function is called in the kernel source, the memory declaration and / or allocation portion of the copy target variable of the called kernel interface function can be checked to determine whether the copy target variable is a stack variable or a heap variable. For example, referring to operation 210 in FIG. 2, the vulnerable_stack variable is declared as a stack variable and allocated in memory, and referring to operation 240 in FIG. 2, the vulnerable_heap variable is declared as a heap variable and allocated in memory using the kmalloc() function.

[0173] According to one example, by checking the declaration and assignment parts of a variable, the variable to be copied can be identified as a vulnerable variable and registered in a vulnerable group. In this case, the vulnerable group can be divided into a vulnerable stack group and a vulnerable heap group. The vulnerable stack group may include a vulnerable stack variable list, and the vulnerable heap group may include a vulnerable heap variable list. For vulnerable variables registered in the vulnerable group, the copy code that copies to the target variable (vulnerable variable) can be replaced with an integrated command code that performs the function of (inspection code + copy code). Whenever a vulnerable variable is registered in the vulnerable group, the copy code can be replaced with the integrated command code. The target variable of the copy code can be registered in the vulnerable group, and the copy code can be replaced immediately. When the kernel is executed after compilation, the integrated instruction code that replaces it checks whether the target variable belongs to a vulnerable group; if the target variable belongs to a vulnerable group, it copies to the target variable, and if it does not belong to a vulnerable group, it performs error handling without copying.

[0174] According to one example, if the value of a vulnerable variable is copied to another target variable (e.g., by calling the memcpy() function), if another target variable (another pointer variable) pointing to the vulnerable variable is added, or if a pointer variable is copied to another target variable (another pointer variable), the other target variable may be treated as a vulnerable variable and registered in the vulnerable group. Once the aforementioned other target variable is registered in the vulnerable group as a vulnerable variable, it may be checked whether the vulnerable variable is copied to yet another target variable. This operation may be recursively repeated to register the vulnerable variable in the vulnerable group until there is no longer any copy code copying to the other target variable. As described above, after registering the other target variable (vulnerable variable) in the vulnerable group, the copy code for copying to the other target variable may be replaced with an integrated command code that performs both the functions of the check code and the copy code. The integrated command code checks whether the target variable is included in the vulnerable group, and if the target variable is included in the vulnerable group, it can perform the copy operation. If the variable to be copied is not included in the vulnerable group, error handling can be performed without executing the copy operation.

[0175] According to one example, if processors and hardware such as CPUs, GPUs, TPUs, APUs, and NPUs provide copy (write) and check commands as a single integrated instruction, operations can be processed at higher speeds. According to one example, if hardware support is provided, hardware acceleration will be possible.

[0176] In FIG. 10, operations 1005, 1010, 1020, 1030, 1040, and 1050 correspond to operations 805, 810, 820, 830, 840, and 850 of FIG. 8, respectively; however, unlike operation 835 of FIG. 8, operation 1035 will operate in FIG. 10. That is, there may be a difference in that the copy code and the check code are replaced by a single integrated command code. FIG. 10 is a diagram based on FIG. 8, but the method of replacing the copy code with an integrated command code that performs the function of (check code + copy code) can also be applied to flowcharts such as FIG. 6 or FIG. 7. FIG. 6 is a flowchart in which the check code is inserted whenever a kernel interface function is used in the kernel source, and FIG. 7 is a flowchart in which the check code is inserted only once when compiling the kernel. In the case of FIG. 6 or FIG. 7, the kernel source is modified at once when the operation to insert the check code and the input value of the check code to be inserted (the copy target variable of the copy code) are stored in memory and then inserted, whereas in the case of FIG. 8, there may be a difference in that the check code for the corresponding copy target variable is inserted whenever the copy code is executed. That is, as in FIG. 6, the location where the copy code (including kernel interface functions) must be replaced with an integrated command code that performs the function of (check code + copy code) and the input value of the copy code are stored, and the replacement operation can be performed for each kernel interface function. Also, as in FIG. 7, in the entire kernel source, the location where the copy code (including kernel interface functions) must be replaced with an integrated command code that performs the function of (check code + copy code) and the input value of the copy code are all stored, and the operation to replace the copy code with (check code + copy code) instead of operation 760 can be performed.

[0177] According to one example, operations 360 and 365 can be performed at once by replacing the check code check_write_target (target) in operation 360 of FIG. 3 and the copy code memcpy (target, source, size) in operation 365 of FIG. 3 with an integrated command code such as memcpy_after_check (target, source, size). While the aforementioned integrated command code is generally supported by hardware, a software implementation method can be used to implement a software function memcpy_after_check(), which is an integrated code corresponding to a specific copy code, such as the memcpy() function. That is, it can also be implemented by a method in which a kernel compiler pre-implements an integrated command code that includes the functions of check code and copy code, and then replaces the copy code in the kernel source with the integrated command code. However, compared to the method of inserting check code, the software implementation method may be somewhat complex because it requires pre-implementing an integrated code corresponding to each copy code, while not offering significant performance improvement.

[0178] According to one example, when the kernel is running, the possibility of utilizing abnormal or malicious external input values ​​can be blocked by allowing the copying of external input values, the addresses of those variables, and chains of other variables that directly or indirectly point to those values ​​and addresses—which come in through kernel interface functions such as the primary attack target, `copy_from_user()`—only within pre-allowed areas (potentially vulnerable areas), and by blocking copying to variables that are not potentially vulnerable. In this process, performance degradation can be minimized by reducing unnecessary operations. For instance, since copying a regular variable to another regular variable or to a potentially vulnerable area is permitted, algorithms can be designed to insert check code in response or to avoid blocking copy code.

[0179] One example of the present disclosure may provide an electronic device and a method of operating the electronic device.

[0180] An electronic device according to the present disclosure comprises a communication circuit; a memory for storing at least one instruction; and at least one processor including a processing circuit for executing said at least one instruction, wherein the at least one instruction may cause said data analysis device to perform at least one operation when executed individually or collectively by said at least one processor.

[0181] The above at least one operation may include: an operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of halting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0182] In an electronic device according to the present disclosure, the kernel source can be generated by inserting the first check code among the one or more check codes into the kernel source so as to be positioned before the first copy code among the one or more copy codes.

[0183] In an electronic device according to the present disclosure, when the at least one instruction is executed individually or collectively by the at least one processor, the electronic device may be caused to: acquire a plurality of kernel interface functions; determine that a first kernel interface function among the plurality of kernel interface functions exists in the kernel source; determine that a second copy target variable of the first kernel interface function existing in the kernel source is a first vulnerable variable; register the first vulnerable variable in a vulnerable group; insert a second check code into the kernel source that determines whether the second copy target variable is included in the vulnerable group so as to be positioned before the first kernel interface function of the kernel source; and compile the kernel source to acquire the kernel image.

[0184] In an electronic device according to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: check whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable, determine the third copy target variable as the second vulnerable variable, register the second vulnerable variable to the vulnerable group, and insert a third check code into the kernel source that determines whether the third copy target variable is included in the vulnerable group, such that it is positioned before the second copy code of the kernel source.

[0185] In an electronic device according to the present disclosure, the kernel image is generated by compiling the kernel source including the vulnerable potential group, and the kernel image can be checked for tampering by a secure boot.

[0186] In an electronic device according to the present disclosure, the vulnerable potential group may be stored as a file outside the kernel image.

[0187] In an electronic device according to the present disclosure, when at least one instruction is executed individually or collectively by the at least one processor, the electronic device may: obtain an encrypted digital signature based on a hash key based on the vulnerable group and a private key; obtain a public key based on the private key; obtain a decrypted hash key based on the digital signature and the public key; and perform a forgery check of the vulnerable group based on the decrypted hash key.

[0188] In an electronic device according to the present disclosure, the vulnerable potential group includes at least one of a vulnerable potential stack group or a vulnerable potential heap group, the vulnerable potential stack group includes vulnerable potential stack variables, and the vulnerable potential heap group may include vulnerable potential heap variables.

[0189] In an electronic device according to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: create a list of check codes including location information in which each of a plurality of check codes determining whether each of a plurality of copy target variables is included in a vulnerable group is inserted into the kernel source, and, based on the list of check codes, insert each of the plurality of check codes into the kernel source.

[0190] In an electronic device according to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: check whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable, determine the third copy target variable as the second vulnerable variable, register the third vulnerable variable to the vulnerable group, and replace the second copy code of the kernel source with a third check code that determines whether the third copy target variable is included in the vulnerable group and with an integration code that executes the function of the second copy code.

[0191] A method of operation of an electronic device according to the present disclosure may include at least one of the following: an operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of interrupting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0192] In a method of operation of an electronic device according to the present disclosure, the kernel source can be generated by inserting the first check code among the one or more check codes into the kernel source so as to be positioned before the first copy code among the one or more copy codes.

[0193] A method of operation of an electronic device according to the present disclosure may further include: acquiring a plurality of kernel interface functions; determining that a first kernel interface function among the plurality of kernel interface functions exists in the kernel source; determining a second copy target variable of the first kernel interface function existing in the kernel source as a first vulnerable potential variable; registering the first vulnerable potential variable in a vulnerable potential group; inserting a second check code into the kernel source to determine whether the second copy target variable is included in the vulnerable potential group so as to be positioned before the first kernel interface function in the kernel source; and compiling the kernel source to acquire the kernel image.

[0194] A method of operation of an electronic device according to the present disclosure may further include: checking whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable; determining the third copy target variable as the second vulnerable variable; registering the second vulnerable variable to the vulnerable group; and inserting a third check code into the kernel source that determines whether the third copy target variable is included in the vulnerable group, such that the third copy target variable is positioned before the second copy code of the kernel source.

[0195] In a method of operation of an electronic device according to the present disclosure, the kernel image is generated by compiling the kernel source including the vulnerable potential group, and the kernel image can be checked for tampering by a secure boot.

[0196] In a method of operating an electronic device according to the present disclosure, the vulnerable potential group may be stored as a file outside the kernel image.

[0197] A method of operation of an electronic device according to the present disclosure may further include: an operation of obtaining an encrypted electronic signature based on a hash key based on the vulnerable group and a private key; an operation of obtaining a public key based on the private key; an operation of obtaining a decrypted hash key based on the electronic signature and the public key; and an operation of performing a forgery check of the vulnerable group based on the decrypted hash key.

[0198] In a method of operating an electronic device according to the present disclosure, the vulnerable potential group includes at least one of a vulnerable potential stack group or a vulnerable potential heap group, the vulnerable potential stack group includes vulnerable potential stack variables, and the vulnerable potential heap group may include vulnerable potential heap variables.

[0199] A method of operation of an electronic device according to the present disclosure may further include: an operation of creating a list of inspection codes including location information in which each of a plurality of inspection codes, which determine whether each of a plurality of copy target variables is included in a vulnerable group, is inserted into the kernel source; and an operation of inserting each of the plurality of inspection codes into the kernel source based on the list of inspection codes.

[0200] A method of operation of an electronic device according to the present disclosure may further include: checking whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable; determining the third copy target variable as the second vulnerable variable; registering the third vulnerable variable to the vulnerable group; and replacing the second copy code of the kernel source with a third check code that determines whether the third copy target variable is included in the vulnerable group and an integrated code that executes the function of the second copy code.

[0201] A computer-readable medium according to the present disclosure may store a program that commands the execution of a method of operation of an electronic device comprising at least one of the following: an operation of executing a kernel based on a kernel image generated by compiling a kernel source including one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a vulnerable group; wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the vulnerable group; and an operation of interrupting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the vulnerable group.

[0202] An electronic device according to the present disclosure comprises a memory for storing at least one instruction; and at least one processor including a processing circuit, wherein when the at least one instruction is executed individually or collectively by the at least one processor, the electronic device may cause: to execute a kernel based on a kernel image generated by compiling a kernel source including one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; to execute a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a variable group; the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes, and based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the variable group, the first copy code is executed, and based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the variable group, the kernel may be interrupted.

[0203] According to the present disclosure, when the at least one instruction is executed individually or collectively by the at least one processor, the electronic device may be caused to: acquire a plurality of kernel interface functions; determine that a first kernel interface function among the plurality of kernel interface functions exists in the kernel source; determine that a second copy target variable of the first kernel interface function existing in the kernel source is a first vulnerable variable; register the first vulnerable variable in a variable group; insert a second check code into the kernel source that determines whether the second copy target variable is included in the variable group so as to be positioned before the first kernel interface function of the kernel source; and compile the kernel source to acquire the kernel image.

[0204] According to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: obtain that a second copy code for copying the first vulnerable variable to a third copy target variable exists in the kernel source, determine the third copy target variable as the second vulnerable variable, register the second vulnerable variable to the variable group, and insert a third check code in the kernel source that determines whether the third copy target variable is included in the variable group, such that it is positioned before the second copy code in the kernel source.

[0205] According to the present disclosure, the kernel image is generated by compiling the kernel source including the variable group, and the kernel image can be checked for tampering by a secure boot.

[0206] According to the present disclosure, the variable group may be stored as a file outside the kernel image.

[0207] According to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: obtain an encrypted digital signature based on a hash key based on the variable group and a private key; obtain a public key based on the private key; obtain a decrypted hash key based on the digital signature and the public key; and perform a forgery check of the variable group based on the decrypted hash key.

[0208] According to the present disclosure, the variable group includes at least one of a stack variable group or a heap variable group, the stack variable group includes vulnerable stack variables, and the heap variable group may include vulnerable heap variables.

[0209] According to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: create a list of check codes including location information for inserting each of a plurality of check codes into the kernel source, wherein each of the check codes determines whether each of the plurality of copy target variables is included in a variable group, and based on the list of check codes, insert each of the plurality of check codes into the kernel source.

[0210] According to the present disclosure, at least one instruction, when executed individually or collectively by the at least one processor, may cause the electronic device to: check whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable, determine the third copy target variable as the second vulnerable variable, register the third vulnerable variable to the variable group, and replace the second copy code of the kernel source with a third check code that determines whether the third copy target variable is included in the variable group and with an integration code that executes the function of the second copy code.

[0211] A method of operation of an electronic device according to the present disclosure may include: an operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; an operation of executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a variable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; an operation of executing the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the variable group; and an operation of interrupting the kernel based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the variable group.

[0212] A method of operation of an electronic device according to the present disclosure may further include: acquiring a plurality of kernel interface functions; determining that a first kernel interface function among the plurality of kernel interface functions exists in the kernel source; determining a second copy target variable of the first kernel interface function existing in the kernel source as a first vulnerable variable; registering the first vulnerable variable in a variable group; inserting a second check code into the kernel source to determine whether the second copy target variable is included in the variable group so as to be positioned before the first kernel interface function in the kernel source; and compiling the kernel source to acquire the kernel image.

[0213] A method of operation of an electronic device according to the present disclosure may further include: an operation of checking whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable; an operation of determining the third copy target variable as the second vulnerable variable; an operation of registering the second vulnerable variable to the variable group; and an operation of inserting a third check code into the kernel source that determines whether the third copy target variable is included in the variable group, such that the third copy target variable is positioned before the second copy code of the kernel source.

[0214] In a method of operation of an electronic device according to the present disclosure, the kernel image is generated by compiling the kernel source including the variable group, and the kernel image can be checked for tampering by a secure boot.

[0215] In a method of operating an electronic device according to the present disclosure, the variable group may be stored as a file outside the kernel image.

[0216] A method of operation of an electronic device according to the present disclosure may further include: an operation of obtaining an encrypted electronic signature based on a hash key based on a variable group and a private key; an operation of obtaining a public key based on the private key; an operation of obtaining a decrypted hash key based on the electronic signature and the public key; and an operation of performing a forgery check of the variable group based on the decrypted hash key.

[0217] In a method of operating an electronic device according to the present disclosure, the variable group includes at least one of a stack variable group or a heap variable group, the stack variable group includes vulnerable stack variables, and the heap variable group may include vulnerable heap variables.

[0218] A method of operation of an electronic device according to the present disclosure may further include: an operation of creating a list of inspection codes comprising location information in which each of a plurality of inspection codes determining whether each of a plurality of copy target variables is included in a variable group is inserted into the kernel source; and an operation of inserting each of the plurality of inspection codes into the kernel source based on the list of inspection codes.

[0219] A method of operation of an electronic device according to the present disclosure may further include: checking whether there exists a second copy code that copies the first vulnerable variable to a third copy target variable; determining the third copy target variable as the second vulnerable variable; registering the third vulnerable variable to the variable group; and replacing the second copy code of the kernel source with a third check code that determines whether the third copy target variable is included in the variable group and an integration code that executes the function of the second copy code.

[0220] The various embodiments of this document and the terms used therein are not intended to limit the technical features described in this document to specific embodiments, and should be understood to include various modifications, equivalents, or substitutions of said 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 said items unless the relevant context clearly indicates otherwise. In this document, phrases such as "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" may each include any one of the items listed together in the corresponding phrase, or all possible combinations thereof. Terms such as "first," "second," or "first" or "second" may be used simply to distinguish said components from other said components and do not limit said components in any other aspect (e.g., importance or order). Where any (e.g., 1st) component is referred to as “coupled” or “connected” to another (e.g., 2nd) component, with or without the terms “functionally” or “communicationly,” it means that said any component may be connected to said other component directly (e.g., via a wire), wirelessly, or through a third component.

[0221] The term “module” as used in the various embodiments 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, for example. A module may be a component formed integrally, or a minimum unit of said component or a part thereof 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).

[0222] Various embodiments of this document may be implemented as software (e.g., a program) comprising one or more instructions stored in a storage medium (e.g., internal memory or external memory) readable by a machine (e.g., an electronic device). For example, a processor of the machine (e.g., an electronic device) may call at least one of the one or more instructions stored from the storage medium and execute it. This enables the machine to be operated 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 that can be executed by an interpreter. The storage medium readable by the machine 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 a signal (e.g., electromagnetic waves), and this term does not distinguish between cases where data is stored semi-permanently and cases where it is stored temporarily in the storage medium.

[0223] According to one embodiment, the method according to the various embodiments disclosed herein may be provided as included in a computer program product. The computer program product may be traded between a seller and a buyer 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 distributed online (e.g., download or upload) through an application store (e.g., Play Store™) or directly between two user devices (e.g., smartphones). In the case of online distribution, at least a portion of the computer program product may be temporarily stored or temporarily created on a device-readable storage medium, such as the memory of a manufacturer's server, an application store's server, or a relay server.

[0224] According to various embodiments, each component (e.g., module or program) of the components described above may include a singular or multiple entities, and some of the multiple entities may be separated and placed in other components. According to various embodiments, one or more of the components or operations of the aforementioned components may be omitted, or one or more other components or operations may be added. Generally or additionally, multiple components (e.g., module or program) may be integrated into a single component. In this case, the integrated component may perform one or more functions of each of the multiple components in the same or similar manner as those performed by the corresponding component among the multiple components prior to integration. According to various embodiments, operations performed by the module, program, or other components 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.

Claims

1. In an electronic device, Memory for storing at least one instruction; and It includes at least one processor comprising a processing circuit, When the above at least one instruction is executed individually or collectively by the above at least one processor, the electronic device: Execute a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes, and Executing a first check code among the one or more check codes that determines whether a first copy target variable of a first copy code among the one or more copy codes is included in a variable group, and the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes, and Based on the fact that the first copy target variable of the first copy code among the above one or more copy codes is included in the variable group, the first copy code is executed, and An electronic device that causes the kernel to be interrupted based on the fact that the first copy target variable of the first copy code among the one or more copy codes is not included in the variable group.

2. In Paragraph 1, An electronic device in which the kernel source is generated by inserting the first inspection code among the one or more inspection codes into the kernel source so as to be positioned before the first copy code among the one or more copy codes.

3. In Paragraph 1 or 2, When the above at least one instruction is executed individually or collectively by the above at least one processor, the electronic device: Obtain multiple kernel interface functions, and Determining that a first kernel interface function among the plurality of kernel interface functions exists in the kernel source above, and The second copy target variable of the first kernel interface function existing in the kernel source is determined as the first vulnerability potential variable, and Register the above-mentioned first vulnerable variable to a variable group, and Insert a second check code into the kernel source that determines whether the second copy target variable is included in a variable group, so as to be positioned before the first kernel interface function of the kernel source, and An electronic device that causes the kernel source to be compiled to obtain the kernel image.

4. In Paragraph 3, At least one instruction, when executed individually or collectively by the at least one processor, causes the electronic device: It is obtained that a second copy code exists in the kernel source that copies the first vulnerable variable to the third copy target variable, and The above third copy target variable is determined as the second vulnerability potential variable, and Register the above second vulnerable variable to the variable group, and An electronic device that causes a third check code to be inserted into the kernel source to determine whether the third copy target variable is included in a variable group, so as to be positioned before the second copy code of the kernel source.

5. In Paragraph 4, The kernel image above is generated by compiling the kernel source including the variable group above, and The above kernel image is checked for tampering by secure boot, Electronic device.

6. In Paragraph 4 or 5, The above variable group is stored as a file outside the kernel image Electronic device.

7. In Paragraph 6, At least one instruction, when executed individually or collectively by the at least one processor, causes the electronic device: Obtain an encrypted digital signature based on a hash key and a private key based on the above variable group, and Obtain a public key based on the above private key, and Based on the above digital signature and the above public key, obtain a decrypted hash key, and An electronic device that causes to perform a forgery check of the variable group based on the decrypted hash key.

8. In any one of paragraphs 1 through 7, The above variable group includes at least one of a stack variable group or a heap variable group, and The above stack variable group includes potentially vulnerable stack variables, and The above heap variable group is an electronic device containing potentially vulnerable heap variables.

9. In Paragraph 4, At least one instruction, when executed individually or collectively by the at least one processor, causes the electronic device: A list of inspection codes is prepared that includes location information where each of the multiple inspection codes determining whether each of the multiple copy target variables is included in a variable group is inserted into the kernel source, and An electronic device that causes each of the plurality of inspection codes to be inserted into the kernel source based on the above list of inspection codes. Electronic device.

10. In Paragraph 3, At least one instruction, when executed individually or collectively by the at least one processor, causes the electronic device: Check whether there exists a second copy code that copies the above-mentioned first vulnerable potential variable to the third copy target variable, and The above third copy target variable is determined as the second vulnerability potential variable, and Register the above third potential vulnerability variable to the above variable group, and An electronic device that causes the second copy code of the kernel source to be replaced with a third check code that determines whether the third copy target variable is included in a variable group and an integration code that executes the function of the second copy code.

11. In a method of operating an electronic device, An operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; An operation of executing a first check code among one or more check codes to determine whether a first copy target variable of a first copy code among one or more copy codes is included in a variable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; An operation to execute the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the variable group; and A method of operation of an electronic device comprising an operation to interrupt the kernel based on the fact that, among the one or more copy codes, the first copy target variable of the first copy code is not included in the variable group.

12. In Paragraph 11, A method of operation of an electronic device, wherein the first inspection code among the one or more inspection codes is inserted into the kernel source so as to be positioned before the first copy code among the one or more copy codes, and the kernel source is generated.

13. In Paragraph 11 or 12, Operation of acquiring multiple kernel interface functions; An operation to determine whether a first kernel interface function among the plurality of kernel interface functions exists in the kernel source; An operation to determine the second copy target variable of the first kernel interface function existing in the kernel source as the first vulnerability potential variable; The action of registering the above-mentioned first vulnerable potential variable to a variable group; The operation of inserting a second check code into the kernel source that determines whether the second copy target variable is included in a variable group, so as to be positioned before the first kernel interface function of the kernel source; and A method of operating an electronic device, further comprising the operation of compiling the kernel source to obtain the kernel image.

14. In Paragraph 13, An operation to check whether there exists a second copy code that copies the above-mentioned first vulnerable potential variable to a third copy target variable; The operation of determining the above-mentioned third copy target variable as the second vulnerability potential variable; The operation of registering the above-mentioned second vulnerable potential variable to the above-mentioned variable group; and A method of operation of an electronic device, further comprising the operation of inserting a third check code into the kernel source to determine whether the third copy target variable is included in a variable group, so as to be positioned before the second copy code of the kernel source.

15. A computer-readable medium storing a program for executing a method of operating an electronic device, wherein the program, when executed by at least one processor of the electronic device, causes the electronic device: An operation of executing a kernel based on a kernel image generated by compiling a kernel source comprising one or more copy codes and one or more check codes corresponding to each of the one or more copy codes; An operation of executing a first check code among one or more check codes to determine whether a first copy target variable of a first copy code among one or more copy codes is included in a variable group, wherein the first check code among the one or more check codes corresponds to the first copy code among the one or more copy codes; An operation to execute the first copy code based on the fact that the first copy target variable of the first copy code among the one or more copy codes is included in the variable group; and A computer-readable recording medium that causes the kernel to perform an action to stop based on the fact that, among the one or more copy codes above, the first copy target variable of the first copy code is not included in the variable group.