Memory trampling detection method, electronic equipment and storage medium

By detecting the memory management linked list at preset time intervals in UEFI firmware, the problem of difficulty in detecting memory pedaling in the prior art is solved, and fast and accurate memory pedaling detection is achieved.

CN119415302APending Publication Date: 2025-02-11SHENZHEN JAGUAR MICROSYSTEMS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411547039.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The prior art is difficult to quickly and accurately detect memory pedaling problems occurring in UEFI firmware, especially in complex driver code environments.

Method used

By detecting the memory management linked list every preset time interval, we judge whether the linked list subunit meets the preset conditions, and determine that the currently executed driver is the driver that has memory trampled.

Benefits of technology

It realizes the rapid and accurate detection of memory stamped drivers, reducing detection time and energy, and improving detection efficiency in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415302A_ABST
    Figure CN119415302A_ABST
Patent Text Reader

Abstract

The invention discloses a memory trampling detection method, electronic equipment and a storage medium, and the memory trampling detection method comprises the following steps: when executing each drive program according to a loading sequence, detecting a memory management linked list at preset time intervals; judging whether all linked list subunits in the memory management linked list meet preset conditions or not; when it is detected that the linked list subunits which do not meet the preset condition exist in the memory management linked list, it is determined that the currently-executed driving program is the driving program with memory trampling. According to the method, the memory management linked list is detected every preset time interval, and when it is detected that the linked list subunits which do not meet the preset conditions exist in the memory management linked list, it is determined that the currently executed driving program is the driving program where the memory trampling occurs, so that the driving program where the memory trampling occurs can be rapidly and accurately detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a memory stepping detection method, electronic equipment and storage medium. Background Art

[0002] In modern computer systems, UEFI (Unified Extensible Firmware Interface) firmware is responsible for initializing hardware and loading the operating system. During operation, UEFI firmware needs to frequently allocate and release memory. However, due to the complexity of driver code and potential programming errors, memory trampling (i.e., memory data corruption caused by illegal memory access) problems often occur. When memory trampling problems occur, it is necessary to quickly and accurately detect the program that caused the memory trampling in order to solve the problem.

[0003] In the prior art, the methods used to solve the memory trampling problem mainly include: tracking the call stack, adding log output and using debugging tools. Tracking the call stack is to determine the specific function and call flow that triggered the exception by analyzing the call stack information when the system Assert exception occurs. Adding log output is to insert debugging information or log output statements at key code locations to collect more information that helps detect the memory trampling location during operation. Using debugging tools is to use debugging tools such as GDB and LLDB to conduct in-depth analysis of the program, including operations such as setting breakpoints, viewing variable values, and single-stepping code.

[0004] However, the existing methods often take a lot of time and effort, and in the complex UEFI firmware code environment, it is often impossible to quickly detect the program that has memory trampled. For example, during the operation of the UEFI firmware, driver A destroys a piece of memory data. At this time, driver B has a memory application or release operation. If the memory data is found to be incorrect, a system Assert exception will occur. Since there may be many driver codes running between driver A and driver B, but no memory application, it is generally impossible to quickly detect which driver code caused the memory trampling problem. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present application provides a memory trampling detection method, an electronic device and a storage medium. By detecting the memory management linked list at preset time intervals, when it is detected that there are linked list sub-units in the memory management linked list that do not meet the preset conditions, it is determined that the currently executed driver is the driver where memory trampling has occurred, and the driver where memory trampling has occurred can be detected quickly and accurately.

[0006] To solve the above problems, the present invention provides the following technical solutions: In a first aspect, an embodiment of the present application provides a memory trampling detection method, comprising: when executing each driver in a loading order, detecting a memory management linked list at a preset time interval; Determine whether all linked list subunits in the memory management linked list meet preset conditions; When it is detected that there is a linked list subunit in the memory management linked list that does not meet the preset condition, it is determined that the currently executed driver is the driver in which memory trampling occurs.

[0007] In some implementations, the memory management linked list includes a first linked list for managing unallocated memory, and determining whether all linked list subunits in the memory management linked list meet a preset condition includes: It is determined whether all first linked list sub-units in the first linked list meet a first preset condition.

