Memory management method and device

By replacing overlapping regions with placeholder VMAs and updating mapping relationships in virtual memory management, the operating system security vulnerability caused by overlapping virtual address regions is resolved, thereby improving the security and stability of the operating system.

CN121364950AActive Publication Date: 2026-01-20NEW H3C TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511937718.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-22
Publication Date
2026-01-20
Estimated Expiration
2045-12-22

AI Technical Summary

Technical Problem

In virtual memory management, the exposure of gaps caused by overlapping virtual address ranges can lead to operating system security vulnerabilities and crashes, and existing technologies have not been able to effectively solve this problem.

Method used

By receiving a forced memory mapping request, the target virtual address range is locked, the first VMA of the overlapping range is determined, and it is replaced with a placeholder VMA or a VMA created according to the mapping parameters. The old mapping relationship is released, the new mapping relationship is recorded, and the overlapping range is always managed by a VMA.

Benefits of technology

This avoids gap exposure and improves the security and robustness of the operating system, especially the system stability in high-security and high-concurrency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121364950A_ABST
    Figure CN121364950A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory management method and device, and relates to the technical field of computers.The method comprises the steps that a forced memory mapping request for a target virtual address interval is received, and the target virtual address interval is locked; determining a first VMA for managing the overlapping interval; replacing the determined first VMA with a second VMA; removing a first mapping relation between the overlapping interval and the mapped physical memory area from the page table; if the second VMA is the VMA corresponding to the overlapping interval, recording a second mapping relation between the VMA corresponding to the overlapping interval and a new physical memory area indicated by the forced memory mapping request in a page table; if the second VMA is a placeholder VMA, replacing the placeholder VMA with a VMA corresponding to the overlapping interval, and recording a second mapping relation in the page table; and unlocking the target virtual address interval. By applying the memory management scheme provided by the embodiment of the invention, the security of the operating system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a memory management method and device. BACKGROUND

[0002] An operating system using virtual memory management mechanism allocates an independent virtual address interval for each process, and maps the allocated virtual address interval to a physical memory region through a memory mapping operation, so that the process can access the mapped physical memory region by accessing the allocated virtual address interval. In order to manage the virtual address interval allocated to each process, the operating system records the mapping relationship between the virtual address interval allocated to the process and the physical memory region in a page table, and creates a virtual memory area (VMA) for each process, and manages the virtual address interval allocated to the process through the VMA.

[0003] When performing a memory mapping operation on a virtual address interval, the virtual address interval may overlap with the virtual address interval managed by the currently effective VMA. In this case, during the memory mapping process using the related technology, there may be a short period of time without VMA management of the virtual address interval, that is, a gap exposure occurs. This will cause security vulnerabilities in the operating system, and in severe cases, may cause abnormal running of the application program or crash of the operating system. SUMMARY

[0004] Embodiments of the present application aim to provide a memory management method and device to improve the security of the operating system. The specific technical solutions are as follows:

[0005] In a first aspect, the embodiments of the present application provide a memory management method, which comprises:

[0006] receiving a forced memory mapping request for a target virtual address interval, and locking the target virtual address interval;

[0007] determining a first VMA for managing an overlapping interval, wherein the overlapping interval is an interval overlapping between a virtual address interval managed by a currently effective VMA and the target virtual address interval;

[0008] replacing the determined first VMA with a second VMA, wherein the second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is a VMA created according to mapping parameters carried by the forced memory mapping request for managing the overlapping interval;

[0009] removing a first mapping relationship between the overlapping interval and a mapped physical memory region from the page table;

[0010] if the second VMA is the VMA corresponding to the overlapping interval, recording a second mapping relationship between the VMA corresponding to the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table;

[0011] if the second VMA is the placeholder VMA, replacing the placeholder VMA with the VMA corresponding to the overlapping interval, and recording the second mapping relationship in the page table;

[0012] unlocking the target virtual address interval.

[0013] In an embodiment of the present application, the determining the first VMA that manages the overlapping interval comprises:

[0014] from the currently valid VMAs, determining a candidate VMA that has an overlapping interval with the target virtual address interval;

[0015] if part of the virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, splitting a third VMA from the candidate VMA, and taking the third VMA as the first VMA, wherein the third VMA manages the part of the interval;

[0016] if the entire virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, determining the candidate VMA as the first VMA.

[0017] In an embodiment of the present application, after the splitting of the third VMA from the candidate VMA, the method further comprises:

[0018] from the mapping relationship between the virtual address interval managed by the candidate VMA and the mapped physical memory region in the page table, splitting a mapping relationship between the part of the interval and the mapped physical memory region.

[0019] In an embodiment of the present application, the removing the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table comprises:

[0020] migrating the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table to a to-be-cleaned list;

[0021] performing a page table entry cleaning operation on the first mapping relationship recorded in the to-be-cleaned list in units of the to-be-cleaned list.

[0022] In an embodiment of the present application, after the replacement of the determined first VMA with the second VMA, the method further comprises:

[0023] In a case that the mapping type recorded in the first VMA is a file mapping type, remove an association between a file mapped by the first VMA and the first VMA.

[0024] In a second aspect, an embodiment of the present application provides a memory management apparatus, which comprises:

[0025] a request receiving module, configured to receive a forced memory mapping request for a target virtual address interval, and lock the target virtual address interval;

[0026] a VMA determining module, configured to determine a first VMA for managing an overlapping interval, wherein the overlapping interval is an interval overlapping between a virtual address interval managed by a currently effective VMA and the target virtual address interval;

[0027] a VMA replacing module, configured to replace the determined first VMA with a second VMA, wherein the second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is a VMA for managing the overlapping interval, which is created according to mapping parameters carried in the forced memory mapping request;

[0028] a relationship removing module, configured to remove a first mapping relationship between the overlapping interval and a mapped physical memory region from a page table;

[0029] a first recording module, configured to, in a case that the second VMA is the VMA corresponding to the overlapping interval, record a second mapping relationship between the VMA corresponding to the overlapping interval and a new physical memory region indicated by the forced memory mapping request in the page table;

[0030] a second recording module, configured to, in a case that the second VMA is the placeholder VMA, replace the placeholder VMA with the VMA corresponding to the overlapping interval, and record the second mapping relationship in the page table;

