KR20080066459A - Apparatus and method for dynamic detection of kernel stack overflow on operating system - Google Patents

Apparatus and method for dynamic detection of kernel stack overflow on operating system Download PDF

Info

Publication number
KR20080066459A
KR20080066459A KR1020070003937A KR20070003937A KR20080066459A KR 20080066459 A KR20080066459 A KR 20080066459A KR 1020070003937 A KR1020070003937 A KR 1020070003937A KR 20070003937 A KR20070003937 A KR 20070003937A KR 20080066459 A KR20080066459 A KR 20080066459A
Authority
KR
South Korea
Prior art keywords
stack
kernel
memory
overflow
area
Prior art date
Application number
KR1020070003937A
Other languages
Korean (ko)
Inventor
장영준
정경진
김민찬
Original Assignee
삼성전자주식회사
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 삼성전자주식회사 filed Critical 삼성전자주식회사
Priority to KR1020070003937A priority Critical patent/KR20080066459A/en
Publication of KR20080066459A publication Critical patent/KR20080066459A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/06Addressing a physical block of locations, e.g. base addressing, module addressing, memory dedication
    • G06F12/0646Configuration or reconfiguration
    • G06F12/0684Configuration or reconfiguration with feedback, e.g. presence or absence of unit detected by addressing, overflow detection
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/006Identification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

A device and a method for detecting kernel stack overflow in an OS(Operating System) are provided to detect the kernel stack overflow by adding a protected area at the last part of a stack area allocated in a fixed size, and inducing page fault when a stack pointer enters the protected area. A kernel stack manager(310) initializes a stack by adding a protected area at the end part of a stack area when a kernel stack is generated. A page fault handler(320) outputs an error message when a page fault exception is generated when overflow occurs in the kernel stack. A virtual memory manager(330) manages addressing a memory used by the kernel and addressing the kernel stack. A page frame allocator(340) manages the memory in a page unit, and maps the memory to a virtual memory when the memory is allocated. The protected area of the stack area is allocated in one page unit and is initialized in a state that a physical page is not allocated.

Description

컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치 및 방법{Apparatus and method for dynamic detection of kernel stack overflow on Operating System}Apparatus and method for dynamic detection of kernel stack overflow on Operating System}

도 1은 종래의 컴퓨터 운영체제에서 커널 시스템 구성을 나타내는 도면.1 is a diagram showing a kernel system configuration in a conventional computer operating system.

도 2는 종래의 컴퓨터 운영체제에서 커널 시스템의 동작을 나타내는 도면.2 is a diagram illustrating the operation of a kernel system in a conventional computer operating system.

도 3은 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 메모리 관리를 위한 구성 요소를 나타낸 도면.3 is a diagram illustrating components for memory management of a kernel system in a computer operating system according to an embodiment of the present invention.

도 4는 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 동작을 나타내는 도면.4 illustrates the operation of a kernel system in a computer operating system in accordance with an embodiment of the present invention.

도 5는 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 메모리 관리 방법의 흐름도.5 is a flowchart of a memory management method of a kernel system in a computer operating system according to an exemplary embodiment of the present invention.

<도면의 주요 부분에 관한 부호의 설명><Explanation of symbols on main parts of the drawings>

310 : 커널 스택 매니저 320 : 페이지 폴트 핸들러310: kernel stack manager 320: page fault handler

330 : 가상 메모리 관리자 340 : 페이지 프레임 할당자330: virtual memory manager 340: page frame allocator

본 발명은 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치 및 방법에 관한 것으로, 더욱 상세하게는 고정 크기의 커널 스택을 가지는 운영체제에서 커널 스택 오버플로우에 대한 별도의 처리를 하지 않기 때문에 다른 영역의 메모리를 침범하게 되어 커널 패닉(panic)이 발생하게 되는 컴퓨터 운영체제의 커널 모드 스택 오버플로우를 검출하는 장치 및 방법에 관한 것이다.The present invention relates to an apparatus and method for dynamically detecting kernel mode stack overflow in a computer operating system. More particularly, the present invention relates to a kernel stack overflow in an operating system having a fixed size kernel stack. An apparatus and method for detecting a kernel mode stack overflow of a computer operating system in which a memory panic occurs and a kernel panic occurs.

운영체제(Operating System, OS)는 개인용 컴퓨터(personal computer; PC)와 같은 컴퓨터 장치에서, 사용자가 하드웨어를 보다 용이하게 사용할 수 있도록 인터페이스를 제공해 주는 프로그램들의 집합으로서, 프로세서, 기억 장치, 입출력 장치, 통신 장치, 데이터 등의 자원을 관리한다. An operating system (OS) is a set of programs that provides an interface for a user to use hardware more easily in a computer device such as a personal computer (PC), and includes a processor, a memory device, an input / output device, and a communication device. Manage resources such as devices and data.