[0008] In some implementations, each of the first linked list subunits includes a first identifier located at a head, and determining whether all the first linked list subunits in the first linked list meet the first preset condition includes: When each of the first linked list sub-units includes the first identifier, determining that all the first linked list sub-units in the first linked list meet the first preset condition; When there is the first linked list subunit that does not include the first identifier, it is determined that there is a first linked list subunit that does not meet the first preset condition.

[0009] In some implementations, the memory management linked list includes a second linked list for managing allocated memory, and determining whether all linked list subunits in the memory management linked list meet a preset condition includes: It is determined whether all second linked list sub-units in the second linked list meet a second preset condition.

[0010] In some implementations, each of the second linked list subunits includes a second identifier located at the head, and determining whether all the second linked list subunits in the second linked list meet the second preset condition includes: When each of the second linked list sub-units includes the second identifier, determining that all the second linked list sub-units in the second linked list meet the second preset condition; When there is a second linked list subunit that does not include the second identifier, it is determined that there is a second linked list subunit that does not meet the second preset condition.

[0011] In some embodiments, the memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, the first linked list is stored in a first structure, one first structure is used to manage unallocated memory of a type of memory resource, the second linked list is stored in a second structure, one second structure is used to manage allocated memory of a type of memory resource, each driver corresponds to a type of memory resource, and the determining whether all linked list subunits in the memory management linked list meet a preset condition includes: When executing each of the drivers according to the loading order, determining a first structure and a second structure corresponding to the driver according to a type of memory resources corresponding to the driver; Determine whether all first linked list sub-units of the first linked list in the first structure corresponding to the driver program meet the first preset condition; It is determined whether all second linked list sub-units of the second linked list in the second structure corresponding to the driver program meet the second preset condition.

[0012] In some implementations, determining whether all linked list subunits in the memory management linked list meet a preset condition includes: When executing each of the drivers in the loading order, creating a timer event according to the preset time interval; In response to receiving a trigger signal generated by the timer event at every preset time interval, it is determined whether all the linked list sub-units in the memory management linked list meet the preset condition.

[0013] In some embodiments, the memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, the first linked list includes a plurality of first branch linked lists, one of the first branch linked lists corresponds to a storage address of a bit width, the second linked list includes a plurality of second branch linked lists, one of the second branch linked lists corresponds to a storage address of a bit width, and the determining whether all linked list subunits in the memory management linked list meet a preset condition includes: When executing each of the drivers according to the loading order, it is determined at each preset time interval whether all the first linked list sub-units in each of the first branch linked lists of the first linked list corresponding to the driver meet the first preset condition, and it is determined whether all the second linked list sub-units in each of the second branch linked lists of the second linked list corresponding to the driver meet the second preset condition.

[0014] In a second aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: at least one processor; and, 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 so that the at least one processor can execute the memory stepping detection method as described in the first aspect.

[0015] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores an executable program, and the executable program is executed by a processor to implement the memory stepping detection method as described in the first aspect.

[0016] The present application provides a memory trampling detection method, an electronic device and a storage medium. The present application detects the memory management linked list at preset time intervals. When it is detected that there are linked list sub-units in the memory management linked list that do not meet preset conditions, it is determined that the currently executed driver is the driver where memory trampling occurs. The driver where memory trampling occurs can be detected quickly and accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a flow chart of the memory stepping detection method provided in the embodiment of the present application.

[0018] Figure 2 yes Figure 1 Schematic diagram of the first detailed process of step S200.

[0019] Figure 3 It is a schematic diagram of the first linked list provided in an embodiment of the present application.

[0020] Figure 4 It is a schematic diagram of the second linked list subunit provided in an embodiment of the present application.

[0021] Figure 5 yes Figure 1 A second detailed flow chart of step S200 in FIG.

[0022] Figure 6 yes Figure 1 A third detailed flow chart of step S200 in FIG.

[0023] Figure 7 It is a structural schematic diagram of the memory stepping detection device provided in an embodiment of the present application.

[0024] Figure 8 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.

[0025] Fig. 9 It is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0028] The present application provides a memory trampling detection method, an electronic device and a storage medium. By detecting the memory management linked list at every preset time interval, when it is detected that there are linked list sub-units in the memory management linked list that do not meet the preset conditions, it is determined that the currently executed driver is the driver where the memory trampling occurs, and the driver where the memory trampling occurs can be detected quickly and accurately.

[0029] The memory stepping detection method provided by the present application will be described in detail below with reference to the accompanying drawings.