[0031] an interval unlocking module, configured to unlock the target virtual address interval.

[0032] In an embodiment of the present application, the VMA determining module is specifically configured to:

[0033] determine, in the currently effective VMA, a candidate VMA in which a managed virtual address interval overlaps with the target virtual address interval;

[0034] if a part of the virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, split a third VMA from the candidate VMA, and take the third VMA as the first VMA, wherein the third VMA manages the part of the virtual address interval;

[0035] If the virtual address interval managed by the candidate VMA as a whole overlaps with the target virtual address interval, the candidate VMA is determined as the first VMA.

[0036] In an embodiment of the present application, the apparatus further comprises:

[0037] The relationship splitting module is configured to, after the third VMA is split from the candidate VMA, split, in the page table, a mapping relationship between the part of the virtual address interval managed by the candidate VMA and the mapped physical memory region from a mapping relationship between the virtual address interval managed by the candidate VMA and the mapped physical memory region.

[0038] In an embodiment of the present application, the relationship removing module is specifically configured to:

[0039] migrate the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table to a to-be-cleaned list;

[0040] perform a page table entry cleaning operation on the first mapping relationship recorded in the to-be-cleaned list in units of the to-be-cleaned list.

[0041] In an embodiment of the present application, the apparatus further comprises:

[0042] The relationship removing module is configured to, after the determined first VMA is replaced by the second VMA, remove an association relationship between the first VMA and a file mapped by the first VMA in a case where a mapping type recorded in the first VMA is a file mapping type.

[0043] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;

[0044] The memory is configured to store a computer program.

[0045] The processor is configured to execute the program stored on the memory, and implement the method steps of any one of the first aspect.

[0046] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method steps of any one of the first aspect.

[0047] The embodiment of the present application has the following beneficial effects:

[0048] From the above, when the memory is managed by the scheme provided in the embodiments of the present application, after receiving the forced memory mapping request, the first VMA managing the overlapping interval is determined, the interval managed by the first VMA belongs to the target virtual address interval targeted by the forced memory mapping request, and the overlapping interval actually has an established mapping relationship. When the mapping relationship of the overlapping interval in the target virtual address interval is re-established based on the forced memory mapping request, the first VMA is replaced by the placeholder VMA or the VMA for managing the overlapping interval created according to the mapping parameters in the request, and then the first mapping relationship of the overlapping interval is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0049] Compared with deleting the first VMA and removing the first mapping relationship first, and then establishing a new VMA and recording the second mapping relationship, this way has no VMA management for the overlapping interval in the time period of deleting the first VMA and establishing the new VMA, and the gap exposure may occur. However, in the present scheme, the first VMA is replaced by the second VMA before the mapping relationship is removed, and in the case that the second VMA is the placeholder VMA, it will be replaced by the VMA corresponding to the overlapping interval again subsequently. The whole process can ensure that the overlapping interval is always managed by the VMA, and in the case that the second VMA is the VMA corresponding to the overlapping interval, it can also ensure that the overlapping interval is always managed by the VMA. Therefore, by applying the memory management scheme provided in the embodiments of the present application, the gap exposure can be avoided in the whole request processing process, so as to avoid the security vulnerability of the operating system and improve the security of the operating system. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other embodiments can also be obtained by those skilled in the art based on these drawings.

[0051] Figure 1 The relationship between the VMA, the virtual address interval, the page table and the physical memory region provided in the embodiments of the present application is shown in the schematic diagram;

[0052] Figure 2 The flowchart of the first memory management method provided in the embodiments of the present application is shown in the schematic diagram;

[0053] Figure 3 The distribution of a virtual address interval provided in the embodiments of the present application is shown in the schematic diagram;

[0054] Figure 4 The structure of a maple tree tree structure provided in the embodiments of the present application is shown in the schematic diagram;

[0055] Figure 5a This is a schematic diagram of the first mapping relationship provided in the embodiments of this application;

[0056] Figure 5b This is a schematic diagram of a second mapping relationship provided in an embodiment of this application;

[0057] Figure 6 A flowchart illustrating the second memory management method provided in this application embodiment;

[0058] Figure 7 This is a schematic diagram of the structure of a memory management device provided in an embodiment of this application;

[0059] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.

[0061] First, some concepts mentioned in the embodiments of this application will be explained.

[0062] 1. VMA

[0063] Virtual Address Maps (VMAs) are the basic units used by the operating system kernel (such as Linux) to manage the virtual address ranges of processes. Each VMA represents a contiguous range within a process's virtual address range. The operating system kernel uses VMAs to record information such as the starting address, length, permissions, and mapping type of this range. Efficient VMA management is crucial for implementing functions such as process isolation, memory allocation and reclamation, and memory access permission control.

[0064] See Figure 1 It illustrates the relationship between VMA, virtual address ranges, page tables, and physical memory regions, from... Figure 1 As can be seen, VMA is used to manage virtual address ranges. The page table records the mapping relationship between virtual address ranges and physical memory regions. When a process receives a memory access request, after the VMA verifies the request for permissions, identity, etc., it can read the mapping relationship recorded in the page table, determine the physical memory region mapped by the process's virtual address range based on the mapping relationship, and thus obtain the data stored in the determined physical memory region.

[0065] 2. Mapping type

[0066] Mapping type is one of the information recorded in VMA, including file mapping and anonymous mapping.

[0067] The application degree can request the operating system to allocate or map the specified virtual memory interval through the system call mmap() method, so as to realize flexible management of memory resources. When a new memory mapping is created in the virtual address interval of the calling process by using the mmap() method, the related code is as follows:

[0068] viod mmap(size_t length;

[0069] void addr[length],size_t length,int prot,int flags,

[0070] int fd,dff_t offset);

[0071] In the above code, if the fd parameter specifies an opened file or device, mmap() will map a segment of the file content to the virtual address interval of the process, so that the access to this segment of virtual memory directly acts on the file content through the page cache, and this mapping is called file mapping.

[0072] If the fd parameter is -1 and MAP_ANONYMOUS is specified, a memory region not associated with any file is created, and this mapping is called anonymous mapping, which is often used for private memory allocation.

