Memory error detection method and device for operating system, equipment and storage medium

By determining the error type of the target cache name and kernel object in the Linux operating system, creating a memory pool and allocating memory for detection, the accuracy and efficiency of memory error detection in the operating system is solved, and the security and stability of the system are improved.

CN119938378APending Publication Date: 2025-05-06BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411983059.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

In complex operating environments, Linux operating systems may encounter errors such as memory access out of bounds and use of released memory, resulting in system crashes, data corruption or malicious attacks, seriously threatening the security and stability of the system.

Method used

Provides a memory error detection method for operating systems, by determining the target cache name to be monitored and the error type of the target kernel object, creating a memory pool of corresponding size, and allocating memory from it for error detection.

Benefits of technology

It realizes dynamically turning on memory error detection in a production environment, accurately overwrites the target cache name, improves the accuracy and efficiency of memory error detection, and saves memory resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938378A_ABST
    Figure CN119938378A_ABST
Patent Text Reader

Abstract

The invention provides a memory error detection method and device for an operating system, equipment and a storage medium, and relates to the technical field of computers, in particular to the technical field of operating systems. The method comprises the following steps: determining a target cache name to be monitored, and a target error type and a target object number of a target kernel object; wherein the target kernel object is associated with the target cache name; determining a target size according to the target error type and the number of the target objects, and creating a memory pool of the target size; and allocating a memory for the target kernel object from the memory pool according to the target error type, and performing error detection on the allocated memory.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, in particular to the field of operating system technology, and specifically to a memory error detection method, device, equipment and storage medium for an operating system. Background Art

[0002] In a complex operating environment, the Linux operating system kernel may encounter memory access out of bounds, use of freed memory (also known as dangling pointer reference), and other memory management errors. If these errors are not discovered and repaired in a timely manner, they may cause system crashes, data corruption, or even be exploited by malicious attackers to execute arbitrary code, thus seriously threatening the security and stability of the system. Therefore, it is particularly important to detect memory errors in the Linux operating system. Summary of the invention

[0003] The present disclosure provides a memory error detection method, apparatus, device and storage medium for an operating system.

[0004] According to one aspect of the present disclosure, a memory error detection method for an operating system is provided, comprising:

[0005] Determine a target cache name to be monitored, and a target error type and a target object quantity of a target kernel object; wherein the target kernel object is associated with the target cache name;

[0006] Determine a target size according to the target error type and the target object quantity, and create a memory pool of the target size;

[0007] According to the target error type, memory is allocated from the memory pool for the target kernel object, and error detection is performed on the allocated memory.

[0008] According to one aspect of the present disclosure, a memory error detection device for an operating system is provided, comprising:

[0009] A target determination module, used to determine a target cache name to be monitored, a target error type of a target kernel object, and a target object quantity; wherein the target kernel object is associated with the target cache name;

[0010] A memory pool creation module, used to determine a target size according to the target error type and the target object quantity, and create a memory pool of the target size;

[0011] The error detection module is used to allocate memory for the target kernel object from the memory pool according to the target error type, and perform error detection on the allocated memory.

[0012] According to another aspect of the present disclosure, there is provided an electronic device, the electronic device comprising:

[0013] at least one processor; and

[0014] a memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method provided by any embodiment of the present disclosure.

[0016] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to execute the method provided by any embodiment of the present disclosure.

[0017] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein when the computer program is executed by a processor, the method provided according to any embodiment of the present disclosure is implemented.

[0018] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flow chart of a memory error detection method for an operating system provided according to an embodiment of the present disclosure;

[0020] Figure 2 is a flowchart of another memory error detection method for an operating system provided according to an embodiment of the present disclosure;

[0021] Figure 3a is a flowchart of another memory error detection method for an operating system provided according to an embodiment of the present disclosure;

[0022] Figure 3b It is a schematic diagram of a memory allocation format for out-of-bounds access within a page provided according to an embodiment of the present disclosure;

