Verification method of operating system memory management mechanism based on dependency assurance mechanism

Through the concurrent event model and parallel program verification framework, the complexity of memory management verification of preemptive real-time operating systems is solved, the security and reliability of memory management are ensured, and the formal verification of memory management of preemptive real-time operating systems is realized.

CN115033866BActive Publication Date: 2024-09-10ZHEJIANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210552736.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-19
Publication Date
2024-09-10
Estimated Expiration
2042-05-19

AI Technical Summary

Technical Problem

The existing dependency-guaranteed verification framework is difficult to directly apply to the verification of preemptive real-time operating systems, especially in terms of parallelism and complex memory management mechanisms. It cannot effectively capture the timing security properties and handle the interaction of infinite sequence events, and is difficult to adapt to Dynamic memory allocation and deallocation.

Method used

Use the concurrent event model to design the operating system memory management model, use the semantics and notations provided by the parallel program verification framework, model the system initialization state and running state, extract the memory safety properties, and verify the dependencies and guarantee conditions through the interactive theorem prover Correct,formal verification of memory management assurance.

Benefits of technology

It achieves formal verification of the operating system's memory management mechanism, ensures memory security, avoids memory leaks, memory block overlaps and free memory linked list definition errors, and improves the reliability of the operating system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033866B
    Figure CN115033866B
Patent Text Reader

Abstract

This invention discloses a method for verifying the operating system memory management mechanism based on a dependency guarantee mechanism. This method models the operating system as a concurrent event model and utilizes the program semantics and notation provided by a parallel program verification framework to model memory allocation and deallocation functions. Memory safety is designed and transformed into safety specifications under the semantics of the program verification framework. Based on the safety specifications, corresponding verification conditions are designed, and the compatibility of the verification conditions is automatically checked using the dependency-guarantee proof system of the parallel program verification framework. Finally, the correctness of the proof is checked through an interactive theorem prover. This invention utilizes formal verification and machine proof techniques to rigorously verify the security of the memory management system, ensuring the safe and reliable operation of the operating system and preventing potential problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of formal verification and relates to a verification method for an operating system memory management mechanism based on a dependency-guarantee mechanism. Background Art

[0002] Operating System (OS) is an essential component of critical systems. Therefore, the correctness and reliability of a system depends heavily on the underlying OS of the system. Memory management is a fundamental function of an OS, which provides a way to dynamically allocate portions of memory to programs upon their request and release memory for reuse when it is not available. Since program variables and data are stored in the allocated memory, incorrect memory management specifications and implementations can lead to system crashes or exploitable attacks on the entire system.

[0003] seL4 is the first verified general-purpose operating system kernel that can be used in practice. seL4 first implements the kernel prototype in Haskell, then uses the Isabelle theorem prover to form a formally verified execution specification, and ensures the correctness of the implementation by establishing the essential relationship between the execution specification and the C implementation code. The seL4 kernel contains 8700 lines of C code and 600 lines of assembly code, and its correctness is verified using more than 200,000 lines of Isabelle code.

[0004] Although seL4 has verified its memory management mechanism, it has the following two defects: (1) It is only verified on a serial operating system and does not consider the parallelism of the operating system. (2) The verified memory management system is relatively simple and only considers virtual memory mapping, without considering dynamic allocation and release of memory blocks, or complex data structures such as free memory linked lists.

[0005] The dependency-guarantee verification framework is a commonly used parallel program verification framework. By extending the Hoare logic, dependency conditions and guarantee conditions are added to record the impact of the environment and the thread itself on the system state. First, the individual threads are verified. Then, by checking whether the dependency-guarantee conditions between different threads are compatible, the compatibility of the independent thread verification results is checked, thereby verifying the entire parallel system.

[0006] Traditional dependency-guarantee based verification frameworks are difficult to apply directly to the verification of preemptive real-time operating systems due to the following two difficulties: (1) There is no direct method to verify the timing safety properties of preemptive real-time operating systems. Traditional dependency-guarantee based verification frameworks only focus on imperative programs, and it is difficult to capture the interaction with a potentially infinite sequence of event handlers and the input parameters of event handlers in dependency and guarantee relationships. (2) Dependency-guarantees must check whether the state of each variable is updated, even if the behavior of other processes obviously does not affect the variable. Therefore, it is necessary to extend the existing dependency-guarantee framework to adapt it to the characteristics of parallel and infinite response services of preemptive real-time operating systems. At the same time, it is necessary to reasonably model the complex parallel memory management mechanism and extract appropriate safety specifications to achieve formal verification of the operating system memory management mechanism. Summary of the invention