[0073] In addition, in the above code, the addr parameter is: the expected mapping start address (if this parameter is set to NULL, the kernel automatically selects a suitable address);

[0074] The length parameter is: the byte length of the mapping, which must be greater than 0, and is usually aligned according to the page size;

[0075] Other parameters (such as prot, flags) are used to determine the mapping permission and shared / private attribute.

[0076] The memory management method provided by the embodiments of the present application will be described below through specific examples.

[0077] Referring to Figure 2 , Figure 2 The flowchart of the first memory management method provided by the embodiments of the present application is shown in the embodiment, and the above method includes the following steps S201-S207.

[0078] Step S201: receiving a forced memory mapping request for a target virtual address interval, and locking the target virtual address interval.

[0079] The above forced memory mapping request is used to force the establishment of a mapping relationship between the target virtual address interval and the physical memory. If the target virtual address interval has already established a memory mapping relationship with a piece of physical memory, the memory mapping relationship between the target virtual address interval and the physical memory needs to be removed, and the memory mapping relationship between the target virtual address interval and other physical memory is re-established according to the forced memory mapping request.

[0080] For example, in the mmap() system call, the MAP_FIXED flag is widely used to require the operating system to force the mapping of the specified physical memory region to the virtual address interval provided by the user. Such a requirement is particularly common in embedded development, runtime memory layout optimization, hardware interface programming, and high-performance computing scenarios. If an application calls mmap() and sets the MAP_FIXED flag, the operating system will attempt to force the mapping of the specified memory region to the virtual address interval specified in mmap(). If the virtual address interval is already occupied by other memory mapping, the operating system will remove the original mapping and replace it with a new mapping.

[0081] After receiving the forced memory mapping request, the operating system can parse the forced memory mapping request to obtain the target virtual address interval, and lock the target virtual address interval to prevent other threads or processes from accessing or concurrently modifying the target virtual address interval during management, ensuring the mutual exclusivity of operations.

[0082] In an embodiment of the present application, the operating system can perform write-mode memory mapping locking (mmap_lock) on the target virtual address interval.

[0083] Alternatively, the operating system can perform read-write mode memory mapping locking on the target virtual address interval.

[0084] Step S202: Determine the first VMA that manages the overlapping interval.

[0085] The overlapping interval is the interval overlapping between the virtual address interval managed by the currently effective VMA and the target virtual address interval.

[0086] Each currently effective VMA manages a piece of virtual address interval. The operating system can determine the overlapping interval between the target virtual address interval and the virtual address interval managed by the currently effective VMA, and the determined interval is the overlapping interval, so that the VMA managing the overlapping interval is the first VMA.

[0087] Referring to Figure 3 , Figure 3 shows the interval distribution of the virtual address interval managed by the currently effective VMA, and the target virtual address interval isFigure 3 In the example, the virtual address range managed by the effective VMA1 is 0x0000-0x1000, the virtual address range managed by the effective VMA2 is 0x1000-0x2000, the virtual address range managed by the effective VMA3 is 0x2000-0x3000, and the virtual address range managed by the effective VMA4 is 0x7000-0x8000. If the target virtual address range is 0x0000-0x5000, the overlapping range overlapping with the target virtual address range in the virtual address range managed by each effective VMA is 0x0000-0x3000, and thus the effective VMA1, the effective VMA2, and the effective VMA3 can be determined as the first VMAs.

[0088] In an embodiment of the present application, the operating system manages the virtual address ranges of the processes by using a maple tree data structure, and each end node of each branch of the maple tree corresponds to an effective VMA. When determining the first VMA, the node corresponding to the overlapping range can be searched in the maple tree according to the target virtual address range, and the VMA corresponding to the searched node can be determined as the first VMA.

[0089] Referring to Figure 4 , Figure 4 is a structural diagram of the maple tree data structure. In Figure 4 , the root node records three virtual addresses, 24, 44, and 99. The root node is connected with three nodes below, the first node records 17 and 24, and the node corresponds to the virtual address range 17-24; the second node records 34 and 44, and the node corresponds to the virtual address range 34-44; and the third node records 54, 64, and 74. The third node is connected with two nodes below, the first node records 45 and 50, and the node corresponds to the virtual address range 45-50; and the second node records 55 and 60, and the node corresponds to the virtual address range 55-60. In Figure 4 , when searching the target address range 17-50 in the maple tree shown in the figure, the nodes corresponding to the three virtual address ranges 17-24, 34-44, and 45-50 can be searched, and thus the VMAs corresponding to the three nodes can be determined as the first VMAs.

[0090] In the case of managing the virtual address ranges of the processes by using the maple tree data structure, after obtaining the forced memory mapping request, the maple tree data structure can be locked, the target virtual address range can be locked after the target virtual address range is parsed from the forced memory mapping request, and the target virtual address range and the maple tree data structure can be unlocked after the subsequent processing completes the request.

[0091] Step S203: replacing the determined first VMA with a second VMA.

[0092] The second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval.

[0093] The following describes the two cases of the second VMA.

[0094] 1. The second VMA is a placeholder VMA

[0095] The placeholder VMA is a pre-generated VMA, which is used to prevent the overlapping interval from being without VMA management.

[0096] Specifically, the first VMA belongs to a valid VMA, and the overlapping interval managed by the first VMA actually has an established memory mapping relationship. When re-establishing the mapping relationship of the overlapping interval in response to the forced memory mapping request, the VMA that manages the overlapping interval also needs to be re-established. After the first VMA is determined, if the first VMA is directly removed and a new VMA is created subsequently, the overlapping interval will be without VMA management during the period of removing the first VMA and creating the new VMA. In this case, a malicious process or attacker can directly access the overlapping interval without obstacles, read and tamper with the data on the physical memory mapped by the overlapping interval, thereby causing security risks such as data leakage, privilege escalation, and system crash. Therefore, when the first VMA is removed, the first VMA can be replaced with a pre-generated placeholder VMA, and the placeholder VMA can be subsequently replaced with a new VMA, so that the overlapping interval is always under VMA management.

[0097] In the case where multiple first VMAs are determined, each first VMA can be replaced with a placeholder VMA.