[0023] Figure 3c It is a schematic diagram of a memory allocation format for cross-page out-of-bounds access provided according to an embodiment of the present disclosure;

[0024] Figure 3d is a schematic diagram of a memory allocation format for using released memory provided according to an embodiment of the present disclosure;

[0025] Figure 4It is a structural schematic diagram of a memory error detection device for an operating system provided according to an embodiment of the present disclosure;

[0026] Figure 5 The invention is a block diagram of an electronic device for implementing the memory error detection method of the operating system according to the embodiment of the present disclosure. DETAILED DESCRIPTION

[0027] Regarding kernel memory error detection methods, the relevant technologies mainly include Kernel Address Sanitizer (KASAN) and SLUB DEBUG. Among them, KASAN relies on compiler instrumentation to detect problems such as out-of-bounds access to memory allocated by global variables, stacks, and heaps, and the use of released memory. KASAN uses an extra 1 / 8 of memory to mark the status of available memory. This extra memory is called shadow memory. By using a specific magic number to fill the shadow memory, each time a memory load or store operation is performed, the corresponding shadow memory is checked to determine whether the memory operation of the system kernel is valid. SLUB DEBUG mainly detects problems such as out-of-bounds access to memory allocated from SLUB and the use of released memory. SLUB (Slab Allocator for Uncached objects) is a memory allocator in the Linux kernel, which is mainly used to allocate small blocks of memory. SLUB DEBUG modifies the format of the object managed by the SLUB allocator and fills specific magic numbers at the beginning and end of the object. During each memory allocation (alloc) and release (free) operation, SLUB DEBUG checks whether these magic numbers have been accidentally modified to detect whether there are any abnormal problems with the corresponding memory.

[0028] However, despite its powerful functions, KASAN brings a large performance overhead, so it is not suitable for use in actual online environments. SLUB DEBUG requires passing parameters through the boot command line (boot cmdline) when the system starts and restarting the system to enable it, which also makes it unsuitable for online environments; moreover, SLUB DEBUG also comes with a large overhead cost, which will have a significant impact on system performance.

[0029] Figure 1The present invention is a flowchart of a memory error detection method for an operating system provided according to an embodiment of the present invention. The method is applicable to the detection of kernel memory errors. The method can be executed by a memory error detection device for an operating system, which can be implemented in software and / or hardware and can be integrated into an electronic device. Figure 1 As shown, the memory error detection method of the operating system of this embodiment may include:

[0030] S101, determining a target cache name to be monitored, and a target error type and a target object quantity of a target kernel object; wherein the target kernel object is associated with the target cache name;

[0031] S102, determining a target size according to the target error type and the target object quantity, and creating a memory pool of the target size;

[0032] S103, allocating memory for the target kernel object from the memory pool according to the target error type, and performing error detection on the allocated memory.

[0033] In the memory management of the Linux kernel, the Slab allocator optimizes memory allocation and release by managing memory blocks of specific sizes (i.e., Slabs). The Slab allocator is used to divide the memory into multiple fixed-size blocks, each of which can accommodate a kernel object. The cache name refers to the name of the kmem_cache (kernel memory cache) used in the Slab allocator to describe and manage memory blocks of specific sizes. It can be named based on the size of the kernel object, such as "kmalloc-32", "kmalloc-64", etc., indicating that the size of the kernel object in the cache is 32 bytes and 64 bytes. Therefore, each cache name can be associated with a fixed kernel object.