[0007] The purpose of the present invention is to provide a method for verifying an operating system memory management mechanism based on a dependency assurance mechanism in view of the deficiencies in the prior art.

[0008] The objective of the present invention is achieved through the following technical solution: a method for verifying an operating system memory management mechanism based on a dependency assurance mechanism, the method comprising the following steps:

[0009] (1) Operating system semantic design: The real-time operating system is modeled as a memory management model. The memory management model adopts a concurrent event model. The memory management model includes a scheduling event system and several thread event systems, and also includes system security regulations and dependency guarantee conditions that are common to real-time operating systems.

[0010] (2) Memory management protocol modeling: Using the program semantics and notations provided by the parallel program verification framework, the system initialization state, system operation state (such as memory group, current execution thread, private variables of each thread, etc.) and memory application and memory release functions of the operating system memory management mechanism are modeled;

[0011] (3) Design security specifications: Extract properties that are highly relevant to the operating system's memory safety, combine them with the memory management mechanism and memory group data structure, and use the semantic interface provided by the parallel program verification framework to transform the security properties into formal memory safety specifications.

[0012] (4) Design verification conditions: Based on the memory management model and system security regulations established in step (1), and the memory security regulations designed in step (3), design the dependencies and guarantee conditions of each event system; based on the task code of the operating system memory management module, the system security regulations established in step (1), and the memory security regulations designed in step (3), design the preconditions and postconditions of each event system;

[0013] (5) Verify the memory management model: Write a proof script to verify that a single event system meets the dependencies, guarantee conditions, and pre- and post-conditions, and verify the correctness of the proof script through an interactive theorem prover, thereby formally verifying the correctness of the single event system; use the event verification interface provided by the parallel program verification framework to verify whether the dependencies, guarantee conditions, and pre- and post-conditions between different event systems are compatible; use the event system verification interface provided by the parallel program verification framework to formally verify the memory management model.

[0014] Furthermore, traditional dependency guarantee-based verification frameworks focus only on imperative programs, and it is difficult to capture the interaction with a potentially infinite sequence of event systems, as well as the input parameters of the event systems, in dependency and guarantee relationships. A concurrent event model consists of a set of well-defined input event systems, and the concurrent event model handles these event systems by executing associated handlers for each event system. In a concurrent environment, the handlers of each event system can interact with the handlers of other event systems, such as hardware interrupts in a preemptive system.

[0015] Furthermore, in the step (1), the memory management model constructed includes a highly abstract scheduling event system for event scheduling and thread control, which can support the modeling of other operating systems.

[0016] Furthermore, in step (3), it is necessary to extract security properties that are strongly related to ensuring the safe and reliable operation of the memory management mechanism, including memory leaks, memory block overlaps, free memory block list definition errors, and memory pool data structure errors, and convert these security properties into formal memory safety specifications and represent them using the semantics provided by the parallel program verification framework.

[0017] Furthermore, in step (4), loop invariants are designed based on the designed preconditions and postconditions, so that the preconditions, postconditions and loop invariants are compatible with the event system.

[0018] Furthermore, the parallel program verification framework adopts PiCore and HOL-Hoare_Parallel, and the interactive theorem prover adopts Isabelle.

[0019] The beneficial effects of the present invention are as follows: the operating system memory management mechanism verification method based on the dependency guarantee mechanism proposed by the present invention ensures that the memory management system does not have memory leaks, memory block overlaps, free memory block linked list definition errors, and memory pool data structure errors, thereby increasing the reliability of the operating system operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0021] Figure 1 It is a concurrent event system diagram provided by an exemplary embodiment of the present invention.

[0022] Figure 2 It is a block diagram of a method implementation provided by an exemplary embodiment of the present invention.

[0023] Figure 3 It is a state modeling diagram provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION

[0024] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0025] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.

[0026] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. The singular forms "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0027] The embodiment of the present invention provides a method for verifying an operating system memory management mechanism based on a dependency guarantee mechanism, such as Figure 1 As shown, the following steps are included:

[0028] (1) Operating system semantic design: The real-time operating system is modeled as a memory management model. The memory management model adopts a concurrent event model. The memory management model includes a scheduling event system and several thread event systems, as well as system security regulations and dependency guarantee conditions that are common to real-time operating systems.