[0030] See also Figure 1 , Figure 1 is a flow chart of the memory stepping detection method provided in the embodiment of the present application. Figure 1 As shown, the memory stepping detection method includes: step S100 to step S300.

[0031] Step S100: When executing each driver program in the loading order, the memory management linked list is checked at a preset time interval.

[0032] In some implementations, when the computer system boots up, each driver is executed in a loading order to initialize the hardware and load the operating system.

[0033] Exemplarily, the loading order is to load the first driver, the second driver, and the third driver in sequence. Only one driver is executed in the same time period. When the first driver is executed, the memory management linked list is checked at preset time intervals. When the second driver is executed, the memory management linked list is checked at preset time intervals. When the third driver is executed, the memory management linked list is checked at preset time intervals.

[0034] In some implementations, during the operation of a computer system, memory resources need to be allocated and released. A memory management linked list is used to manage memory resources in a computer system.

[0035] Optionally, the computer system may be a Windows system or a FreeRTOS system, etc.

[0036] Optionally, the memory trampling detection method is executed by UEFI firmware. The UEFI firmware may be firmware in a Windows system.

[0037] Optionally, the memory trampling detection method is executed by relevant firmware in the FreeRTOS system.

[0038] Step S200: Determine whether all linked list sub-units in the memory management linked list meet preset conditions.

[0039] In some implementations, one linked list subunit manages one storage address.

[0040] Optionally, the data structure of the linked list subunit is a structure, an array, a linked list or a tree.

[0041] See also Figure 2 , Figure 2 yes Figure 1 The first detailed flow chart of step S200 in FIG. Figure 2 As shown, in some embodiments, step S200 includes steps S210 to S220.

[0042] Step S210: when executing each driver program in the loading order, creating a timer event according to a preset time interval.

[0043] Optionally, the timer event may generate a trigger signal at every preset time interval.

[0044] Step S220: In response to receiving a trigger signal generated by a timer event at a preset time interval, determining whether all linked list sub-units in the memory management linked list meet preset conditions.

[0045] Optionally, in response to receiving a trigger signal generated by a timer event at preset time intervals, the current driver program is stopped from being executed, and it is determined whether all the linked list sub-units in the memory management linked list meet preset conditions.

[0046] In some implementations, the memory management linked list includes a first linked list for managing unallocated memory.

[0047] Optionally, the preset condition includes a first preset condition.

[0048] In some embodiments, step S200 includes step (200.1).

[0049] (200.1) Determine whether all first linked list sub-units in the first linked list meet a first preset condition.

[0050] In some implementations, each first linked list subunit includes a first identifier at the head.

[0051] Exemplarily, the first linked list subunit is a structure. One first linked list subunit corresponds to a storage address of an unallocated memory.

[0052] See also Figure 3 , Figure 3 is a schematic diagram of the first linked list provided in the embodiment of the present application. Figure 3 As shown, in some embodiments, each first linked list subunit 110 includes a first identifier 111 at the head. Exemplarily, the first identifier 111 is a character string "pfr0". Figure 3 The first linked list Freelist[0] and the first linked list Freelist[1] are the first linked lists of unallocated memory that manage different types of memory resources.

[0053] In some embodiments, step (200.1) includes steps (200.1.1) to step (200.1.2).

[0054] (200.1.1) When each first linked list sub-unit includes the first identifier, determine that all first linked list sub-units in the first linked list meet the first preset condition.

[0055] Exemplarily, when the first identifier 111 is a character string “pfr0” and the first linked list sub-unit 110 includes the character string “pfr0”, it is determined that the first linked list sub-unit 110 meets the first preset condition.

[0056] (200.1.2) When there is a first linked list subunit that does not include the first identifier, determine that there is a first linked list subunit that does not meet the first preset condition.

[0057] Exemplarily, when the first identifier 111 is the string “pfr0” and the first linked list sub-unit 110 does not include the string “pfr0”, it is determined that the first linked list sub-unit 110 does not meet the first preset condition.

[0058] like Figure 3 As shown, in some embodiments, Link in the first linked list subunit 110 represents a pointer, and Index represents an index of the first linked list subunit 110. The pointer of each first linked list subunit 110 that is not at the end of the first linked list points to the next first linked list subunit 110.