커널(Kernel)은 이 운영체제의 핵심이다. 커널에는 종료된 입출력 연산, 커널의 서비스를 경쟁적으로 요구하는 모든 요청들을 처리하는 인터럽트 처리기, 어떤 프로그램들이 어떤 순서로 커널의 처리시간을 공유할 것인지를 결정하는 스케줄러, 및 스케줄이 끝나면 실제로 각 프로세스들에게 컴퓨터의 사용권을 부여하는 장치 등이 포함될 수 있다. 또한 커널은 메모리나 저장장치 내에서 운영체제의 주소공간을 관리하고, 이들을 모든 주변장치들과 커널의 서비스들을 사용하는 다른 사용자들에게 고루 나누어주는 메모리 관리자를 가지고 있다.The kernel is at the heart of this operating system. The kernel has a closed I / O operation, an interrupt handler that handles all requests that competitively require the services of the kernel, a scheduler that determines which programs share the kernel's processing time in what order, and when each schedule actually finishes each process. It may include a device for granting the right to use the computer. The kernel also has a memory manager that manages the operating system's address space in memory or storage and distributes it to all peripherals and other users of the kernel's services.

도 1은 종래의 컴퓨터 운영체제에서 커널 시스템 구성을 나타내는 도면이다. 1 is a diagram illustrating a kernel system configuration in a conventional computer operating system.

도시한 바와 같이, 컴퓨터 전체 시스템은 크게 사용자 영역 및 커널 영역으로 구분할 수 있다. As shown, the entire computer system can be largely divided into a user space and a kernel space.

사용자 영역에서는 사용자 응용 프로그램(태스크)이 동작하게 된다. In the user area, a user application (task) runs.

커널 영역에는 태스크 매니지먼트, 메모리 매니지먼트, 파일 시스템, 디바이스 컨트롤 등의 서브 시스템들이 구분된다. 이들은 하드웨어에 대한 제어를 담당하고, 응용 프로그램이 동작하는 데 필요한 서비스를 제공한다. 커널 영역에서 제공되는 기능은 시스템 서비스 API(Application Programming Interface) 형태로 구성되어 응용 프로그램에서 이를 사용하게 된다.The kernel area divides subsystems such as task management, memory management, file system, and device control. They take control of the hardware and provide the services necessary for the application to run. The functions provided in the kernel area are configured in the form of system service application programming interfaces (APIs) and used by the application.

도 2는 종래의 컴퓨터 운영체제에서 커널 시스템의 동작을 나타내는 도면이다.2 is a diagram illustrating the operation of a kernel system in a conventional computer operating system.

도시한 바와 같이, 커널 스택 매니저에서 가상 주소 공간에 커널 스택 영역을 생성하고 초기화 하는 것을 나타낸다.As shown, the kernel stack manager creates and initializes a kernel stack region in the virtual address space.

커널은 가상 주소 공간을 사용하고, 가상 주소 공간은 크게 커널 영역과 사용자 영역으로 구분된다.The kernel uses a virtual address space, which is largely divided into a kernel space and a user space.

스택 영역도 가상 주소 공간상에서 할당된다.Stack areas are also allocated on the virtual address space.

사용자 스택(210)은 크기가 계속해서 확장 가능한 동적 크기를 가지고 있고, 커널 스택(220)은 고정 크기의 스택을 가진다.User stack 210 has a dynamic size that is continuously scalable in size, and kernel stack 220 has a fixed size stack.

스택 영역은 커널 스택 생성시 일정크기(2개의 페이지, 즉 8KB)가 할당되어 사용하도록 구성되어 있다.The stack area is configured to allocate a certain size (two pages, that is, 8KB) when the kernel stack is created.

페이지는 가상 메모리를 사용하는 컴퓨터 시스템에서, 실제 저장소, 즉 램(RAM)에 없는 데이터가 요청되었을 때, 보조 기억장치로부터 실제 저장소로 한번에 옮겨갈 수 있는 데이터 저장 단위이다.A page is a unit of data storage in a computer system using virtual memory that can be moved from auxiliary storage to real storage at once when data is requested that is not in real storage, or RAM.

초기의 스택 포인터는 스택 영역의 첫번째 주소를 가리키고 있다.The initial stack pointer points to the first address in the stack area.

스택 포인터는 스택의 현재 위치를 가리킨다. 이는 이 위치의 주소를 가지고 있음을 의미한다.The stack pointer points to the current location on the stack. This means that it has an address for this location.

태스크 정보가 없는 스택(220a)은 8KB 영역을 모두 스택 용도로만 사용하는 경우를 나타낸다. 여기서 태스크 정보는 별도의 메모리 공간에 위치하게 된다.The stack 220a without task information indicates a case in which all 8 KB areas are used only for stack purposes. The task information is located in a separate memory space.

태스크 정보가 있는 스택(220b)은 태스크 정보와 커널 스택 영역이 같은 메모리 공간을 사용하는 경우이다. 바람직하게는, 태스크 정보의 크기는 보통 1KB 이하로 한다.The stack 220b with task information is a case where the task information and the kernel stack area use the same memory space. Preferably, the size of the task information is usually 1 KB or less.

종래의 방식은 커널 실행중 푸쉬(push), 팝(pop) 연산 발생시 스택 포인터가 스택 영역으로 할당된 크기(8KB)가 넘어갈 수 있고(오버플로우 발생), 이 경우 다른 메모리 영역을 침범하게 되어 커널이 크래쉬된다.In the conventional method, when a push or pop operation occurs during kernel execution, the stack pointer allocated to the stack area may be exceeded (8KB), and in this case, the kernel may invade another memory area. Will crash.