[0029] Without considering the initialization of the operating system, the operating system can be considered as a concurrent event-reaction system in an idle loop until it receives an interrupt request and executes the interrupt handler. In this concurrent event-reaction system, the execution of the interrupt handler can be interrupted by other processes and resumed later. In this concurrent event-reaction system, we consider a scheduler S and a set of threads t1,...,t m In this concurrent event-response system, the execution of the scheduler is atomic, because kernel services triggered by a thread cannot interrupt it. However, kernel services can be interrupted by the scheduler, i.e., the execution of a memory service by a thread t may be interrupted by the kernel scheduler. i Memory service called to execute another thread t j . Taking ucOS-II as an example, Figure 1 It is its memory management model, which includes a scheduling event system and several thread event systems. Threads will call memory application services or memory release services, and different threads may affect each other.

[0030] (2) Memory management protocol modeling: Using the program semantics and notations provided by the parallel program verification framework, the system initialization state, system operation state (such as memory group, current execution thread, private variables of each thread, etc.) and memory request and memory release functions of the operating system memory management mechanism are modeled.

[0031] Take the memory management module of ucOS-II as an example. First, the operating system state is modeled, including the memory group, the currently executing thread, and the private variables of each thread. We model the operating system state of ucOS-II as the record type in Isabelle, such as Figure 3As shown. The variable cur represents the currently executing thread, which can be an exact thread number or NULL; the variable OS_MEMs represents the entire memory, which is a set of thread pool references OS_MEM_ref; the mapping OS_MEM_info allows access to the memory pool data using the memory pool reference. The thread private variable is modeled as a full function that maps the thread number to the value of the thread private variable. Then we model the initial state of the operating system. In our memory management model, we model the initial state of the operating system as an axiom of the proof system, and then prove that the initial state meets the system security regulations. Finally, we model the memory application / release function. ucOS-II creates a memory group by the OSMemCreate function. The memory group is an implicit linked list structure, which is recorded by a structure with the first address, free list address, memory block size, number of memory blocks and number of free memory blocks. Use the memory application function OSMemGet function to obtain the head memory block of the free memory linked list. Use the memory release function OSMemPut function to release the memory block and insert the released memory block into the head of the free memory linked list. Most of the C code can be directly converted to the semantic symbols provided by PiCore. However, the memory management service uses OS_ENTER_CRITICAL();P;OS_EXIT_CRITICAL(); to ensure atomic execution of the interrupt handler by disabling interrupts. We simplify it to the ATOM semantics provided by PiCore so that the service will not be interrupted by other processes at this point.

[0032] (3) Design security specifications: Extract properties that are highly relevant to the operating system's memory safety, and combine them with the memory management mechanism and memory group data structure. Use the semantic interface provided by the parallel program verification framework to transform the security properties into formalized memory safety specifications.

[0033] Taking the memory management module of ucOS-II as an example, we extract the security properties that are strongly related to the safe and reliable operation of the memory management mechanism, including memory leakage, memory block overlap, free memory block list definition error, memory pool data structure error, and convert these security properties into formal memory safety specifications, and use the semantics provided by the parallel program verification framework to represent them. In combination with the ucOS-II memory management mechanism and memory group data structure, we use the semantic interface provided by PiCore to convert the security properties into formal security specifications. The security properties we verified in the memory verification of ucOS-II are shown in Table 1, including inv_cur indicating that the currently executing process must be in the RUNNING state, inv_NBlks indicating that the number of memory blocks in the memory pool is a positive integer, inv_NFBlks indicating that the number of free memory blocks in the memory pool is a natural number, inv_NFBlks2 indicating that the total number of memory blocks in the memory group is greater than or equal to the number of free memory blocks in the memory pool, and inv_NFList indicating that the number of free blocks in the memory group is equal to the length of the free memory block list.

[0034] Table 1 Memory safety specifications

[0035] Invariants describe inv_cur The current running thread state is RUNNING inv_NBlks Number of memory blocks ≥ 0 inv_NFBlks The number of free memory blocks ≥ 0 inv_NFBlks2 Number of memory blocks ≥ number of free memory blocks inv_NFList Number of free memory blocks = length of free memory block linked list

[0036] (4) Design verification conditions: Based on the memory management model and system security regulations established in step (1), and the memory security regulations designed in step (3), design the dependencies and guarantee conditions of each event system; based on the task code of the operating system memory management module, the system security regulations established in step (1), and the memory security regulations designed in step (3), design the preconditions and postconditions of each event system.

[0037] The dependency-guarantee conditions for the event system are a four-tuple:

[0038] RGCond=(pre,R,G,pst)