[0034] In the disclosed embodiment, according to the existing operating system log or memory error report, the Slab cache that may have errors can be determined, the name of the corresponding slab cache can be extracted and recorded as the target cache name to be monitored, and the error type that may exist can be extracted and recorded as the target error type. Exemplarily, the target cache name to be monitored is input in the memory monitoring tool, the Slab distributor information interface provided by the operating system is accessed, and each registered Slab cache is traversed from the Slab distributor information (slabinfo), and each Slab cache that successfully matches the target cache name is used as the target cache, and the monitoring of the target cache is dynamically enabled, for example, by hooking the relevant Slab distributor function, or by modifying the kernel configuration to enable the relevant debugging options, so as to realize the dynamic activation of the memory error detection of the target cache in the kernel (kernel) of the production environment. Among them, the target cache name can be more than one, and each target cache name has a corresponding target error type. The kernel object associated with the target cache name is used as the target kernel object, and the target object quantity of the target kernel object can also be obtained from the Slab distributor information. It should be noted that the memory monitoring tool keeps the other slab caches except the target cache in a disabled state.

[0035] By using the Slab cache that may have problems, such as "kmalloc-32", as the target cache name to be monitored, the memory error detection mechanism for the target cache is dynamically enabled in the production environment. This mechanism can accurately cover the target cache name without the need to perform unnecessary memory error detection on other cache names other than the target cache name, such as "kmalloc-64". In addition, for the target cache name, only the target error types related to it, such as out-of-bounds access, are detected, without involving other error types other than the target error type, such as use-after-free or abnormal memory release (invalid-free). Therefore, the above processing improves the coverage of the target cache and the target error type, and effectively avoids unnecessary over-detection of other caches or other error types, thereby improving the detection efficiency and accuracy of memory error detection.

[0036] For each target cache name, determine the required memory size according to its corresponding target error type and the number of target objects managed; summarize and sum the memory sizes required by various target cache names to obtain the total memory size required by the entire system, that is, the target size. Create a memory pool based on the target size as a memory allocation source for various target cache names. In response to a memory allocation request for any kernel object, determine whether the kernel object belongs to the target cache name and whether there is memory to be allocated in the memory pool; if the kernel object belongs to the target cache name, that is, the kernel object is the target kernel object to be monitored, and there is memory to be allocated in the memory pool, allocate the corresponding memory space from the memory pool; otherwise, allocate memory for the kernel object from other memories outside the memory pool. For example, if the memory pool is exhausted, the allocation path will return NULL (null value), indicating that the memory pool has been allocated. At this time, memory allocation is performed from other memories outside the memory pool.

[0037] After allocating memory space for the target kernel object from the memory pool, the target error type detection is also performed on this memory space to accurately determine whether the target kernel object has the target error type of concern, and obtain the memory detection result of the target kernel object. For example, in the case where the page0 data exception may have an out-of-bounds access, the out-of-bounds access detection on page0 determines that the cause of the exception is that object1 modifies the data of page0 across pages when accessing page1. By allocating memory on demand for the target kernel object from the memory pool in combination with the target error type, and detecting the allocated memory to determine whether the target kernel object has the corresponding target error type, the accuracy of memory error detection is effectively improved, and the consumption of memory resources is also saved.

[0038] The technical solution provided by the disclosed embodiment, by taking the Slab cache that may have problems as the target cache name to be monitored, dynamically enabling the memory error detection mechanism for the target cache in the production environment, can accurately cover the target cache name without unnecessary memory error detection for other cache names except the target cache name. In addition, by allocating memory on demand for the target kernel object from the memory pool in combination with the target error type, and detecting whether the target kernel object has the corresponding target error type, the accuracy of memory error detection is effectively improved, and the consumption of memory resources is also saved.

[0039] Figure 2 is a flowchart of another memory error detection method for an operating system provided according to an embodiment of the present disclosure. Figure 2 , further defined on the basis of the above embodiment, the memory error detection method of the operating system of this embodiment may include:

[0040] S201, after the operating system crashes due to a memory error and restarts, determine the target cache name where the exception occurs according to the crash log of the operating system, and obtain the target kernel object associated with the target cache name and the target object quantity of the target kernel object;

[0041] S202, determining a target error type of the target kernel object according to the crash log;

[0042] S203, determining a target size according to the target error type and the target object quantity, and creating a memory pool of the target size;

[0043] S204: Allocate memory for the target kernel object from the memory pool according to the target error type, and perform error detection on the allocated memory.