태스크 정보가 없는 스택(220a)에서 스택 사용량이 8KB를 초과하는 경우, 인접한 메모리 영역을 건드리게 되어 문제가 야기된다. 그러나, 이 경우, 인접한 메모리 영역이 사용되지 않고 있다면 침범해도 문제가 안될 수 있다.If the stack usage exceeds 8 KB in the stack 220a without task information, a problem is caused by touching an adjacent memory area. In this case, however, it may not be a problem if an adjacent memory area is not used, invading.

태스크 정보가 있는 스택(220b)에서 태스크 정보와 커널 스택 영역이 같은 메모리 공간을 사용할 경우, 커널 스택이 7KB를 초과하게 되면, 태스크 정보가 깨지므로 100% 문제가 발생한다. 태스크 정보는 깨지면 안되는 중요한 정보이므로 더 위험한 상황에 처하게 된다.When the task information and the kernel stack area use the same memory space in the stack 220b including the task information, when the kernel stack exceeds 7 KB, the task information is broken and thus a 100% problem occurs. Task information is important because it should not be broken, which puts you in a more dangerous situation.

이와 같이, 종래의 커널 시스템에서는 고정 크기 스택을 가지는 운영체제에서 커널 스택 오버플로우에 대한 별도의 처리를 하지 않고 있다. 이 때문에 스택 오버플로우 발생시 스택으로 할당된 메모리 영역을 벗어나게 되므로 다른 메모리 영역을 침범하게 된다. 이는 커널의 다른 동작에 영향을 주게 되고, 이후 커널은 이상 동작을 보이거나 커널 패닉(panic)이 발생한다. 결과적으로 운영체제의 안정성 확보에 큰 문제를 야기시키며, 개발기간도 크게 늘어나게 된다.As such, in the conventional kernel system, the kernel stack overflow is not separately processed by the OS having the fixed size stack. Because of this, when a stack overflow occurs, the memory area allocated to the stack is moved out of the way, thereby invading other memory areas. This affects other behaviors of the kernel, which then cause the kernel to behave strangely or cause kernel panic. As a result, it causes a big problem in securing the stability of the operating system, and the development period greatly increases.

본 발명은 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치 및 방법으로 인해 고정 크기로 할당된 스택 영역의 마지막 부분에 보호 영역을 추가하여 스택 포인터가 보호 영역으로 진입하게 되면 페이지 폴트(page fault)를 유발시켜 커널 스택 오버플로우를 감지할 수 있도록 처리 하는데 그 목적이 있다.The present invention provides a page fault when a stack pointer enters a protected area by adding a protected area to the last part of a stack area allocated to a fixed size due to an apparatus and method for dynamically detecting kernel mode stack overflow in a computer operating system. Its purpose is to handle kernel stack overflow detection by triggering.

본 발명의 다른 목적은 커널모드에서 선 할당된 고정 크기를 가지는 스택의 오버플로우를 디버깅하는 방법을 제공하는 데 그 목적이 있다.Another object of the present invention is to provide a method for debugging overflow of a stack having a fixed size pre-allocated in kernel mode.

본 발명의 목적들은 이상에서 언급한 목적들로 제한되지 않으며, 언급되지 않은 또 다른 목적들은 아래의 기재로부터 당업자에게 명확하게 이해될 수 있을 것이다.The objects of the present invention are not limited to the above-mentioned objects, and other objects that are not mentioned will be clearly understood by those skilled in the art from the following description.

상기 목적을 달성하기 위하여, 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치는 커널 스택 생성시 스택 영역의 뒷부분에 보호 영역을 추가하여 스택을 초기화 하는 커널 스택 매니저, 상기 커널 스택에서 오버플로우 발생시 페이지 폴트 예외가 발생하는 경우, 에러 메시지를 출력하는 페이지 폴트 핸들러, 상기 커널에서 사용하는 메모리의 어드레싱 및 커널 스택 의 어드레싱을 담당하는 가상 메모리 관리자, 및 상기 메모리를 소정의 페이 지 단위로 관리하고 상기 메모리를 할당할 경우 상기 가상 메모리에 매핑시키는 페이지 프레임 할당자를 포함한다.In order to achieve the above object, a dynamic detection device for kernel mode stack overflow in a computer operating system according to an embodiment of the present invention is a kernel stack manager for initializing the stack by adding a protection area to the rear of the stack area when the kernel stack is generated. If a page fault exception occurs when an overflow occurs in the kernel stack, a page fault handler that outputs an error message, a virtual memory manager responsible for addressing the memory used in the kernel and a kernel stack, and a predetermined page for the memory. And a page frame allocator that maps to the virtual memory when the memory is allocated and managed in units of data.