[0059] Optionally, the first linked list sub-unit further includes an identifier of a corresponding storage address, and the first linked list sub-unit indicates that the corresponding storage address has not been allocated.

[0060] In some implementations, when memory resources need to be allocated to the driver, a first linked list subunit corresponding to the storage address that meets the first preset condition is first searched in the first linked list, and then the first linked list subunit is deleted.

[0061] In some implementations, when a memory trampling problem occurs, for example, when a driver program deletes a first linked list subunit, data is written to the storage address of the first linked list subunit to be deleted due to a code error, and the data overflows to the next first linked list subunit. Because the storage address of the next first linked list subunit is physically adjacent to the storage address of the first linked list subunit to be deleted, the first identifier at the head of the next first linked list subunit is destroyed.

[0062] It is understandable that there are many reasons for the occurrence of memory trampling, and the above is only one of the reasons. Regardless of the reason, when the memory trampling problem occurs, at least one linked list subunit will be destroyed because the identifier of its head is not the preset identifier. Therefore, the above method can be used to detect the driver that has memory trampling.

[0063] In some implementations, the memory management linked list includes a second linked list for managing allocated memory.

[0064] Optionally, the preset condition includes a second preset condition.

[0065] In some embodiments, step S200 includes step (200.2).

[0066] (200.2) Determine whether all second linked list sub-units in the second linked list meet the second preset condition.

[0067] Optionally, the structure of the second linked list refers to the structure of the first linked list, but the structure of the subunit of the second linked list is different from the structure of the subunit of the first linked list.

[0068] Optionally, the second linked list may also be called Poollist.

[0069] In some implementations, each second linked list subunit includes a second identifier at the head.

[0070] Exemplarily, the second linked list subunit is a structure. One second linked list subunit manages a storage address of an allocated memory.

[0071] See also Figure 4 , Figure 4is a schematic diagram of the second linked list subunit provided in the embodiment of the present application. Figure 4 As shown, in some embodiments, each second linked list subunit 200 includes a second identifier 210 at the head. Exemplarily, the second identifier 210 is a character string "phd0".

[0072] In some implementations, Reserved in the second linked list subunit 200 is a reserved field used to expand the function of the second linked list subunit 200. Type in the second linked list subunit 200 is used to indicate the type of memory resources managed by the second linked list subunit 200, Size is used to indicate the size of data stored in the second linked list subunit 200, and Data is used to indicate the data stored in the second linked list subunit 200.

[0073] Optionally, the second linked list sub-unit 200 is stored in a storage address corresponding to the second linked list sub-unit 200 .

[0074] In some implementations, the second linked list subunit further includes a pointer. Each pointer of the second linked list subunit not located at the end of the second linked list points to the next second linked list subunit.

[0075] In some embodiments, step (200.2) includes steps (200.2.1) to step (200.2.2).

[0076] (200.2.1) When each second linked list sub-unit includes the second identifier, determine that all second linked list sub-units in the second linked list meet the second preset condition.

[0077] Exemplarily, when the second identifier 210 is the character string “phd0”, and the second linked list sub-unit 200 includes the character string “phd0”, it is determined that the second linked list sub-unit 200 meets the second preset condition.

[0078] (200.2.2) When there is a second linked list subunit that does not include the second identifier, determine that there is a second linked list subunit that does not meet the second preset condition.

[0079] Exemplarily, when the second identifier 210 is the character string “phd0”, and the second linked list sub-unit 200 does not include the character string “phd0”, it is determined that the second linked list sub-unit 200 does not meet the second preset condition.

[0080] In some implementations, when memory resources need to be allocated to the driver, a first linked list subunit corresponding to the storage address that meets the first preset condition is first found in the first linked list, and then the first linked list subunit is deleted. Thereafter, a second linked list subunit corresponding to the storage address is inserted into the second linked list.

[0081] Optionally, when there is no first linked list subunit corresponding to the storage address in the first linked list that meets the first preset condition, but all the first linked list subunits in the first linked list meet the first preset condition, the second linked list subunit corresponding to the storage address is directly inserted into the second linked list.

[0082] In some implementations, when it is necessary to release memory resources for the driver, a second linked list subunit corresponding to the storage address that meets the second preset condition is found in the second linked list, and then the second linked list subunit is deleted.