[0098] 2. The second VMA is a VMA corresponding to the overlapping interval

[0099] The VMA corresponding to the overlapping interval is a VMA created to manage the overlapping interval according to mapping parameters carried by the forced memory mapping request.

[0100] The mapping parameters can include a mapping physical address, a byte length, mapping permissions, a shared / private attribute, and the like.

[0101] Specifically, after receiving the forced memory mapping request, the forced memory mapping request is parsed to obtain the mapping parameters carried in the request. When the first VMA is determined in step S202, the overlapping interval is also determined. Thus, according to the obtained mapping parameters and the overlapping interval, the VMA for managing the overlapping interval, i.e., the VMA corresponding to the overlapping interval, can be created, so that the first VMA is replaced with the VMA corresponding to the overlapping interval.

[0102] In the case of determining a plurality of first VMAs, for each first VMA, a VMA corresponding to the overlapping interval corresponding to the first VMA managed by the first VMA can be created, and the first VMA is replaced by the created VMA corresponding to the overlapping interval. The plurality of first VMAs are replaced by the plurality of VMAs corresponding to the overlapping intervals.

[0103] Step S204: removing the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table.

[0104] The page table is used to record the mapping relationship between the virtual address interval and the physical memory region.

[0105] After replacing the first VMA with the second VMA, the mapping relationship corresponding to the overlapping interval managed by the first VMA can be retrieved in the page table, and after retrieving the mapping relationship corresponding to the overlapping interval, the mapping relationship is removed from the page table.

[0106] The first VMA can be one or more, each first VMA manages a virtual address interval, and the page table also records the first mapping relationship of the virtual address interval managed by each VMA. Therefore, the first mapping relationship can be removed in any of the following two ways.

[0107] In the first way, the first mapping relationship between the overlapping interval and the mapped physical memory region is migrated from the page table to the to-be-cleaned list; the page table entry cleaning operation is performed on the first mapping relationship recorded in the to-be-cleaned list in units of the to-be-cleaned list.

[0108] This way first migrates all first mapping relationships to the to-be-cleaned list, so that the page table entry cleaning operation is performed on the to-be-cleaned list, which can remove all first mapping relationships at a time, realize atomic operation for all first mapping relationships, so that the relationship during the removal period cannot be interrupted or disturbed by other operations, and the entire relationship removal process is completed as an indivisible whole, which can also ensure that there is no gap exposure during operation, guarantee the consistency and safety of the memory space, and eliminate the risk of race conditions and data inconsistency.

[0109] In the second way, the first mapping relationship of the virtual address interval managed by each first VMA can be removed one by one.

[0110] After removing the first mapping relationship, the physical memory region recorded in the first mapping relationship is not limited by the mapping relationship, so removing the first mapping relationship releases the physical memory region recorded in the first mapping relationship.

[0111] In an embodiment of the present application, in the case that the mapping type recorded in the first VMA is a file mapping type, in addition to removing the first mapping relationship from the page table, the association relationship between the file mapped by the first VMA and the first VMA also needs to be removed.

[0112] For example, the operating system can call the callback function of file unmapping to remove the association relationship between the file mapped by the first VMA and the first VMA.

[0113] The scheme provided by the embodiment of the present application can remove the mapping relationship and the association relationship of the VMA under the file mapping type, and perform subsequent steps to complete the processing of the forced memory mapping request. It can be seen that the memory management scheme provided by the embodiment of the present application can manage the virtual address interval under various mapping types including the file mapping type, and the scope of application of the scheme is larger.

[0114] After completing all the operations of removing the mapping relationship, releasing the physical memory and the like related to the first VMA, the operating system kernel can release the virtual address interval of all the first VMAs to the memory allocation subsystem of the operating system kernel, and update the relevant memory statistical information, so as to facilitate the subsequent management and allocation of the idle memory.

[0115] Step S205: If the second VMA is the VMA corresponding to the overlapping interval, a second mapping relationship between the VMA corresponding to the overlapping interval and the new physical memory region indicated by the forced memory mapping request is recorded in the page table.

[0116] Specifically, the forced memory mapping request is parsed to obtain the new physical memory region indicated by the forced memory mapping request, so that after the first mapping relationship corresponding to the overlapping interval is removed from the page table, the second mapping relationship between the VMA corresponding to the overlapping interval and the new physical memory region can be recorded in the page table again.

[0117] Step S206: If the second VMA is a placeholder VMA, the placeholder VMA is replaced by the VMA corresponding to the overlapping interval, and the second mapping relationship is recorded in the page table.

[0118] In the case that the second VMA is a placeholder VMA, after the mapping relationship is removed from the page table, the VMA managing the overlapping interval is still the placeholder VMA, so the VMA corresponding to the overlapping interval can be created, the placeholder VMA is replaced by the VMA corresponding to the overlapping interval, and the second mapping relationship is recorded in the page table.

[0119] Step S207: The target virtual address interval is unlocked.

[0120] From the above, when the memory is managed by the scheme provided in the embodiments of the present application, after receiving the forced memory mapping request, the first VMA managing the overlapping interval is determined, the interval managed by the first VMA belongs to the target virtual address interval targeted by the forced memory mapping request, and the overlapping interval actually has an established mapping relationship. When the mapping relationship of the overlapping interval in the target virtual address interval is re-established based on the forced memory mapping request, the first VMA is replaced with the placeholder VMA or the VMA for managing the overlapping interval created according to the mapping parameters in the request, and then the first mapping relationship of the overlapping interval is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0121] Compared with deleting the first VMA and removing the first mapping relationship first, and then establishing a new VMA and recording the second mapping relationship, this way has no VMA management for the overlapping interval during the period of deleting the first VMA and establishing the new VMA, and the gap exposure may occur. However, in this scheme, the first VMA is replaced with the second VMA before the mapping relationship is removed. In the case that the second VMA is a placeholder VMA, it will be replaced with the VMA corresponding to the overlapping interval again subsequently. The whole process can ensure that the overlapping interval is always managed by the VMA, and in the case that the second VMA is the VMA corresponding to the overlapping interval, it can also ensure that the overlapping interval is always managed by the VMA. Therefore, by using the memory management scheme provided in the embodiments of the present application, the gap exposure can be avoided during the whole request processing process, and the mmap() interface compatibility and performance will not be affected, so that the security vulnerability of the operating system can be avoided, and the security, reliability and robustness of the memory management of the operating system are improved. In particular, the security and robustness of the operating system kernel in the high-security and high-concurrency scenarios are effectively improved, and the popularization of cloud computing, big data and high-security systems is promoted.