[0044] In the case where the operating system crashes due to a memory error, the operating system can be restarted, and after the restart, the native crash log of the operating system is parsed to obtain the target cache name where the exception occurred. Exemplarily, during the version upgrade process of the operating system due to the launch of new functions, if a memory error occurs, the operating system crashes and exits, the operating system is restarted, and after the restart, the cache name where the exception occurred is automatically extracted from the native crash log of the operating system as the target cache name. The kernel object associated with the target cache name is used as the target kernel object, and the target object number of the target kernel object is obtained.

[0045] In addition, the native error information of the target kernel object is extracted from the native crash log of the operating system, and the error code in the native error information is matched with each candidate error type of the memory to obtain the target error type that may exist in the target kernel object. Exemplarily, the target cache name, the number of target objects of the target kernel object, and the target error type can be input into the memory monitoring tool to dynamically enable the monitoring of the target error type of the target cache. By automatically determining the target cache name and the target error type that may exist in the target kernel object from the native crash log of the operating system, the troubleshooting efficiency of memory error detection can be significantly improved, human errors can be reduced, system problem repair can be accelerated, and system stability can be improved.

[0046] In addition, the memory monitoring tool can determine the target size according to the target error type of each target kernel object and the corresponding number of target objects, and create a memory pool based on the target size as a memory allocation source for various target cache names. In response to a memory allocation request for any kernel object, if the kernel object belongs to the target cache name and there is memory to be allocated in the memory pool, the corresponding memory space is allocated for it from the pre-created memory pool, and after the memory allocation is completed, the memory error detection is performed on this memory space to accurately determine whether the target kernel object has the target error type of concern; otherwise, memory is allocated to the kernel object from other memory outside the memory pool.

[0047] In an optional implementation, determining the target error type of the target kernel object based on the crash log includes: if the error information in the crash log is a data exception, determining that the error type of the target kernel object is an out-of-bounds access, and extracting an access address from the crash log; determining that the target error type is a cross-page out-of-bounds access or an intra-page out-of-bounds access based on the access address.

[0048] For any target kernel object, the error information of the target kernel object is extracted from the native crash log of the operating system. If the error information is a data exception, the error type of the target kernel object is determined to be an out-of-bounds access, and it is necessary to further distinguish whether it is a cross-page out-of-bounds access or an intra-page out-of-bounds access. Exemplarily, the access address of the target kernel object can be extracted from the native crash log. If the address exceeds the boundary of the current memory page, that is, the address space of the next or previous memory page is accessed, the target error type is a cross-page out-of-bounds access; if the address is still within the current memory page, but exceeds the allocated memory area, the target error type is an intra-page out-of-bounds access. By parsing the access address in the crash log and determining whether it exceeds the current memory page boundary or the allocated memory area range, it is possible to quickly and accurately distinguish between cross-page out-of-bounds access and intra-page out-of-bounds access, thereby speeding up problem location and repair, and improving system stability and reliability.

[0049] In an optional implementation, determining the target cache name to be monitored, as well as the target error type and target object number of the target kernel object, includes: if the error information in the crash log is a null pointer, determining that the target error type is the use of released memory; if the error information in the crash log is repeated release of the same memory block, release of an unallocated or released memory block, determining that the target error type is abnormal memory release.

[0050] For any target kernel object, if the error information of the target kernel object extracted from the native crash log is a null pointer (such as "NULL pointer dereference"), the program attempts to access a memory block that has been released, and the corresponding target error type is use after free; if the error information of the target kernel object indicates that the program attempts to repeatedly release the same memory block, release an unallocated or released memory block, illustratively, if the crash log contains error information such as "double free or corruption", "free(): invalid pointer", etc., the target error type is determined to be abnormal memory release. By parsing the native crash log of the operating system, the efficiency and accuracy of determining the target error type can be significantly improved.