[0083] In some embodiments, when a memory trampling problem occurs, for example, when a driver program inserts a second linked list subunit, due to a code error, data exceeding a preset data amount is written into the second linked list subunit, and the data overflows to the next second linked list subunit. Because the storage address of the next second linked list subunit is connected to the physical location of the storage address of the second linked list subunit, the second identifier of the head of the next second linked list subunit is destroyed.

[0084] It is understandable that there are many reasons for the occurrence of memory trampling, and the above is only one of the reasons. Regardless of the reason, when the memory trampling problem occurs, at least one linked list subunit will be destroyed because the identifier of its head is not the preset identifier. Therefore, the above method can be used to detect the driver that has memory trampling.

[0085] In some embodiments, the memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, and step S200 includes steps (200.1) to (200.2). The contents of steps (200.1) to (200.2) refer to the above description.

[0086] In some embodiments, the first linked list is stored in a first structure, a first structure is used to manage unallocated memory of a type of memory resource, the second linked list is stored in a second structure, a second structure is used to manage allocated memory of a type of memory resource, and each driver corresponds to a type of memory resource.

[0087] like Figure 3 As shown, in some embodiments, the first linked list Freelist[0] is stored in the first structure 10, the first linked list Freelist[1] is stored in the first structure 20, and the first linked list Freelist[0] and the first linked list Freelist[1] are the first linked lists of unallocated memory that manage different types of memory resources.

[0088] In some implementations, the first structure 10 includes a first structure identifier at the head, for example, the first structure identifier is a string “pist”.

[0089] In some implementations, the first structure 10 further includes a usage status identifier, for example, the usage status identifier is Used.

[0090] In some embodiments, the first structure 10 further includes a memory resource type identifier, such as a memory resource type identifier of EfiBootServiceData or EfiRuntimeServicesData, etc. EfiBootServiceData indicates that the memory resource is used to store data about EFI boot services. EfiRuntimeServicesData indicates that the memory resource is used to store global data required when the UEFI firmware is running.

[0091] In some implementations, the first structure further includes a pointer to the next first structure.

[0092] Optionally, the structure of the second structure body refers to the structure of the first structure body, and the structure of the second linked list refers to the structure of the first linked list.

[0093] See also Figure 5 , Figure 5 yes Figure 1 A second detailed flow chart of step S200 in FIG. Figure 5 As shown, in some embodiments, step S200 includes steps S230 to S250.

[0094] Step S230: when executing each driver program in the loading order, determining the first structure and the second structure corresponding to the driver program according to the type of memory resources corresponding to the driver program.

[0095] As described above, each driver corresponds to a type of memory resource, and a type of memory resource corresponds to a first structure and a second structure, so the first structure and the second structure corresponding to the driver can be determined according to the type of memory resource corresponding to the driver. In this way, there is no need to detect the memory management linked list in the structure that is not related to the currently executed driver, thereby reducing the amount of calculation and improving the detection speed.

[0096] Step S240: Determine whether all first linked list sub-units of the first linked list in the first structure corresponding to the driver program meet the first preset condition.

[0097] The content of step S240 refers to the relevant description of the above step (200.1).

[0098] Step S250: Determine whether all second linked list sub-units of the second linked list in the second structure corresponding to the driver program meet the second preset condition.

[0099] The content of step S250 refers to the relevant description of the above step (200.2).

[0100] In some embodiments, the memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, the first linked list includes multiple first branch linked lists, each first branch linked list corresponds to a storage address of a bit width, and the second linked list includes multiple second branch linked lists, each second branch linked list corresponds to a storage address of a bit width.

[0101] like Figure 3 As shown, exemplarily, the first linked list Freelist[0] includes a first branch linked list 11, a first branch linked list 12, and a first branch linked list 13. The first branch linked list 11 corresponds to a 128-bit storage address. The first branch linked list 12 corresponds to a 256-bit storage address. The first branch linked list 13 corresponds to a 29824-bit storage address.

[0102] It is understandable that the number of the first branch linked lists is multiple, not limited to Figure 3 For example, the number of the first branch linked lists may be 2, 3, 5, 10, or 100.

[0103] Optionally, the structure of the second linked list refers to the structure of the first linked list.

[0104] In some embodiments, step S200 includes: when executing each driver in the loading order, determining whether all first linked list sub-units in each first branch linked list of the first linked list corresponding to the driver meet the first preset condition at every preset time interval, and determining whether all second linked list sub-units in each second branch linked list of the second linked list corresponding to the driver meet the second preset condition.