상기 목적을 달성하기 위하여, 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 방법은 커널 스택 매니저에서 가상 주소공간에 커널 스택 영역을 생성하고 초기화하는 단계, 디바이스 드라이버, 파일 시스템의 커널 서브 시스템들이 수행되면서 상기 커널 스택이 동작하는 단계, 스택 포인터가 상기 커널 스택의 보호 영역으로 진입하게 되어 오버플로우 발생할 경우, 페이지 폴트 예외가 발생하는 단계, 및In order to achieve the above object, a dynamic detection method for kernel mode stack overflow in a computer operating system according to an embodiment of the present invention comprises the steps of creating and initializing a kernel stack region in a virtual address space in a kernel stack manager, a device driver, and a file system. Operating the kernel stack while the kernel subsystems of the server are running, generating a page fault exception when an overflow occurs because a stack pointer enters a protected area of the kernel stack, and

상기 오버플로우를 처리하는 단계를 포함한다.Dealing with the overflow.

기타 실시예들의 구체적인 사항들은 상세한 설명 및 도면들에 포함되어 있다. Specific details of other embodiments are included in the detailed description and the drawings.

본 발명의 이점 및 특징, 그리고 그것들을 달성하는 방법은 첨부되는 도면과 함께 상세하게 후술되어 있는 실시예들을 참조하면 명확해질 것이다. 그러나 본 발명은 이하에서 개시되는 실시예들에 한정되는 것이 아니라 서로 다른 다양한 형태로 구현될 수 있으며, 단지 본 실시예들은 본 발명의 개시가 완전하도록 하고, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자에게 발명의 범주를 완전하게 알려주기 위해 제공되는 것이며, 본 발명은 청구항의 범주에 의해 정의될 뿐이다. 명세서 전체에 걸쳐 동일 참조 부호는 동일 구성 요소를 지칭한다.Advantages and features of the present invention and methods for achieving them will be apparent with reference to the embodiments described below in detail with the accompanying drawings. However, the present invention is not limited to the embodiments disclosed below, but can be implemented in various different forms, and only the embodiments make the disclosure of the present invention complete, and the general knowledge in the art to which the present invention belongs. It is provided to fully inform the person having the scope of the invention, which is defined only by the scope of the claims. Like reference numerals refer to like elements throughout.

이하, 본 발명의 실시예들에 의한 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치 및 방법을 설명하기 위한 블록도 또는 처리 흐름도에 대 한 도면들을 참고하여 본 발명에 대해 설명하도록 한다. Hereinafter, the present invention will be described with reference to a block diagram or a flowchart illustrating a dynamic detection apparatus and method for kernel mode stack overflow in a computer operating system according to embodiments of the present invention.

이 때, 처리 흐름도 도면들의 각 블록과 흐름도 도면들의 조합들은 컴퓨터 프로그램 인스트럭션들에 의해 수행될 수 있음을 이해할 수 있을 것이다. At this point, it will be understood that each block of the flowchart illustrations and combinations of flowchart illustrations may be performed by computer program instructions.

이들 컴퓨터 프로그램 인스트럭션들은 범용 컴퓨터, 특수용 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서에 탑재될 수 있으므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비의 프로세서를 통해 수행되는 그 인스트럭션들이 흐름도 블록(들)에서 설명된 기능들을 수행하는 수단을 생성하게 된다. Since these computer program instructions may be mounted on a processor of a general purpose computer, special purpose computer, or other programmable data processing equipment, those instructions executed through the processor of the computer or other programmable data processing equipment may be described in flow chart block (s). It creates a means to perform the functions.

이들 컴퓨터 프로그램 인스트럭션들은 특정 방식으로 기능을 구현하기 위해 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 지향할 수 있는 컴퓨터 이용 가능 또는 컴퓨터 판독 가능 메모리에 저장되는 것도 가능하므로, 그 컴퓨터 이용가능 또는 컴퓨터 판독 가능 메모리에 저장된 인스트럭션들은 흐름도 블록(들)에서 설명된 기능을 수행하는 인스트럭션 수단을 내포하는 제조 품목을 생산하는 것도 가능하다. These computer program instructions may be stored in a computer usable or computer readable memory that can be directed to a computer or other programmable data processing equipment to implement functionality in a particular manner, and thus the computer usable or computer readable memory. It is also possible for the instructions stored in to produce an article of manufacture containing instruction means for performing the functions described in the flowchart block (s).

컴퓨터 프로그램 인스트럭션들은 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에 탑제되는 것도 가능하므로, 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비 상에서 일련의 동작 단계들이 수행되어 컴퓨터로 실행되는 프로세스를 생성해서 컴퓨터 또는 기타 프로그램 가능한 데이터 프로세싱 장비를 수행하는 인스트럭션들은 흐름도 블록(들)에서 설명된 기능들을 실행하기 위한 단계들을 제공하는 것도 가능하다. Computer program instructions It is also possible to mount on a computer or other programmable data processing equipment, so that a series of operating steps are performed on the computer or other programmable data processing equipment to create a computer-implemented process to perform the computer or other programmable data processing equipment. It is also possible for the instructions to provide steps for performing the functions described in the flowchart block (s).

또한, 각 블록은 특정된 논리적 기능(들)을 실행하기 위한 하나 이상의 실행 가능한 인스트럭션들을 포함하는 부, 세그먼트 또는 코드의 일부를 나타낼 수 있다. In addition, each block may represent a portion, segment, or portion of code that includes one or more executable instructions for executing a specified logical function (s).