[0122] In addition, since the first VMA is directly replaced with the second VMA after it is determined, in the whole memory management process, the external process or external visitor can either know that the overlapping interval is managed by the first VMA in the application program by traversal, or know that the overlapping interval is managed by the second VMA by traversal, and the situation of no VMA management for the overlapping interval by traversal will never occur. It can be seen that from the perspective of the external process or external visitor, it is also explained that the gap exposure of the operating system can be avoided by using the present scheme.

[0123] The first VMA can be determined in the following embodiments.

[0124] In one embodiment of this application, when determining the first VMA, candidate VMAs whose managed virtual address ranges overlap with the target virtual address range can be identified among the currently valid VMAs. If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, a third VMA is segmented from the candidate VMA and used as the first VMA. If the entire virtual address range managed by the candidate VMA overlaps with the target virtual address range, the candidate VMA is determined as the first VMA.

[0125] The third VMA manages the aforementioned intervals.

[0126] Specifically, within the virtual address range managed by the currently valid VMA, an overlapping range that overlaps with the target virtual address range can be identified. Among the currently valid VMAs, those VMAs whose managed virtual address ranges contain the overlapping range can be identified as candidate VMAs.

[0127] by Figure 3 Taking the effective VMAs shown as examples, if the target virtual address range is 0x1000-0x7500, then among the virtual address ranges managed by effective VMA1, effective VMA2, effective VMA3, and effective VMA4, the overlapping ranges that overlap with the target virtual address range are 0x1000-0x2000, 0x2000-0x3000, and 0x7000-0x7500. Among them, 0x1000-0x2000 is the virtual address range managed by effective VMA2, 0x2000-0x3000 is the virtual address range managed by effective VMA3, and 0x7000-0x7500 is a part of the virtual address range 0x7000-0x8000 managed by effective VMA4. Therefore, effective VMA2, effective VMA3, and effective VMA4 can be identified as candidate VMAs.

[0128] After the candidate VMA is determined, if a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the third VMA is segmented from the candidate VMA and used as the first VMA.

[0129] When segmenting a VMA, a third VMA that manages the aforementioned partial interval and a fourth VMA that manages the aforementioned non-overlapping interval can be generated based on the aforementioned partial interval and the non-overlapping interval in the virtual address interval managed by the candidate VMA, and only the third VMA is used as the first VMA.

[0130] If the virtual address range managed by the candidate VMA overlaps with the overall target virtual address range, then the candidate VMA is directly adopted as the first VMA.

[0131] In the above example, the virtual address range managed by the effective VMA4 partially overlaps with the target virtual address range, the overlapped part is 0x7000-0x7500, and the non-overlapped part of the virtual address range managed by the effective VMA4 except the part is 0x7500-0x8000, thus, a third VMA managing 0x7000-0x7500 and a fourth VMA managing 0x7500-0x8000 can be generated, and the third VMA managing 0x7000-0x7500 is taken as the first VMA.

[0132] The virtual address ranges managed by the effective VMA2 and the effective VMA3 entirely overlap with the target virtual address range, thus, the effective VMA2 and the effective VMA3 can be directly determined as the first VMA.

[0133] As can be seen from the above, when the memory is managed by using the scheme provided in the embodiments of the present application, for the VMA whose managed range partially overlaps with the target virtual address range, the operating system can split the VMA to obtain a VMA managing the overlapped part, and then determine the split VMA as the first VMA, and for the VMA whose managed range entirely overlaps with the target virtual address range, the VMA is directly determined as the first VMA, thus, the first VMA can be accurately determined, and the memory management can be performed according to the first VMA, thus, the accuracy of the memory management can be improved.

[0134] In the case where the part of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, after the third VMA is split from the candidate VMA, the following manners mentioned in the embodiments can also be performed.

[0135] In one embodiment of the present application, after the third VMA is split from the candidate VMA, the mapping relationship between the above part and the mapped physical memory region can be split from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region in the page table.

[0136] Specifically, the candidate VMA can be split into a third VMA and a fourth VMA, the third VMA manages a part of the range of the candidate VMA that overlaps with the target virtual address range, and the fourth VMA manages a non-overlapping part of the range of the candidate VMA. After splitting the third VMA from the candidate VMA, the part of the range of the candidate VMA that overlaps with the target virtual address range can be mapped to a first physical memory region according to the mapping relationship recorded in the page table, and the non-overlapping part of the range of the candidate VMA can be mapped to a second physical memory region. Thus, the original set of mapping relationships can be split into two sets of mapping relationships, one set of mapping relationships between the part of the range of the candidate VMA that overlaps with the target virtual address range and the first physical memory region, and the other set of mapping relationships between the non-overlapping part of the range of the candidate VMA and the second physical memory region. The mapping relationship between the part of the range of the candidate VMA that overlaps with the target virtual address range and the first physical memory region is the mapping relationship between the split part of the range of the candidate VMA and the mapped physical memory region, and this mapping relationship is the first mapping relationship to be removed.

[0137] Referring to Figure 5a , Figure 5a Fig. 4 shows the mapping relationship between the virtual address range managed by the effective VMA 4 and the mapped physical memory region in the Figure 3 In the example shown in Figure 5a , the virtual address range 0x7000-0x8000 is mapped to the physical memory region 0x4000-0x5000. The operating system can split the mapping relationship into two sets of mapping relationships, as shown in Figure 5b , the first set of mapping relationships is the mapping relationship between the overlapping part of the range of the candidate VMA 0x7000-0x7500 and the physical memory region 0x4000-0x4500, and the second set of mapping relationships is the mapping relationship between the non-overlapping part of the range of the candidate VMA 0x7500-0x8000 and the physical memory region 0x4500-0x5000. The first set of mapping relationships is the mapping relationship between the split part of the range of the candidate VMA and the mapped physical memory region.