[0105] By means of the above method, the memory management linked list can be fully detected, and when the driver operates the unnecessary first branch linked list or the second branch linked list due to a code error, the location where the memory is trampled can also be detected.

[0106] like Figure 3 As shown, illustratively, at every preset time interval, it is determined whether all the first linked list sub-units in the first branch linked list 11, the first branch linked list 12 and the first branch linked list 13 of the first linked list Freelist[0] corresponding to the driver meet the first preset condition.

[0107] In some implementations, the target bit width of the storage address of the memory applied for or released by the driver is obtained, and it is determined whether all the first linked list sub-units in the target first branch linked list of the first linked list corresponding to the driver meet the first preset condition according to the target bit width, and it is determined whether all the second linked list sub-units in the target second branch linked list of the second linked list corresponding to the driver meet the second preset condition. In this way, there is no need to detect the first branch linked list and the second branch linked list that are not related to the driver, which can reduce the amount of calculation and improve the detection speed.

[0108] See also Figure 6 , Figure 6 yes Figure 1 The third detailed flow chart of step S200 in FIG. Figure 6 As shown, in some embodiments, step S200 includes steps S260 to S270.

[0109] Step S260: When each driver is executed in the loading order, a timer event is created according to a preset time interval.

[0110] Step S270: In response to receiving a trigger signal generated by a timer event at preset time intervals, determine whether all first linked list sub-units in each first branch linked list of the first linked list in the first structure corresponding to the driver program meet the first preset condition, and determine whether all second linked list sub-units in each second branch linked list of the second linked list in the second structure corresponding to the driver program meet the second preset condition.

[0111] As described above, in some embodiments, each driver corresponds to a type of memory resource, and a type of memory resource corresponds to a first structure and a second structure. Therefore, the first structure and the second structure corresponding to the driver can be determined according to the type of memory resources corresponding to the driver, and then the first linked list and the second linked list corresponding to the driver can be determined according to the first structure and the second structure corresponding to the driver.

[0112] As described above, in some embodiments, when each first linked list subunit includes the first identifier, it is determined that all first linked list subunits in the first linked list meet the first preset condition; when there are first linked list subunits that do not include the first identifier, it is determined that there are first linked list subunits that do not meet the first preset condition.

[0113] As described above, in some embodiments, when each second linked list subunit includes the second identifier, it is determined that all second linked list subunits in the second linked list meet the second preset condition; when there is a second linked list subunit that does not include the second identifier, it is determined that there is a second linked list subunit that does not meet the second preset condition.

[0114] Step S300: when it is detected that there is a linked list subunit in the memory management linked list that does not meet the preset condition, determining that the currently executed driver is the driver that has memory trampling.

[0115] In some implementations, when all linked list sub-units in the memory management linked list meet a preset condition, the current driver program continues to be executed.

[0116] In some implementations, when there is a linked list subunit in the memory management linked list that does not meet a preset condition, execution of the current driver program is stopped.

[0117] Optionally, when there is a linked list subunit in the memory management linked list that does not meet a preset condition, a dead loop is entered to stop executing the current driver.

[0118] Optionally, the user can view where the program stopped, which is where the memory trampling occurred.

[0119] In summary, the memory stepping detection method provided in the embodiment of the present application has the following advantages: 1. By detecting the memory management linked list at preset time intervals, when it is detected that there is a linked list subunit in the memory management linked list that does not meet the preset conditions, it is determined that the currently executed driver is the driver where the memory trampling occurs, and the driver where the memory trampling occurs can be detected quickly and accurately.

[0120] 2. By determining the first structure and the second structure corresponding to the driver according to the type of memory resources corresponding to the driver, there is no need to detect the memory management linked list in the structure unrelated to the currently executed driver, thereby reducing the amount of calculation and improving the detection speed.

[0121] 3. By judging whether all the first linked list sub-units in each first branch linked list of the first linked list corresponding to the driver meet the first preset condition at every preset time interval, and judging whether all the second linked list sub-units in each second branch linked list of the second linked list corresponding to the driver meet the second preset condition, the memory management linked list can be comprehensively detected. When the driver operates the first branch linked list or the second branch linked list that does not need to be operated due to a code error, the location where the memory trampling occurs can also be detected.