[0039] Where pre represents the precondition, R represents the dependency condition, G represents the guarantee condition, and pst represents the postcondition. For an event system P, a legal dependency-guarantee condition is denoted as It can be intuitively understood that if the state s∈pre before executing P, and any state transition that the environment can make is included in the dependency condition R, and any state transition that P can make is included in the guarantee condition G, then the final termination state belongs to the post-condition pst. We need to write corresponding preconditions, postconditions, and loop invariants based on the task code of the memory allocation / release function and the system safety regulations. The written preconditions, postconditions, and loop invariants need to be compatible with the dependency-guarantee conditions of the event system.

[0040] (5) Verify the memory management model: Write a proof script to verify that a single event system meets the dependencies, guarantee conditions, and pre- and post-conditions, and verify the correctness of the proof script through an interactive theorem prover, thereby formally verifying the correctness of the single event system; use the event verification interface provided by the parallel program verification framework to verify whether the dependencies, guarantee conditions, and pre- and post-conditions between different event systems are compatible; use the event system verification interface provided by the parallel program verification framework to formally verify the memory management model.

[0041] For example, the verification framework of the memory management model is as follows Figure 2 As shown. First, use the proof interface provided by HOL-Hoare_Parallel to write a proof to verify that the individual event system complies with the memory safety specification and dependency-guarantee conditions, and use Isabelle to verify the correctness of the proof, thereby achieving formal verification of the correctness of the individual event system. Finally, use PiCore's dependency-guarantee proof framework to automatically check whether the dependency-guarantee conditions and pre- and post-conditions between different event systems are compatible, thereby achieving formal verification of the entire memory management model.

[0042] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0043] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0044] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0045] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0046] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.

Claims

1. A method for verifying an operating system memory management mechanism based on a dependency assurance mechanism, characterized in that: The following steps are involved: (1) Operating system semantic design: The real-time operating system is modeled as a memory management model. The memory management model adopts a concurrent event model. The memory management model includes a scheduling event system and several thread event systems, and also includes system security regulations and dependency guarantee conditions that are common to real-time operating systems. (2) Memory management protocol modeling: Using the program semantics and notations provided by the parallel program verification framework, the system initialization state, system operation state, and memory application and memory release functions of the operating system memory management mechanism are modeled; (3) Design security specifications: Extract properties that are highly relevant to the operating system's memory safety, combine them with the memory management mechanism and memory group data structure, and use the semantic interface provided by the parallel program verification framework to transform the security properties into formal memory safety specifications. (4) Design verification conditions: Based on the memory management model and system security specifications established in step (1), and the memory security specifications designed in step (3), design the dependencies and guarantee conditions of each event system; Design the preconditions and postconditions of each event system based on the task code of the operating system memory management module, the system security specification established in step (1), and the memory security specification designed in step (3); (5) Verify the memory management model: Write a proof script to verify that the individual event system meets the dependencies, guarantee conditions, and preconditions and postconditions, and verify the correctness of the proof script through an interactive theorem prover, thereby formally verifying the correctness of the individual event system; The event verification interface provided by the parallel program verification framework is used to check whether the dependencies, guarantee conditions, and pre- and post-conditions between different event systems are compatible; the event system verification interface provided by the parallel program verification framework is used to formally verify the memory management model.

2. According to the method for verifying the memory management mechanism of an operating system based on a dependency assurance mechanism in claim 1, it is characterized in that: In step (1), the concurrent event model is composed of a set of accurately defined input event systems, and the concurrent event model processes these event systems by executing an associated processing program on each event system; In a concurrent environment, handlers for each event system can interact with handlers for other event systems.

3. The method for verifying an operating system memory management mechanism based on a dependency assurance mechanism according to claim 1, characterized in that: In the step (1), the memory management model constructed includes a highly abstract scheduling event system for event scheduling and thread control, and can support the modeling of other operating systems.

4. The method for verifying an operating system memory management mechanism based on a dependency assurance mechanism according to claim 1, characterized in that: In the step (3), it is necessary to extract security properties that are strongly related to ensuring the safe and reliable operation of the memory management mechanism, including memory leaks, memory block overlaps, free memory block list definition errors, and memory pool data structure errors, and convert these security properties into formal memory safety specifications and represent them using the semantics provided by the parallel program verification framework.

5. The method for verifying the memory management mechanism of an operating system based on a dependency assurance mechanism according to claim 1, characterized in that: In the step (4), loop invariants are designed based on the designed preconditions and postconditions, so that the preconditions, postconditions and loop invariants are compatible with the event system.

6. The method for verifying the memory management mechanism of an operating system based on a dependency assurance mechanism according to claim 1, characterized in that: The parallel program verification framework adopts PiCore and HOL-Hoare_Parallel, and the interactive theorem prover adopts Isabelle.