또, 몇 가지 대체 실행예들에서는 블록들에서 언급된 기능들이 순서를 벗어나서 발생하는 것도 가능함을 주목해야 한다. It should also be noted that in some alternative implementations, the functions noted in the blocks may occur out of order.

예컨대, 잇달아 도시되어 있는 두 개의 블록들은 사실 실질적으로 동시에 수행되는 것도 가능하고 또는 그 블록들이 때때로 해당하는 기능에 따라 역순으로 수행되는 것도 가능하다.For example, the two blocks shown in succession may in fact be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending on the corresponding function.

이하, 첨부된 도면을 참조하여 본 발명의 바람직한 실시예를 상세히 설명하기로 한다.Hereinafter, exemplary embodiments of the present invention will be described in detail with reference to the accompanying drawings.

도 3은 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 메모리 관리를 위한 구성 요소를 나타낸 도면이다.3 is a diagram illustrating components for memory management of a kernel system in a computer operating system according to an exemplary embodiment of the present invention.

도시한 바와 같이, 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 메모리 관리를 위한 구성 요소는 커널 스택 매니저(310), 페이지 폴트 핸들러(320), 가상 메모리 관리자(330), 페이지 프레임 할당자(Page Frame Allogator)(340), 및 다른 요소(350)는 포함하여 구성된다.As shown, components for memory management of a kernel system in a computer operating system according to an embodiment of the present invention are the kernel stack manager 310, page fault handler 320, virtual memory manager 330, page frame allocator (Page Frame Allogator) 340, and other elements 350 are included.

커널 스택 매니저(310)는 커널 스택 생성시 스택 영역의 뒷부분에 보호 영역을 추가하여 스택을 초기화한다.The kernel stack manager 310 initializes the stack by adding a protection area at the rear of the stack area when generating the kernel stack.

페이지 폴트 핸들러(320)는 커널 스택 오버플로우 발생시 페이지 폴트 예외(page fault exception)가 발생하게 되고, 페이지 폴트 핸들러에서 에러 메시지 출력 등의 오버플로우 발생시의 처리를 수행한다.The page fault handler 320 generates a page fault exception when a kernel stack overflow occurs, and performs a process when an overflow occurs such as an error message output in the page fault handler.

가상 메모리 관리자(330)는 커널의 가상 메모리 관리자로서 커널에서 사용하는 메모리의 어드레싱 및 커널 스택의 어드레싱을 담당한다. 커널의 가상 메모리 관리자에서 관리되는 가상 주소공간은 처음 메모리 할당 시는 물리 메모리와 연결되지 않은 상태이고, 가상 주소공간으로의 액세스 발생시 물리 메모리가 연결되지 않은 경우, 페이지 오류 예외(page fault exception)가 발생되어 페이지 오류 핸들러(Page Fault Handler)에서 물리 메모리에 매핑이 된다.The virtual memory manager 330 is a virtual memory manager of the kernel and is responsible for addressing memory used in the kernel and addressing the kernel stack. The virtual address space managed by the kernel's virtual memory manager is not associated with physical memory when the memory is first allocated, and a page fault exception occurs when the physical memory is not associated with access to the virtual address space. Generated and mapped to physical memory by the Page Fault Handler.

페이지 프레임 할당자(Page Frame Allogator)(340)는 물리 메모리를 4KB 의 페이지(page) 단위로 관리하고, 필요한 경우 물리 메모리를 할당하여 가상 메모리에 매핑시킨다. 커널 스택에서 사용되는 물리 메모리를 여기서 할당받는다.The page frame allocator 340 manages the physical memory in units of 4 KB pages, and allocates the physical memory to the virtual memory if necessary. The physical memory used by the kernel stack is allocated here.

다른 요소(350)는 디바이스 드라이버, 파일 시스템 등 커널을 구성하고 있는 커널의 서브 시스템들을 의미한다. 커널 코드가 실행되는 부분으로서, 커널 코드가 실행되면서 커널 스택 영역에 푸쉬(push), 팝(pop) 연산이 발생하게 되고, 할당된 스택 크기 이상의 푸쉬(push)가 발생할 때 오버플로우가 발생하게 된다.The other element 350 refers to subsystems of the kernel constituting the kernel, such as a device driver and a file system. As the kernel code is executed, push and pop operations occur in the kernel stack area as the kernel code is executed, and an overflow occurs when a push larger than the allocated stack size occurs. .

이상의 커널 서브 시스템 중에서 커널 스택 매니저(310)와 페이지 폴트 핸들러(320)는 종래의 커널의 동작과 달라지는 부분이다. 이는 본 발명에서 커널 스택 생성 및 초기화, 그리고 오버플로우 처리의 동작에 관여한다.Among the above kernel subsystems, the kernel stack manager 310 and the page fault handler 320 are different from those of the conventional kernel. It is involved in the operation of kernel stack creation and initialization and overflow processing in the present invention.

도 4는 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 동작을 나타내는 도면이다.4 illustrates an operation of a kernel system in a computer operating system according to an exemplary embodiment of the present invention.

도시한 바와 같이, 커널 스택 매니저에서 가상 주소 공간에 커널 스택 영역 을 생성하고 초기화 하는 것을 나타낸다.As shown, the kernel stack manager represents creating and initializing a kernel stack region in the virtual address space.