[0122] 4. By judging whether all the first linked list sub-units in the target first branch linked list of the first linked list corresponding to the driver meet the first preset condition according to the target bit width, and judging whether all the second linked list sub-units in the target second branch linked list of the second linked list corresponding to the driver meet the second preset condition, there is no need to detect the first branch linked list and the second branch linked list that are not related to the driver, which can reduce the amount of calculation and improve the detection speed.

[0123] See also Figure 7 , Figure 7 Schematic diagram of the structure of the memory stepping detection device provided in the embodiment of the present application. Figure 7 As shown, the memory stepping detection device 300 includes an execution module 310 and a judgment module 320 .

[0124] In some implementations, the execution module 310 is configured to detect the memory management linked list at preset time intervals when executing each driver program in the loading order.

[0125] In some embodiments, the judgment module 320 is used to judge whether all the linked list sub-units in the memory management linked list meet the preset conditions; when it is detected that there are linked list sub-units in the memory management linked list that do not meet the preset conditions, it is determined that the currently executed driver is the driver where memory trampling occurs.

[0126] See also Figure 8 , Figure 8 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 8 As shown, the electronic device 400 includes: one or more processors 410 and a memory 420, Figure 8 A processor 410 is taken as an example.

[0127] In some implementations, the processor 410 and the memory 420 may be connected via a bus or other means. Figure 8 The example of connecting through bus is taken in the following.

[0128] In some embodiments, the processor 410 is used to detect the memory management linked list at preset time intervals when executing each driver in the loading order; determine whether all the linked list sub-units in the memory management linked list meet the preset conditions; when it is detected that there are linked list sub-units in the memory management linked list that do not meet the preset conditions, determine that the currently executed driver is the driver where memory trampling occurs.

[0129] In some embodiments, the memory 420, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules of the memory trampling detection method in the embodiment of the present application. The processor 410 executes various functional applications and data processing of the electronic device 400 by running the non-volatile software programs, instructions and modules stored in the memory 420, that is, the memory trampling detection method of the above method embodiment is implemented.

[0130] In some embodiments, the memory 420 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device 400, etc. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 420 may optionally include a memory remotely arranged relative to the processor 410, and these remote memories may be connected to the controller via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0131] In some embodiments, one or more modules are stored in the memory 420, and when executed by one or more processors 410, the memory stepping detection method in any of the above method embodiments is executed, for example, the memory stepping detection method described above is executed. Figure 1 The method comprises steps S100 to S300.

[0132] In some embodiments, the electronic device may be a chip, such as a data processor (DPU) chip used in a data center, or the electronic device may be a network interface card including a chip and multiple interfaces (such as a PCI / PCIE interface, a UART interface, a USB interface, etc.), or the electronic device may be a traditional server, or a server including a network interface card or a chip, wherein the server includes a host and a data processor, wherein the data processor is used to dispatch messages to the host or the data processor itself for processing, and the host is used to process messages dispatched by the data processor.

[0133] Please refer to Fig. 9 , Fig. 9 The computer-readable storage medium 500 stores a program code 510, which can be called by a processor to execute the memory stepping detection method described in the above method embodiment.

[0134] The computer-readable storage medium 500 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium 500 has a storage space for program codes for executing any method steps in the above-mentioned memory stepping detection method. These program codes may be read from or written to one or more computer program products. The program code may be compressed, for example, in an appropriate form.

[0135] In some implementations, the embodiments of the present application further provide a computer program product, including a computer program, which implements the above-mentioned memory trampling detection method when executed by a processor.

[0136] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium 500. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to a memory, a database or other medium used in the embodiments provided in the present application can include at least one of a non-volatile and a volatile memory. Non-volatile memory can include a read-only memory (ROM), a magnetic tape, a floppy disk, a flash memory, an optical memory, a high-density embedded non-volatile memory, a resistive random access memory (ReRAM), a magnetoresistive random access memory (MRAM), a ferroelectric random access memory (FRAM), a phase change memory (PCM), a graphene memory, etc. Volatile memory can include a random access memory (RAM) or an external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0137] In summary, the present application provides a memory trampling detection method, an electronic device, and a storage medium. The memory trampling detection method includes: when executing each driver program in a loading order, detecting the memory management linked list at preset time intervals; determining whether all linked list subunits in the memory management linked list meet preset conditions; and determining that the currently executed driver program is a driver program where memory trampling has occurred when detecting that there are linked list subunits in the memory management linked list that do not meet the preset conditions. The present application can quickly and accurately detect a driver program where memory trampling has occurred by detecting the memory management linked list at preset time intervals and determining that the currently executed driver program is a driver program where memory trampling has occurred when detecting that there are linked list subunits in the memory management linked list that do not meet the preset conditions.