[0138] As can be seen from the above, when managing memory using the scheme provided in the embodiments of the present application, after splitting the third VMA from the candidate VMA, the mapping relationship between the part of the range of the candidate VMA that overlaps with the target virtual address range and the mapped physical memory region is split from the mapping relationship between the range of the candidate VMA and the mapped physical memory region in the page table. Thus, the first mapping relationship between the overlapping part of the range of the candidate VMA and the mapped physical memory region can be accurately determined in the page table, and the first mapping relationship can be removed, and subsequent processing can be performed. Thus, the memory can be accurately managed, and the security of the operating system can be improved.

[0139] In the memory management process, the virtual address range managed by all valid VMAs can not completely cover the target virtual address range. In the example of the above Figure 3 If the target virtual address range is 0x1000-0x7500, the range covered by the virtual address range managed by all valid VMAs is 0x1000-0x3000 and 0x7000-0x7500, and the other range 0x3000-0x7000 in the target virtual address range is not allocated a VMA for management, and the page table does not have a mapping relationship for the range 0x3000-0x7000.

[0140] Therefore, for the range covered in the target virtual address range, that is, the overlapping range, the above steps S202-S204 can be used for processing. For the remaining range in the target virtual address range except the overlapping range, a VMA for managing the remaining range can be directly created according to the mapping parameter carried in the forced memory mapping request. Moreover, since the mapping relationship of the remaining range is not recorded in the page table, the mapping relationship of the overlapping range is removed by performing the above step S204, and therefore, after the above step S204 is performed, the mapping relationship of the entire target virtual address range is not recorded in the page table, so that when the second mapping relationship is recorded in step S205 or step S206, the mapping relationship between the entire target virtual address range and the new physical memory region can be directly recorded in the page table.

[0141] In the example of the above Figure 3 The overlapping range is 0x1000-0x2000, 0x2000-0x3000, and 0x7000-0x7500, the page table originally records the mapping relationship of the three ranges and does not record the mapping relationship of 0x3000-0x7000, and after the mapping relationship of the above three ranges is removed in the above step S204, the page table does not record the mapping relationship of the entire target virtual address space 0x1000-0x7500, so that when the second mapping relationship is recorded subsequently, the mapping relationship of 0x1000-0x7500 can be directly recorded in the page table.

[0142] In addition, in the case that the maple tree tree structure is used to manage the virtual address interval of each process, after the VMA replacement and creation, the whole target virtual address interval is actually managed by VMAs, and the partial intervals in the target virtual address interval are managed by multiple VMAs. Thus, after the VMA replacement and creation, the maple tree tree structure can integrate the nodes corresponding to the VMAs managing the partial intervals in the target virtual address interval into the node corresponding to the target virtual address interval according to the virtual address intervals managed by the valid VMAs. Meanwhile, the mapping relationship corresponding to the target virtual address interval is recorded in the page table.

[0143] In one embodiment of the present application, referring to Figure 6 , Figure 6 The flowchart of the second memory management method provided by the embodiment of the present application is shown in FIG. 6. In the embodiment of the present application, the method includes the following steps S601-S611.

[0144] S601: receiving a forced memory mapping request for a target virtual address interval;

[0145] S602: analyzing the forced memory mapping request to obtain the target virtual address interval;

[0146] S603: locking the target virtual address interval;

[0147] S604: determining a first VMA managing an overlapping interval;

[0148] S605: replacing the determined first VMA with a second VMA;

[0149] S606: detecting whether the replacement is successful. If the replacement is successful, S608 is executed; if the replacement fails, S607 is executed;

[0150] S607: returning an error message and ending;

[0151] For example, an error message indicating that the request response fails, the VMA replacement fails, etc. can be returned.

[0152] S608: removing the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table;

[0153] S609: if the second VMA is the VMA corresponding to the overlapping interval, recording a second mapping relationship between the VMA corresponding to the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table; if the second VMA is a placeholder VMA, replacing the placeholder VMA with the VMA corresponding to the overlapping interval, and recording the second mapping relationship in the page table;

[0154] Step S610: unlocking the target virtual address interval;

[0155] Step S611: returning the mapping result, and ending.

[0156] Corresponding to the memory management method, an embodiment of the present application further provides a memory management device.

[0157] In an embodiment of the present application, referring to Figure 7 , a memory management device is provided, which comprises:

[0158] A request receiving module 701 is configured to receive a forced memory mapping request for a target virtual address interval, and lock the target virtual address interval.

[0159] A VMA determining module 702 is configured to determine a first VMA for managing an overlapping interval, wherein the overlapping interval is an interval overlapping between a virtual address interval managed by a currently effective VMA and the target virtual address interval.

[0160] A VMA replacing module 703 is configured to replace the determined first VMA with a second VMA, wherein the second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is a VMA for managing the overlapping interval, which is created according to mapping parameters carried by the forced memory mapping request.

[0161] A relationship releasing module 704 is configured to release a first mapping relationship between the overlapping interval and a mapped physical memory region from a page table.

[0162] A first recording module 705 is configured to, in a case where the second VMA is the VMA corresponding to the overlapping interval, record a second mapping relationship between the VMA corresponding to the overlapping interval and a new physical memory region indicated by the forced memory mapping request in the page table.

[0163] A second recording module 706 is configured to, in a case where the second VMA is the placeholder VMA, replace the placeholder VMA with the VMA corresponding to the overlapping interval, and record the second mapping relationship in the page table.

[0164] An interval unlocking module 707 is configured to unlock the target virtual address interval.