종래 기술과 같이 커널은 가상 주소 공간을 사용하고, 가상 주소 공간은 크게 커널 영역과 사용자 영역으로 구분된다(미도시).As in the prior art, the kernel uses a virtual address space, and the virtual address space is largely divided into a kernel region and a user region (not shown).

태스크 정보가 없는 스택(410a)은 8KB 영역을 모두 스택 용도로만 사용하는 경우를 나타낸다. 여기서 태스크 정보는 별도의 메모리 공간에 위치하게 된다. 태스크 정보와 스택 영역 사이에 물리 페이지가 할당되지 않은 보호 영역을 추가한다. 태스크 정보가 없는 스택(410a)에서 스택 사용량이 8KB를 초과하는 경우, 인접한 메모리 영역을 건드리게 되어 야기될 수 있는 문제를 방지한다.The stack 410a without task information indicates a case in which all 8 KB areas are used only for stack purposes. The task information is located in a separate memory space. Add a protected area with no physical pages allocated between the task information and the stack area. If the stack usage exceeds 8KB in the stack 410a without task information, the problem that may be caused by touching adjacent memory areas is prevented.

태스크 정보가 있는 스택(410b)은 태스크 정보와 커널 스택 영역이 같은 메모리 공간을 사용하는 경우이다.The stack 410b including the task information is a case where the task information and the kernel stack area use the same memory space.

커널에서 태스크를 관리하기 위한 태스크 정보를 각 태스크 별로 8KB 할당하고 있고, 태스크 정보 유지용으로 할당된 이 8KB의 최상위 어드레스에 스택 포인터가 세팅되어 태스크 별 커널 스택 정보를 유지한다. Task information for managing tasks in the kernel is allocated to 8KB for each task, and a stack pointer is set at the highest address of this 8KB allocated for task information maintenance to maintain kernel stack information for each task.

태스크 정보가 있는 스택(410b)에도 태스크 정보와 스택 영역 사이에 물리 페이지가 할당되지 않은 보호 영역을 추가한다. 이 때 총 4개의 page(16KB)가 할당된다. 커널 스택이 8KB를 넘어가게 되면(오버플로우 발생), 보호 영역에서 페이지 폴트(page fault)가 발생하게 되어 태스크 정보를 안전하게 보호할 수 있게 된다.In the stack 410b including the task information, a protection region in which a physical page is not allocated is added between the task information and the stack region. In this case, a total of four pages (16KB) are allocated. When the kernel stack exceeds 8KB (overflows occur), a page fault occurs in the protected area, which keeps the task information safe.

도 5는 본 발명의 실시예에 따른 컴퓨터 운영체제에서 커널 시스템의 메모리 관리 방법의 흐름도이다.5 is a flowchart of a memory management method of a kernel system in a computer operating system according to an exemplary embodiment of the present invention.

커널 스택 매니저에서 가상 주소공간에 커널 스택 영역을 생성하고 초기화 한다(S510).The kernel stack manager creates and initializes a kernel stack region in the virtual address space (S510).

스택 영역의 맨 뒤에 보호 영역이 추가된다(S520). 보호 영역으로 1 페이지를 할당하여 총 3 페이지(12KB)가 스택 영역으로 할당된다. 이 때 보호 영역은 물리 페이지를 할당하지 않은 상태로 초기화한다.The protection region is added to the end of the stack region (S520). A total of three pages (12KB) are allocated as a stack area by allocating one page as a protection area. At this time, the protection area is initialized without allocating a physical page.

디바이스 드라이버, 파일 시스템 등의 커널 서브 시스템들이 수행되면서 커널 스택이 동작한다(S530). The kernel stack operates while kernel subsystems such as a device driver and a file system are performed (S530).

스택 포인터가 스택 영역 내에 있는 경우는 종래 방법과 동일하게 동작한다. When the stack pointer is in the stack area, it operates in the same manner as the conventional method.

스택 포인터가 보호 영역으로 진입하게 되면(오버플로우 발생), 보호 영역은 물리 페이지(page)가 매핑되지 않은 상태이기 때문에 페이지 폴트 예외(page fault exception)가 발생하게 된다(S540).When the stack pointer enters the protection area (an overflow occurs), a page fault exception occurs because the protection area is not mapped to a physical page (S540).

오버플로우를 처리한다(S550).Process the overflow (S550).

커널 스택 오버플로우가 발생하게 되면 페이지 폴트 핸들러(page fault handler)에서 에러 메시지를 출력해준다. 메시지에는 스택 포인터, 콜 트레이스(call trace), 및 오버플로우가 발생된 태스크 정보 등을 포함하여 에러 발생시 문제의 원인을 파악할 수 있도록 한다.If a kernel stack overflow occurs, the page fault handler will print an error message. The messages include stack pointers, call traces, and overflowed task information to help identify the cause of the problem when an error occurs.