[0051] The technical solution provided by the embodiment of the present disclosure can significantly improve the troubleshooting efficiency of memory error detection, accelerate system problem repair, and improve system stability by automatically determining the target cache name and the target error type that may exist in the target kernel object from the native crash log of the operating system, and performing detection based on the target cache name and the target error type that may exist in the target kernel object.

[0052] Figure 3a is a flowchart of another memory error detection method for an operating system provided according to an embodiment of the present disclosure. Figure 3a , further defined on the basis of the above embodiment, the memory error detection method of the operating system of this embodiment may include:

[0053] S301, determining a target cache name to be monitored, and a target error type and a target object quantity of a target kernel object; wherein the target kernel object is associated with the target cache name;

[0054] S302, determining a target size according to the target error type and the target object quantity, and creating a memory pool of the target size;

[0055] If the target error type is an intra-page out-of-bounds access, continue to execute S303; if the target error type is an inter-page out-of-bounds access, jump to execute S305;

[0056] S303, allocating a memory page from the memory pool to the target kernel object, dividing the allocated memory page into a data area and a protection area, and setting the protection area to an inaccessible state; and continuing to execute S304;

[0057] S304, in response to the access request to the protection area, generating an intra-page out-of-bounds access exception message and rejecting the access request;

[0058] S305, allocating a memory page from the memory pool to the target kernel object, dividing the allocated memory page into a data area and a protection area, and setting the protection area to an inaccessible state; and continuing to execute S306;

[0059] S306, in response to the access request to the protection area, generating an intra-page out-of-bounds access exception message and rejecting the access request.

[0060] Exemplarily, the target cache name to be monitored, the target error type and the target object number of the target kernel object are determined, and the target cache name, the target object number and the target error type of the target kernel object are input into the memory monitoring tool, and the target error type monitoring of the target cache is dynamically enabled. The memory monitoring tool determines the target size according to the target error type and the corresponding target object number of each target kernel object, and creates a memory pool based on the target size as a memory allocation source for various target cache names.

[0061] refer to Figure 3b In response to a memory allocation request of any target kernel object, if the target memory error type of the target kernel object is an intra-page out-of-bounds access, a memory page is allocated to the target kernel object from the memory pool, the memory page is divided into a data area 31 and a protection area 32, and the protection area 32 is set to an inaccessible state; in response to an access request to the protection area 32, an intra-page out-of-bounds access exception message is generated, and the access request is rejected. Reference Figure 3c , if the target error type of the target kernel object is cross-page out-of-bounds access, a data page 33 and a protection page 34 are allocated to the target kernel object from the memory pool, and the protection page 34 is set to an inaccessible state; in response to the access request to the protection page 34, a cross-page out-of-bounds access exception message is generated, and the access request is rejected. By allocating only one memory page and dividing the data area and the protection area for intra-page out-of-bounds access; for cross-page out-of-bounds access, two memory pages are allocated as data pages and protection pages respectively, which can not only accurately detect and protect cross-bounds access, avoid memory damage and data leakage, but also reduce memory usage, optimize resource utilization, and improve system stability and security.

[0062] In an optional implementation, according to the target error type, memory is allocated to the target kernel object from the memory pool, and error detection is performed on the allocated memory, including: if the target error type is the use of released memory, a memory page is allocated to the target kernel object from the memory pool; in response to a release operation on the allocated memory page, the allocated memory page is set to an inaccessible state; in response to an access request to the allocated memory page, a use of released memory exception message is generated, and the access request is rejected.

[0063] refer to Figure 3d In response to a memory allocation request of any target kernel object, if the target error type of the target kernel object is to use released memory, a memory page 35 is allocated to the target kernel object from the memory pool; in response to the release operation of the memory page 35, the corresponding memory page 35 is set to an inaccessible state; in response to an access request to a memory page 35 in an inaccessible state, a use of released memory exception message is generated, and the access request is rejected. By using released memory, only one memory page is allocated and set to an inaccessible state after release, ensuring that access to the memory will trigger an exception and be rejected, not only can the use of released memory be detected, but also the memory usage is reduced.