[0165] As can be seen from the above, when the memory is managed by the scheme provided in the embodiments of the present application, after receiving the forced memory mapping request, the first VMA managing the overlapping interval is determined, the interval managed by the first VMA belongs to the target virtual address interval targeted by the forced memory mapping request, and the overlapping interval actually has an established mapping relationship. When the mapping relationship of the overlapping interval in the target virtual address interval is re-established based on the forced memory mapping request, the first VMA is replaced by the placeholder VMA or the VMA for managing the overlapping interval created according to the mapping parameters in the request, and then the first mapping relationship of the overlapping interval is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0166] Compared with deleting the first VMA and removing the first mapping relationship first, and then establishing a new VMA and recording the second mapping relationship, this way has no VMA management for the overlapping interval during the period of deleting the first VMA and establishing the new VMA, and the gap exposure may occur. However, in the present scheme, the first VMA is replaced by the second VMA before the mapping relationship is removed. In the case that the second VMA is a placeholder VMA, it will be replaced by the VMA corresponding to the overlapping interval again subsequently. The whole process can ensure that the overlapping interval is always managed by the VMA. In the case that the second VMA is the VMA corresponding to the overlapping interval, it can also ensure that the overlapping interval is always managed by the VMA. Therefore, by using the memory management scheme provided in the embodiments of the present application, the gap exposure can be avoided during the whole request processing process, and the mmap() interface compatibility and performance will not be affected, so that the security vulnerability of the operating system can be avoided, and the security, reliability and robustness of the memory management of the operating system are improved. In particular, the security and robustness of the operating system kernel in the high-security and high-concurrency scenarios are effectively improved, and the popularization of cloud computing, big data and high-security systems is promoted.

[0167] In addition, since the first VMA is directly replaced by the second VMA after being determined in the present scheme, in the whole memory management process, the external process or external visitor can either know that the overlapping interval is managed by the first VMA in the application program by traversal, or know that the overlapping interval is managed by the second VMA by traversal, and the situation of no VMA management for the overlapping interval by traversal will never occur. It can be seen that from the perspective of the external process or external visitor, it is also explained that the present scheme can avoid the gap exposure of the operating system.

[0168] In an embodiment of the present application, the VMA determining module 702 is specifically configured to:

[0169] In the currently valid VMA, a candidate VMA is determined, which manages the virtual address interval and has an overlapping interval with the target virtual address interval;

[0170] if a part of the virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, splitting a third VMA from the candidate VMA, and taking the third VMA as the first VMA, wherein the third VMA manages the part of the interval;

[0171] if the virtual address interval managed by the candidate VMA entirely overlaps with the target virtual address interval, determining the candidate VMA as the first VMA.

[0172] As can be seen from the above, when the memory is managed by using the scheme provided in the embodiments of the present application, for the VMA whose managed interval partially overlaps with the target virtual address interval, the operating system can split a VMA managing the overlapping part of the interval from the VMA, and then determine the split VMA as the first VMA, and for the VMA whose managed interval entirely overlaps with the target virtual address interval, directly determine the VMA as the first VMA, which can accurately determine the first VMA, and thus can improve the accuracy of memory management.

[0173] In an embodiment of the present application, the apparatus further comprises:

[0174] a relationship splitting module, configured to, after the third VMA is split from the candidate VMA, split, in the page table, a mapping relationship between the part of the interval and the mapped physical memory region from a mapping relationship between the virtual address interval managed by the candidate VMA and the mapped physical memory region.

[0175] As can be seen from the above, when the memory is managed by using the scheme provided in the embodiments of the present application, after the third VMA is split from the candidate VMA, the mapping relationship between the part of the interval and the mapped physical memory region is split from the mapping relationship between the virtual address interval managed by the candidate VMA and the mapped physical memory region in the page table, which can accurately determine the first mapping relationship between the overlapping interval and the mapped physical memory region in the page table, and then remove the first mapping relationship and perform subsequent processing, thereby accurately performing memory management and improving the security of the operating system.

[0176] In an embodiment of the present application, the relationship removing module 704 is specifically configured to:

[0177] migrate the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table to a to-be-cleaned list;

[0178] perform a page table entry cleaning operation on the first mapping relationship recorded in the to-be-cleaned list in units of the to-be-cleaned list.

[0179] In the scheme, all the first mapping relationships are first migrated to the to-be-cleaned list, so that the page table entry cleaning operation is performed on the to-be-cleaned list, all the first mapping relationships are released at one time, the atomic operation for all the first mapping relationships is realized, and thus the relationship during the release period cannot be interrupted or interfered by other operations, the entire release relationship process is determined as an indivisible whole to be completed, and thus the gap exposure during the operation can be avoided, the consistency and safety of the memory space are ensured, and the risk of race condition and data inconsistency is eliminated.

[0180] In an embodiment of the present application, the device further comprises:

[0181] The relationship removal module is configured to, after the determined first VMA is replaced by the second VMA, remove the association relationship between the file mapped by the first VMA and the first VMA in the case that the mapping type recorded in the first VMA is a file mapping type.

[0182] The scheme provided in the embodiments of the present application can release the mapping relationship and the association relationship of the VMA under the file mapping type, and perform the subsequent steps to complete the processing of the forced memory mapping request. It can be seen that the memory management scheme provided in the embodiments of the present application can manage the virtual address interval under various mapping types including the file mapping type, and the scheme has a large applicable range.

[0183] The embodiments of the present application further provide an electronic device, such as Figure 8 As shown in the figure, the electronic device comprises a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802 and the memory 803 complete mutual communication through the communication bus 804.

[0184] The memory 803 is configured to store a computer program.

[0185] The processor 801 is configured to execute the program stored in the memory 803, and implement the steps of any of the memory management methods.

[0186] The communication bus mentioned in the above electronic device can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0187] The communication interface is configured to communicate between the above electronic device and other devices.

[0188] The memory can include a Random Access Memory (RAM) and can also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory can also be at least one storage device located remotely from the aforementioned processor.

[0189] The processor mentioned above can be a general processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0190] In yet another embodiment provided by the present application, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any of the memory management methods mentioned above.

[0191] In yet another embodiment provided by the present application, a computer program product containing instructions, which, when run on a computer, causes the computer to execute any of the memory management methods in the above embodiments.

[0192] In the embodiments described above, all or some of the steps can be implemented by software, hardware or firmware, or any combination thereof. When implemented by software, all or some of the steps can be implemented in the form of one or more computer programs. The computer program can be stored in any computer readable medium, and when loaded into a computer system, can cause the computer system to perform one or more of the steps of the computer program. The computer readable medium can be a magnetic disk, an optical disk, a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a portable computer disk, a hard disk, an optical fiber, and / or a carrier wave using a transitory signal, and the like. The computer readable medium can be distributed among computer systems that act in a cloud of one or more computers connected by a communication network. The computer readable medium can be accessible from another computer system over the communication network.