본 발명의 실시예에서 사용되는 '~부'라는 용어는 소프트웨어 또는 FPGA(Field Programmable Gate Array) 또는 ASIC(Application Specific Integrated Circuit)와 같은 하드웨어 구성요소를 의미하며, '~부'는 소정의 역할들을 수행한다. The term '~ part' used in an embodiment of the present invention means a software component or a hardware component such as a field programmable gate array (FPGA) or an application specific integrated circuit (ASIC), and '~ part' refers to predetermined roles. Perform.

그렇지만 '~부'는 소프트웨어 또는 하드웨어에 한정되는 의미는 아니다.However, '~' is not meant to be limited to software or hardware.

'~부'는 어드레싱할 수 있는 저장 매체에 있도록 구성될 수도 있고 하나 또는 그 이상의 프로세서들을 재생시키도록 구성될 수도 있다. '~ Portion' may be configured to be in an addressable storage medium or may be configured to play one or more processors.

따라서, 일 예로서 '~부'는 소프트웨어 구성요소들, 객체지향 소프트웨어 구성요소들, 클래스 구성요소들 및 태스크 구성요소들과 같은 구성요소들과, 프로세스들, 함수들, 속성들, 프로시저들, 서브루틴들, 프로그램 코드의 세그먼트들, 드라이버들, 펌웨어, 마이크로코드, 회로, 데이터, 데이터베이스, 데이터 구조들, 테이블들, 어레이들, 및 변수들을 포함한다. Thus, as an example, '~' means components such as software components, object-oriented software components, class components, and task components, and processes, functions, properties, procedures, and the like. Subroutines, segments of program code, drivers, firmware, microcode, circuits, data, databases, data structures, tables, arrays, and variables.

구성요소들과 '~부'들 안에서 제공되는 기능은 더 작은 수의 구성요소들 및 '~부'들로 결합되거나 추가적인 구성요소들과 '~부'들로 더 분리될 수 있다.The functionality provided within the components and the 'parts' may be combined into a smaller number of components and the 'parts' or further separated into additional components and the 'parts'.

이상과 첨부된 도면을 참조하여 본 발명의 실시예를 설명하였지만, 본 발명이 속하는 기술분야에서 통상의 지식을 가진 자는 본 발명이 그 기술적 사상이나 필수적인 특징을 변경하지 않고서 다른 구체적인 형태로 실시될 수 있다는 것을 이해할 수 있을 것이다. 그러므로 이상에서 기술한 실시예들은 모든 면에서 예시적인 것이며 한정적이 아닌 것으로 이해해야만 한다.Although embodiments of the present invention have been described above with reference to the accompanying drawings, those skilled in the art to which the present invention pertains may implement the present invention in other specific forms without changing the technical spirit or essential features thereof. You will understand that. Therefore, it should be understood that the embodiments described above are exemplary in all respects and not restrictive.

상기한 바와 같은 본 발명의 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치 및 방법에 따르면 다음과 같은 효과가 하나 혹은 그 이상 있다.According to the apparatus and method for dynamically detecting kernel mode stack overflow in a computer operating system of the present invention as described above, one or more of the following effects are provided.

커널 스택 오버플로우 발생 시점에 오버플로우를 유발한 커널 코드 위치를 파악할 수 있기 때문에 디버깅 시에 유용하고 될 수 있는 장점이 있다.It can be useful when debugging because it can identify the location of the kernel code that caused the overflow when a kernel stack overflow occurs.

커널의 안정성 확보를 제공하는 장점이 있다.This has the advantage of providing kernel stability.

Claims (4)

커널 스택 생성시 스택 영역의 뒷부분에 보호 영역을 추가하여 스택을 초기화 하는 커널 스택 매니저;A kernel stack manager that initializes the stack by adding a protection area at the end of the stack area when the kernel stack is created; 상기 커널 스택에서 오버플로우 발생시 페이지 폴트 예외가 발생하는 경우, 에러 메시지를 출력하는 페이지 폴트 핸들러;A page fault handler that outputs an error message when a page fault exception occurs when an overflow occurs in the kernel stack; 상기 커널에서 사용하는 메모리의 어드레싱 및 커널 스택의 어드레싱을 담당하는 가상 메모리 관리자; 및A virtual memory manager responsible for addressing a memory used in the kernel and addressing a kernel stack; And 상기 메모리를 소정의 페이지 단위로 관리하고 상기 메모리를 할당할 경우 상기 가상 메모리에 매핑시키는 페이지 프레임 할당자를 포함하는 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치.And a page frame allocator for managing the memory in predetermined page units and mapping the memory to the virtual memory when allocating the memory. 제 1 항에 있어서,The method of claim 1, 상기 스택 영역의 상기 보호 영역은 1 페이지 단위로 할당되어 상기 스택 영역에 포함되며, 물리 페이지를 할당하지 않은 상태로 초기화하는 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 장치.And a protection area of the stack area is included in the stack area in units of one page, and initializes the kernel mode stack overflow in an unallocated state. 커널 스택 매니저에서 가상 주소공간에 커널 스택 영역을 생성하고 초기화하는 단계; Creating and initializing a kernel stack region in a virtual address space in the kernel stack manager; 디바이스 드라이버, 파일 시스템의 커널 서브 시스템들이 수행되면서 상기 커널 스택이 동작하는 단계;Operating the kernel stack while a device driver and a kernel subsystem of a file system are executed; 스택 포인터가 상기 커널 스택의 보호 영역으로 진입하게 되어 오버플로우 발생할 경우, 페이지 폴트 예외가 발생하는 단계; 및Generating a page fault exception when an overflow occurs because a stack pointer enters a protected area of the kernel stack; And 상기 오버플로우를 처리하는 단계를 포함하는 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 방법.And a method for dynamically detecting a kernel mode stack overflow in a computer operating system including processing the overflow. 제 3 항에 있어서,The method of claim 3, wherein 상기 오버플로우 처리 단계는 페이지 폴트 핸들러에서 스택 포인터, 콜 트레이스, 및 상기 오버플로우가 발생된 태스크 정보를 포함하여 에러 발생시 문제의 원인을 파악할 수 있게 하는 에러 메시지를 출력하는 단계를 포함하는 컴퓨터 운영체제에서 커널모드 스택 오버플로우의 동적 검출 방법.The overflow processing step may include outputting an error message in a page fault handler, including a stack pointer, a call trace, and information on the overflowed task to determine a cause of a problem when an error occurs. Dynamic Detection of Kernel-Mode Stack Overflows.
KR1020070003937A 2007-01-12 2007-01-12 Apparatus and method for dynamic detection of kernel stack overflow on operating system KR20080066459A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020070003937A KR20080066459A (en) 2007-01-12 2007-01-12 Apparatus and method for dynamic detection of kernel stack overflow on operating system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020070003937A KR20080066459A (en) 2007-01-12 2007-01-12 Apparatus and method for dynamic detection of kernel stack overflow on operating system