[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A memory trampling detection method, characterized in that: include: When executing each driver in the loading order, the memory management linked list is checked at a preset time interval; Determine whether all linked list subunits in the memory management linked list meet preset conditions; When it is detected that there is a linked list subunit in the memory management linked list that does not meet the preset condition, it is determined that the currently executed driver is the driver in which memory trampling occurs.

2. The memory trampling detection method according to claim 1, characterized in that: The memory management linked list includes a first linked list for managing unallocated memory, and the determining whether all linked list subunits in the memory management linked list meet a preset condition includes: It is determined whether all first linked list sub-units in the first linked list meet a first preset condition.

3. The memory trampling detection method according to claim 2, characterized in that: Each of the first linked list sub-units includes a first identifier at the head, and the determining whether all the first linked list sub-units in the first linked list meet the first preset condition includes: When each of the first linked list sub-units includes the first identifier, determining that all the first linked list sub-units in the first linked list meet the first preset condition; When there is the first linked list subunit that does not include the first identifier, it is determined that there is a first linked list subunit that does not meet the first preset condition.

4. The memory trampling detection method according to claim 1, characterized in that: The memory management linked list includes a second linked list for managing allocated memory, and the determining whether all linked list subunits in the memory management linked list meet a preset condition includes: It is determined whether all second linked list sub-units in the second linked list meet a second preset condition.

5. The memory trampling detection method according to claim 4, characterized in that: Each of the second linked list sub-units includes a second identifier at the head, and the determining whether all the second linked list sub-units in the second linked list meet the second preset condition includes: When each of the second linked list sub-units includes the second identifier, determining that all the second linked list sub-units in the second linked list meet the second preset condition; When there is a second linked list subunit that does not include the second identifier, it is determined that there is a second linked list subunit that does not meet the second preset condition.

6. The memory trampling detection method according to claim 1, characterized in that: The memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, the first linked list is stored in a first structure, one of the first structures is used to manage unallocated memory of a type of memory resource, the second linked list is stored in a second structure, one of the second structures is used to manage allocated memory of a type of memory resource, each of the drivers corresponds to a type of memory resource, and the determining whether all the linked list subunits in the memory management linked list meet a preset condition includes: When executing each of the drivers according to the loading order, determining a first structure and a second structure corresponding to the driver according to a type of memory resources corresponding to the driver; Determine whether all first linked list sub-units of the first linked list in the first structure corresponding to the driver program meet the first preset condition; It is determined whether all second linked list sub-units of the second linked list in the second structure corresponding to the driver program meet the second preset condition.

7. The memory trampling detection method according to claim 1, characterized in that: The determining whether all the linked list sub-units in the memory management linked list meet the preset conditions includes: When executing each of the drivers in the loading order, creating a timer event according to the preset time interval; In response to receiving a trigger signal generated by the timer event at every preset time interval, it is determined whether all the linked list sub-units in the memory management linked list meet the preset condition.

8. The memory trampling detection method according to claim 1, characterized in that: The memory management linked list includes a first linked list for managing unallocated memory and a second linked list for managing allocated memory, the first linked list includes a plurality of first branch linked lists, one of the first branch linked lists corresponds to a storage address of a bit width, the second linked list includes a plurality of second branch linked lists, one of the second branch linked lists corresponds to a storage address of a bit width, and the determining whether all linked list subunits in the memory management linked list meet a preset condition includes: When executing each of the drivers according to the loading order, it is determined at each preset time interval whether all the first linked list sub-units in each of the first branch linked lists of the first linked list corresponding to the driver meet the first preset condition, and it is determined whether all the second linked list sub-units in each of the second branch linked lists of the second linked list corresponding to the driver meet the second preset condition.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, 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 so that the at least one processor can execute the memory stepping detection method as described in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an executable program, and the executable program is executed by a processor to implement the memory stepping detection method according to any one of claims 1 to 8.