[0064] It should be noted that, in response to a memory allocation request for any target kernel object, if the target error type of the target kernel object is abnormal memory release, a memory page is allocated for the target kernel object from the memory pool; in response to the memory allocation and release operations of the memory page, the memory monitoring tool can record the state and related information of the target kernel object memory, and update the state of the corresponding memory page; in response to the memory allocation operation of the target kernel object, determine whether the target kernel object has been allocated a memory page; if so, generate a memory allocation exception; when the program attempts to access the released target memory object or performs an illegal release, the memory monitoring tool will detect these abnormal access behaviors.

[0065] The technical solution provided by the embodiment of the present disclosure can avoid unnecessary memory overhead by detecting the corresponding target error type for the target kernel object and allocating memory based on the target error type; moreover, the full amount of monitoring rather than sampling is adopted for the target kernel object, which also ensures the high accuracy of detection and improves the reliability of the monitoring results. In addition, the monitoring mechanism also supports a dynamic switch function, which can be flexibly enabled or disabled without affecting the normal operation of the online production environment, meeting the diverse needs in actual use.

[0066] In an optional implementation, the target error type includes cross-page cross-boundary access and other error types except cross-page cross-boundary access; the target number of objects includes a first number of objects corresponding to the cross-page cross-boundary access and a second number of objects corresponding to other error types; determining the target size based on the target error type and the target number of objects includes: determining a first size based on the first number of objects for the cross-page cross-boundary access and a page size; multiplying the second number of objects corresponding to the other error types by the page size to obtain a second size; and summing the first size and the second size to obtain the target size.

[0067] Among them, other error types except cross-page cross-boundary access include intra-page cross-boundary access, use-after-free and abnormal memory release (invaild-free). Exemplarily, the number of first objects associated with cross-page cross-boundary access is obtained, and the first size is determined by the following formula: (num_objects1+1)×2×page_size; wherein num_objects1 is the number of first objects and page_size is the page length; the number of second objects associated with other memory error types except cross-page cross-boundary access is obtained, and the second size is determined by the following formula: num_objects2×page_size; wherein num_objects2 is the number of second objects; the first size and the second size are summed up to obtain the target size. In the process of memory monitoring, by reserving only one memory page for a single kernel object for other memory error types except cross-page cross-boundary access, not only can the memory usage be effectively reduced, but also the resource utilization efficiency can be significantly improved.

[0068] Figure 4 1 is a schematic diagram of the structure of a memory error detection device for an operating system provided according to an embodiment of the present disclosure. The device is applicable to the detection of kernel memory errors. The device can be implemented in software and / or hardware and can be integrated into electronic devices. Figure 4 As shown, the memory error detection device 400 of the operating system of this embodiment may include:

[0069] A target determination module 410 is used to determine a target cache name to be monitored, a target error type of a target kernel object, and a target object quantity; wherein the target kernel object is associated with the target cache name;

[0070] A memory pool creation module 420, configured to determine a target size according to the target error type and the target object quantity, and create a memory pool of the target size;

[0071] The error detection module 430 is used to allocate memory for the target kernel object from the memory pool according to the target error type, and perform error detection on the allocated memory.

[0072] In an optional implementation, the target determination module 410 includes:

[0073] A cache object unit, used to determine the target cache name where the exception occurs according to the crash log of the operating system after the operating system crashes due to a memory error and restarts, and obtain the target kernel object associated with the target cache name and the target object quantity of the target kernel object;

[0074] The error type unit is used to determine the target error type of the target kernel object according to the crash log.

[0075] In an optional implementation manner, the error type unit is specifically used to:

[0076] If the error message in the crash log is data anomaly, determining the error type of the target kernel object is out-of-bounds access, and extracting the access address from the crash log;

[0077] The target error type is determined according to the access address as cross-page out-of-bounds access or intra-page out-of-bounds access.

[0078] In an optional implementation manner, the error type unit is specifically used to:

[0079] Determining the target cache name to be monitored, the target error type of the target kernel object, and the number of target objects includes:

[0080] If the error message in the crash log is a null pointer, determining that the target error type is use of released memory;

[0081] If the error information in the crash log is repeated release of the same memory block, release of an unallocated or released memory block, then the target error type is determined to be abnormal memory release.

[0082] In an optional implementation manner, the target error type includes cross-page out-of-bounds access and other error types except cross-page out-of-bounds access; the target object quantity includes a first object quantity corresponding to the cross-page out-of-bounds access and a second object quantity corresponding to other error types;

[0083] The memory pool creation module 420 includes:

[0084] A first size unit, used to determine a first size according to the number of first objects accessed across page boundaries and the page size;

[0085] A second size unit, used for multiplying the second number of objects corresponding to the other error type by the page size to obtain a second size;

[0086] A target size unit is used to sum the first size and the second size to obtain the target size.

[0087] In an optional implementation, the error detection module 430 includes an intra-page cross-border detection unit, and the intra-page cross-border detection unit is specifically used to:

[0088] If the target error type is an out-of-bounds access within a page, a memory page is allocated from the memory pool for the target kernel object, the allocated memory page is divided into a data area and a protection area, and the protection area is set to an inaccessible state;

[0089] In response to an access request to the protection area, an in-page out-of-bounds access exception message is generated, and the access request is rejected.

[0090] In an optional implementation, the error detection module 430 includes a cross-page boundary detection unit, and the cross-page boundary detection unit is specifically used to:

[0091] If the target error type is cross-page out-of-bounds access, a memory page and a protection page are allocated to the target kernel object from the memory pool, and the protection page is set to an inaccessible state;

[0092] In response to an access request to the protection page, a cross-page out-of-bounds access exception message is generated, and the access request is rejected.

[0093] In an optional implementation manner, the error detection module 430 includes a use-released detection unit, and the use-released detection unit is specifically used to:

[0094] If the target error type is using released memory, allocating a memory page for the target kernel object from the memory pool;

[0095] In response to a release operation on the allocated memory page, setting the allocated memory page to an inaccessible state;

[0096] In response to an access request to the allocated memory page, a use of freed memory exception message is generated and the access request is denied.

[0097] The memory error detection device for an operating system provided by an embodiment of the present invention can execute the memory error detection method for an operating system provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0098] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0099] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0100] Figure 5 The invention is a block diagram of an electronic device for implementing the memory error detection method of the operating system according to the embodiment of the present disclosure. Figure 5A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0101] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0102] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0103] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), an image processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as a memory error detection method for an operating system. For example, in some embodiments, the memory error detection method for an operating system may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the memory error detection method for the operating system described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the memory error detection method for the operating system in any other appropriate manner (e.g., by means of firmware).

[0104] Figure 5 A schematic block diagram of an example electronic device 500 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0105] like Figure 5 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0106] Multiple components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, such as a keyboard, a mouse, etc.; an output unit 507, such as various types of displays, speakers, etc.; a storage unit 508, such as a disk, an optical disk, etc.; and a communication unit 509, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0107] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), an image processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above, such as a memory error detection method for an operating system. For example, in some embodiments, the memory error detection method for an operating system may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the memory error detection method for the operating system described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the memory error detection method for the operating system in any other appropriate manner (e.g., by means of firmware).

[0108] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0109] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0110] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0111] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, audio input, or tactile input).

[0112] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web player through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0113] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0114] Artificial intelligence is a discipline that studies how to use computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, audio recognition technology, natural language processing technology, machine learning / deep learning technology, big data processing technology, knowledge graph technology, and other major directions.

[0115] Cloud computing refers to a technology system that uses network access to elastically scalable shared physical or virtual resource pools. Resources can include servers, operating systems, networks, software, applications, and storage devices, and can be deployed and managed on demand and in a self-service manner. Cloud computing technology can provide efficient and powerful data processing capabilities for technical applications such as artificial intelligence and blockchain, as well as model training.