Publications (1)

Publication Number Publication Date
KR20080066459A true KR20080066459A (en) 2008-07-16

Family

ID=39821330

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020070003937A KR20080066459A (en) 2007-01-12 2007-01-12 Apparatus and method for dynamic detection of kernel stack overflow on operating system

Country Status (1)

Country Link
KR (1) KR20080066459A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9158622B2 (en) 2012-06-01 2015-10-13 Samsung Electronics Co. Ltd. Storage device including non-volatile memory device and repair method
CN111858363A (en) * 2020-07-24 2020-10-30 Oppo广东移动通信有限公司 Method and device for identifying stack overflow, terminal and storage medium
CN113448863A (en) * 2021-07-12 2021-09-28 度普(苏州)新能源科技有限公司 Method and device for testing utilization rate of dynamic stack of software of electronic control unit

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9158622B2 (en) 2012-06-01 2015-10-13 Samsung Electronics Co. Ltd. Storage device including non-volatile memory device and repair method
CN111858363A (en) * 2020-07-24 2020-10-30 Oppo广东移动通信有限公司 Method and device for identifying stack overflow, terminal and storage medium
CN113448863A (en) * 2021-07-12 2021-09-28 度普(苏州)新能源科技有限公司 Method and device for testing utilization rate of dynamic stack of software of electronic control unit
CN113448863B (en) * 2021-07-12 2024-02-09 度普(苏州)新能源科技有限公司 Method and device for testing utilization rate of dynamic stack of electronic control unit software

Similar Documents

Publication Publication Date Title
US20160019095A1 (en) Assigning a portion of physical computing resources to a logical partition
Amiri Sani et al. I/O paravirtualization at the device file boundary
KR101673435B1 (en) Creating an isolated execution environment in a co-designed processor
KR101955189B1 (en) Page fault injection in virtual machines to cause mapping of swapped-out memory pages into vm virtualized memory
Varanasi Implementing Hardware-supported Virtualization in OKL4 on ARM
JP6423547B2 (en) Virtual machine system
TW201115334A (en) Hardware resource management within a data processing system
KR20190096959A (en) Event filtering for virtual machine security applications
JP3910573B2 (en) Method, system and computer software for providing contiguous memory addresses
JP2007183952A (en) Method by which guest is accessing memory converted device and apparatus
US10664304B2 (en) Application memory protection using an extended page table switching virtual machine function
Weisberg et al. Enhancing Transportation System Networks Reliability by Securer Operating System
US10565141B1 (en) Systems and methods for hiding operating system kernel data in system management mode memory to thwart user mode side-channel attacks
US11960924B2 (en) Inter-thread interrupt signal sending based on interrupt configuration information of a PCI device and thread status information
KR20210068587A (en) Secure Memory Access in Virtualized Computing Environments
KR20230170079A (en) Dynamic address translation protection reset command
KR20080066459A (en) Apparatus and method for dynamic detection of kernel stack overflow on operating system
US10956571B2 (en) Kernel runtime integrity using processor assists
US20170168865A1 (en) Method and Apparatus for Hypervisor Based Monitoring of System Interactions
Olivier et al. The case for intra-unikernel isolation
US9600190B2 (en) Virtual machine functions for multiple privileged pages
Lackorzynski L4Linux porting optimizations
KR20150039377A (en) Method for device virtualization and apparatus therefor
KR20130131026A (en) Method for monitoring memory usage and problem per of realtime kernel
US10241821B2 (en) Interrupt generated random number generator states

Legal Events

Date Code Title Description
WITN Withdrawal due to no request for examination