[0193] It should be noted that, in the description, relational terms such as first and second, and the like, are used solely to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual relationship or order between such entities or actions. Moreover, the terms "comprises", "comprising", or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. In other words, the terms "comprises", "comprising", or any other variations thereof, merely specify the presence of the defined elements, but do not preclude the presence or addition of one or more other elements.

[0194] Each of the embodiments in the present specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the device, electronic device, computer readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.

[0195] The above merely describes the preferred embodiments of the present application, but is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A memory management method characterized by comprising: The method comprises: receiving a forced memory mapping request for a target virtual address interval, and locking the target virtual address interval; determining a first VMA that manages an overlapping interval, wherein the overlapping interval is an interval overlapping between a virtual address interval managed by a currently effective VMA and the target virtual address interval; replacing the determined first VMA with a second VMA, wherein the second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is a VMA created according to mapping parameters carried by the forced memory mapping request and used for managing the overlapping interval; removing, from a page table, a first mapping relationship between the overlapping interval and a mapped physical memory region; if the second VMA is the VMA corresponding to the overlapping interval, recording, in the page table, a second mapping relationship between the VMA corresponding to the overlapping interval and a new physical memory region indicated by the forced memory mapping request; if the second VMA is the placeholder VMA, replacing the placeholder VMA with the VMA corresponding to the overlapping interval, and recording the second mapping relationship in the page table; unlocking the target virtual address interval.

2. The method of claim 1, wherein, The determining of the first VMA that manages the overlapping interval comprises: in the currently effective VMA, determining a candidate VMA that has a managed virtual address interval overlapping with the target virtual address interval; if part of the virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, splitting a third VMA from the candidate VMA, and taking the third VMA as the first VMA, wherein the third VMA manages the part of the virtual address interval; if the entire virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, determining the candidate VMA as the first VMA.

3. The method of claim 2, wherein, After the splitting of the third VMA from the candidate VMA, the method further comprises: in the page table, splitting, from a mapping relationship between the virtual address interval managed by the candidate VMA and a mapped physical memory region, a mapping relationship between the part of the virtual address interval and the mapped physical memory region.

4. The method according to any one of claims 1 to 3, characterized in that, The removing of the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table comprises: migrating the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table to a to-be-cleaned list; and performing, in units of the to-be-cleaned list, a page table entry cleaning operation on the first mapping relationship recorded in the to-be-cleaned list.

5. The method according to any one of claims 1-3, characterized in that, After the replacement of the determined first VMA with the second VMA, the method further comprises: in a case where a mapping type recorded in the first VMA is a file mapping type, removing an association relationship between a file mapped by the first VMA and the first VMA.

6. A memory management device, characterized by The apparatus comprises: a request receiving module configured to receive a forced memory mapping request for a target virtual address interval, and lock the target virtual address interval; a VMA determination module, configured to determine a first VMA that manages an overlapping interval, wherein the overlapping interval is an interval that overlaps between a virtual address interval managed by a currently valid VMA and the target virtual address interval; a VMA replacement module, configured to replace the determined first VMA with a second VMA, wherein the second VMA is a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is a VMA created according to mapping parameters carried by the forced memory mapping request and used to manage the overlapping interval; a relationship removal module, configured to remove, from a page table, a first mapping relationship between the overlapping interval and a mapped physical memory region; a first recording module, configured to, in a case where the second VMA is the VMA corresponding to the overlapping interval, record, in the page table, a second mapping relationship between the VMA corresponding to the overlapping interval and a new physical memory region indicated by the forced memory mapping request; a second recording module, configured to, in a case where the second VMA is the placeholder VMA, replace the placeholder VMA with the VMA corresponding to the overlapping interval, and record the second mapping relationship in the page table; an interval unlocking module, configured to unlock the target virtual address interval.

7. The apparatus of claim 6, wherein, The VMA determination module is specifically configured to: determine, in the currently valid VMA, a candidate VMA that has a virtual address interval overlapping with the target virtual address interval; if a part of the virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, split a third VMA from the candidate VMA, and use the third VMA as the first VMA, wherein the third VMA manages the part of the virtual address interval; if the entire virtual address interval managed by the candidate VMA overlaps with the target virtual address interval, determine the candidate VMA as the first VMA.

8. The apparatus of claim 7, wherein, The apparatus further includes: a relationship splitting module, configured to, after the third VMA is split from the candidate VMA, split, in the page table, a mapping relationship between the part of the virtual address interval and the mapped physical memory region from a mapping relationship between the virtual address interval managed by the candidate VMA and the mapped physical memory region.

9. The apparatus of any one of claims 6-8, wherein, The relationship removal module is specifically configured to: migrate the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table to a to-be-cleaned list; and perform, in units of the to-be-cleaned list, a page table entry cleaning operation on the first mapping relationship recorded in the to-be-cleaned list.

10. The apparatus of any one of claims 6-8, wherein, The apparatus further includes: a relationship removal module, configured to, after the first VMA is replaced with the second VMA, remove, in a case where a mapping type recorded in the first VMA is a file mapping type, an association relationship between a file mapped by the first VMA and the first VMA.

11. An electronic device, comprising: The apparatus includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory perform communication with each other through the communication bus; the memory is used to store a computer program. A processor for implementing the method steps of any one of claims 1-5 when the processor executes a program stored on a memory.

12. A computer-readable storage medium, characterized in that, A computer program stored in the computer readable storage medium, the computer program being executed by a processor to implement the method steps of any one of claims 1-5.

Citation Information

Patent Citations

  • Security isolation method for edge computing nodes of Internet of Things

    CN120378184A

  • Hot upgrade method of virtual machine monitor (VMM), computer equipment, computer readable medium and program product

    CN120780409A

  • Core dump file generation method and device, electronic equipment and medium

    CN121029394A

  • Memory Deduplication Support for Remote Direct Memory Access (RDMA)

    US20160350261A1

  • Agentless Personal Network Firewall in Virtualized Datacenters

    US20200057666A1