[0116] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0117] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A memory error detection method for an operating system, comprising: Determine a target cache name to be monitored, and a target error type and a target object quantity of a target kernel object; wherein the target kernel object is associated with the target cache name; Determine a target size according to the target error type and the target object quantity, and create a memory pool of the target size; According to the target error type, memory is allocated from the memory pool for the target kernel object, and error detection is performed on the allocated memory.

2. The method according to claim 1, wherein: Determining the target cache name to be monitored, the target error type of the target kernel object, and the number of target objects includes: After the operating system crashes due to a memory error and restarts, determining the target cache name where the exception occurs according to the crash log of the operating system, and obtaining the target kernel object associated with the target cache name and the target object quantity of the target kernel object; A target error type of the target kernel object is determined according to the crash log.

3. The method according to claim 2, wherein: Determining the target error type of the target kernel object according to the crash log includes: If the error message in the crash log is data anomaly, determining the error type of the target kernel object is out-of-bounds access, and extracting the access address from the crash log; The target error type is determined according to the access address as cross-page out-of-bounds access or intra-page out-of-bounds access.

4. The method according to claim 2, wherein: Determining the target cache name to be monitored, the target error type of the target kernel object, and the number of target objects includes: If the error message in the crash log is a null pointer, determining that the target error type is use of released memory; If the error information in the crash log is repeated release of the same memory block, release of an unallocated or released memory block, then the target error type is determined to be abnormal memory release.

5. The method according to claim 1, wherein: The target error types include cross-page out-of-bounds access and other error types except cross-page out-of-bounds access; the target object quantity includes a first object quantity corresponding to cross-page out-of-bounds access and a second object quantity corresponding to other error types; The determining the target size according to the target error type and the target object quantity includes: Determine a first size according to the number of first objects accessed across page boundaries and the page size; Multiplying the second number of objects corresponding to the other error types by the page size to obtain a second size; The first size and the second size are summed to obtain the target size.

6. The method according to claim 1, wherein: The allocating memory for the target kernel object from the memory pool according to the target error type, and performing error detection on the allocated memory, comprises: If the target error type is an out-of-bounds access within a page, a memory page is allocated from the memory pool for the target kernel object, the allocated memory page is divided into a data area and a protection area, and the protection area is set to an inaccessible state; In response to an access request to the protection area, an in-page out-of-bounds access exception message is generated, and the access request is rejected.

7. The method according to claim 1, wherein: The allocating memory for the target kernel object from the memory pool according to the target error type, and performing error detection on the allocated memory, comprises: If the target error type is cross-page out-of-bounds access, a memory page and a protection page are allocated to the target kernel object from the memory pool, and the protection page is set to an inaccessible state; In response to an access request to the protection page, a cross-page out-of-bounds access exception message is generated, and the access request is rejected.

8. The method according to claim 1, wherein: The allocating memory for the target kernel object from the memory pool according to the target error type, and performing error detection on the allocated memory, comprises: If the target error type is using released memory, allocating a memory page for the target kernel object from the memory pool; In response to a release operation on the allocated memory page, setting the allocated memory page to an inaccessible state; In response to an access request to the allocated memory page, a use of freed memory exception message is generated and the access request is denied.

9. A memory error detection device for an operating system, comprising: A target determination module, used to determine a target cache name to be monitored, a target error type of a target kernel object, and a target object quantity; wherein the target kernel object is associated with the target cache name; A memory pool creation module, used to determine a target size according to the target error type and the target object quantity, and create a memory pool of the target size; The error detection module is used to allocate memory for the target kernel object from the memory pool according to the target error type, and perform error detection on the allocated memory.

10. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.

11. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to make a computer execute the method according to any one of claims 1-8.

12. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 8.

Citation Information

Cited By

  • Memory management method and computer equipment

    CN120704882A

  • Memory object management method, device and equipment and readable storage medium

    CN122132326A