Data access method and apparatus

By calculating the verification factor in the memory area identification information in the reference variable in the running system based on the WebAssembly virtual machine, the data access problem caused by the application's illegal modification of the memory area identification information is solved, and the security and reliability of data access are improved.

WO2025113477A1PCT designated stage expired Publication Date: 2025-06-05BEIJING TONGFANG MICROELECTRONICS
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/134821
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-11-28
Filing Date
2024-11-27
Publication Date
2025-06-05

AI Technical Summary

Technical Problem

In a running system based on WebAssembly virtual machine, applications may illegally modify the storage area identification information in the reference variable, resulting in data access failure or illegal access to data from other applications, affecting the security and reliability of data access.

Method used

By calculating the first and second verification factors, it is verified whether the memory area identification information in the reference variable has been illegally modified. Only when the first check factor is the same as the second check factor, the target data is allowed to be obtained from the data storage area.

Benefits of technology

It effectively reduces data access errors or illegal data access caused by the application's illegal modification of the storage area identification information in the reference variable, and improves the reliability and security of data access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024134821_05062025_PF_FP_ABST
    Figure CN2024134821_05062025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a data access method and apparatus, which are applied to an operating system based on a WebAssembly virtual machine. The method comprises: obtaining a data access instruction initiated by an application program, wherein the data access instruction carries first variable data of a reference variable; on the basis of storage area identification information in the first variable data of the reference variable, determining a storage area address of a data storage area corresponding to the application program; on the basis of the storage area address, acquiring basic attribute information recorded in the data storage area; acquiring a first check factor associated with the reference variable; on the basis of the basic attribute information and the storage area address, calculating a second check factor; and if the first check factor and the second check factor are identical, acquiring target data from the data storage area on the basis of the first variable data of the reference variable and the storage area address. The solution of the present application can improve the security and reliability of data access regarding an operating system based on a WebAssembly virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Data access method and device

[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on November 28, 2023, with application number 202311605963.X and invention name “Data Access Method and Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of computer technology, and in particular to a data access method and device. Background Art

[0003] Currently, a WebAssembly virtual machine-based operating system can be deployed in resource-constrained chips or devices. This operating system provides an operating environment for applications, and the WebAssembly virtual machine interprets and executes the application's bytecode.

[0004] During the application installation or operation phase, the application can request the data storage space belonging to the application from the operating system by calling the interface provided in the operating environment corresponding to the WebAssembly virtual machine. The operating system constructs a reference variable for the application based on the storage address corresponding to the data storage space allocated to the application, and records the address information related to the storage address of the data storage space in the reference variable, so as to update the data content of the corresponding reference variable in the application based on the value of the reference variable. Based on this, when the application needs to access the data stored in the data storage space, the WebAssembly virtual machine can access the data in the data storage space based on the address information in the reference variable provided by the application.

[0005] However, while an application is running, it can modify the reference variable in the application. Therefore, if an application illegally modifies the address information related to the data storage space in the reference variable, the WebAssembly virtual machine may be unable to accurately locate the data storage space corresponding to the application based on the address information in the reference variable. This may not only cause data access failures, but may also send data from the data storage space corresponding to other applications to the application, resulting in illegal access to the data of other applications, affecting the security and reliability of data access. Summary of the Invention

[0006] The present application provides a data access method and apparatus to improve the security and reliability of data access in an operating system based on a WebAssembly virtual machine.

[0007] In one aspect, the present application provides a data access method, which is applied to an operating system based on a WebAssembly virtual machine, and the method includes:

[0008] Obtaining a data access instruction initiated by an application, the data access instruction carrying first variable data of a reference variable, the first variable data of the reference variable being used to indicate a data address of target data to be accessed;

[0009] Determining a storage area address of a data storage area corresponding to the application based on storage area identification information recorded in the first variable data of the reference variable, wherein the storage area identification information is used to identify the data storage area corresponding to the application;

[0010] Obtaining a first check factor associated with the reference variable, where the first check factor is calculated by the running system based on a storage area address of the data storage area when generating variable data corresponding to the reference variable for the application;

[0011] Calculating a second check factor based on the storage area address;

[0012] If the first check factor is the same as the second check factor, the target data is obtained from the data storage area based on the first variable data of the reference variable and the storage area address.

[0013] In a possible implementation, after determining the storage area address of the data storage area corresponding to the application, the method further includes:

[0014] Based on the storage area address, obtaining basic attribute information recorded in the data storage area, the basic attribute information including attribute information associated with the data storage area and the application;

[0015] The first check factor is calculated based on the storage area address and basic attribute information of the data storage area;

[0016] The calculating a second check factor based on the storage area address includes:

[0017] A second check factor is calculated based on the basic attribute information recorded in the data storage area and the storage area address.

[0018] In yet another possible implementation, after obtaining the data access indication initiated by the application, the method further includes:

[0019] Obtaining a storage area type identifier in first variable data of the reference variable, the storage area type identifier being one of a first type identifier and a second type identifier, the first type identifier indicating that a storage capacity of a data storage area corresponding to the application is not less than a set threshold, and the second type identifier indicating that a storage capacity of the data storage area is less than the set threshold;

[0020] The first check factor is calculated based on the storage area address, basic attribute information and storage area type identifier of the data storage area;

[0021] The calculating a second check factor based on the basic attribute information recorded in the data storage area and the storage area address includes:

[0022] A second check factor is calculated based on the basic attribute information recorded in the data storage area, the storage area address, and the storage area type identifier.

[0023] In yet another possible implementation, obtaining the first check factor associated with the reference variable includes:

[0024] If the storage area type identifier is a first type identifier, obtaining a first check factor from first variable data of the reference variable;

[0025] If the storage area type identifier is the second type identifier, a first check factor associated with the reference variable is obtained from the attribute storage area of ​​the data storage area.

[0026] In yet another possible implementation, determining the storage area address of the data storage area corresponding to the application based on the storage area identification information recorded in the first variable data of the reference variable includes:

[0027] If the storage area type identifier is a first type identifier, obtaining an address index recorded in the first variable data of the reference variable, and determining a storage area address of the data storage area corresponding to the application based on the address index, wherein the address index is used to indicate a storage location of the storage area address of the data storage area in an address storage table;

[0028] If the storage area type identifier is the second type identifier, obtain the offset information recorded in the first variable data of the reference variable, and determine the storage area address of the data storage area based on the offset information, wherein the offset information is used to represent the relative offset address of the storage area address of the data storage area relative to the starting address of the total space, and the starting address of the total space is the starting address of the total storage space of the running system.

[0029] In yet another possible implementation, obtaining offset information recorded in the first variable data of the reference variable, and determining a storage area address of the data storage area based on the offset information includes:

[0030] Obtaining first offset information and second offset information recorded in first variable data of the reference variable, where the first offset information is a remainder obtained by dividing the relative offset address by a target number of bytes, and the second offset information is a quotient obtained by dividing the relative offset address by the target number of bytes;

[0031] Determining the relative offset address corresponding to the data storage area based on the first offset information and the second offset information;

[0032] The storage area address of the data storage area is determined based on the relative offset address.

[0033] In another possible implementation, the first variable data of the reference variable includes a data offset address of the target data in a data storage area corresponding to the application;

[0034] If the first check factor is the same as the second check factor, obtaining the target data from the data storage area based on the first variable data of the reference variable and the storage area address includes:

[0035] If the first check factor is the same as the second check factor, the target data is obtained from the data storage area based on the data offset address and the storage area address.

[0036] In yet another possible implementation, before obtaining the data access instruction initiated by the application, the method further includes:

[0037] Obtaining a storage area application initiated by the application, wherein the storage area application is used to apply for allocating storage space of a target storage capacity for the application;

[0038] Based on the target storage capacity, a data storage area is created for the application, and a storage area type identifier corresponding to the data storage area is determined, wherein an attribute storage area of ​​the data storage area records basic attribute information associated with the data storage area and the application, wherein if the target storage capacity is not less than a set threshold, the storage area type identifier is a first type identifier, and if the target storage capacity is less than the set threshold, the storage area type identifier is a second type identifier;

[0039] Determining storage area identification information of the data storage area based on a storage area address of the data storage area;

[0040] Calculating a first check factor based on the storage area address, basic attribute information, and storage area type identifier;

[0041] If the target storage capacity is not less than a set threshold, constructing second variable data including the storage area type identifier, the first check factor and the storage area identification information for the reference variable of the application;

[0042] If the target storage capacity is less than a set threshold, third variable data including the storage area type identifier and storage area identifier information is constructed for the reference variable of the application, and the first check factor is stored in the attribute storage area in the data storage area.

[0043] In yet another possible implementation, determining the storage area identification information of the data storage area based on the storage area address of the data storage area includes:

[0044] If the target storage capacity is not less than a set threshold, storing the storage area address of the data storage area in an address storage table, and determining an address index of the storage area address in the address storage table, wherein the address index is used to indicate a storage position of the storage area address in the address storage table;

[0045] If the target storage capacity is less than a set threshold, determining offset information corresponding to the storage area address of the data storage area, the offset information being used to represent a relative offset address of the storage area address of the data storage area relative to a starting address of a total space, where the starting address of the total space is a starting address of a total storage space of the running system;

[0046] If the target storage capacity is not less than a set threshold, constructing second variable data including the storage area type identifier, the first check factor, and the storage area identification information for the reference variable of the application, including:

[0047] If the target storage capacity is not less than a set threshold, constructing second variable data including the storage area type identifier, the first check factor and the address index for the reference variable of the application;

[0048] If the target storage capacity is less than a set threshold, constructing third variable data including the storage area type identifier and storage area identification information for the reference variable of the application program, including:

[0049] If the target storage capacity is smaller than a set threshold, third variable data including the storage area type identifier and offset information is constructed for the reference variable of the application.

[0050] In yet another possible implementation, if the target storage capacity is less than a set threshold, determining the offset information corresponding to the storage area address of the data storage area includes:

[0051] If the storage capacity is less than a set threshold, determining a relative offset address of a storage area address of the data storage area relative to a start address of the total space;

[0052] Determine a quotient and a remainder obtained by dividing the relative offset address by the target number of bytes, determine the remainder as first offset information, and determine the quotient as second offset information;

[0053] If the target storage capacity is less than a set threshold, constructing third variable data including the storage area type identifier and offset information for a reference variable of the application, including:

[0054] If the target storage capacity is smaller than a set threshold, third variable data including the storage area type identifier, first offset information, and second offset information is constructed for the reference variable of the application.

[0055] In another aspect, the present application further provides a data access device, which is applied to an operating system based on a WebAssembly virtual machine, and the device includes:

[0056] an indication obtaining unit, configured to obtain a data access indication initiated by an application, wherein the data access indication carries first variable data of a reference variable, and the first variable data of the reference variable is used to indicate a data address of target data to be accessed;

[0057] An address determining unit, configured to determine a storage area address of a data storage area corresponding to the application based on storage area identification information recorded in the first variable data of the reference variable, wherein the storage area identification information is used to identify the data storage area corresponding to the application;

[0058] a factor acquisition unit, configured to acquire a first check factor associated with the reference variable, the first check factor being calculated by the running system based on a storage area address of the data storage area when generating variable data corresponding to the reference variable for the application;

[0059] a first factor calculation unit, configured to calculate a second check factor based on the storage area address;

[0060] A data acquisition unit is configured to acquire the target data from the data storage area based on the first variable data of the reference variable and the storage area address if the first check factor is the same as the second check factor.

[0061] In another possible implementation, the device further includes: an attribute acquisition unit, configured to acquire basic attribute information recorded in the data storage area based on the storage area address, the basic attribute information including attribute information associated with the data storage area and the application;

[0062] The first check factor obtained by the factor acquisition unit is calculated based on the storage area address and basic attribute information of the data storage area;

[0063] The first factor calculation unit is specifically configured to calculate a second check factor based on the basic attribute information and the storage area address.

[0064] As can be seen from the above, in this application, after the operating system allocates a data storage area to an application, during the process of generating variable data for a reference variable associated with the data storage area for the application, a first check factor associated with the reference variable is calculated based on the storage area address corresponding to the data storage area. Based on this, since the storage area address corresponding to the data storage area is fixed and unchanging, if the storage area identification information of the data storage area in the reference variable is not illegally modified during the application's operation, then after the application initiates a data access instruction carrying the reference variable, the storage area address determined based on the storage area identification information in the variable data of the reference variable is the actual storage area address of the data storage area. Accordingly, the second check factor calculated based on this storage area address is necessarily consistent with the first check factor. Therefore, it can be seen that the target data will only be retrieved from the data storage area when the first check factor and the second check factor are the same. This can reduce the possibility of data access errors or illegal acquisition of data from other applications due to illegal modification of the storage area identification information in the reference variable by the application, thereby improving the reliability and security of data access. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0066] FIG1 shows a flow chart of a data access method provided by an embodiment of the present application;

[0067] FIG2 shows a schematic diagram of an implementation process of allocating data storage areas for an application and constructing variable data for reference variables in an embodiment of the present application;

[0068] FIG3 shows a schematic diagram of a composition structure of reference variables;

[0069] FIG4 shows a schematic diagram of a composition structure of reference variables in an embodiment of the present application;

[0070] FIG5 shows another schematic diagram of a composition structure of reference variables in an embodiment of the present application;

[0071] FIG6 shows another implementation flow diagram of allocating data storage areas for an application and constructing variable data for reference variables in an embodiment of the present application;

[0072] FIG7 shows another flow chart of a data access method provided in an embodiment of the present application;

[0073] FIG8 shows a schematic diagram of the composition structure of a data access device provided in an embodiment of the present application. DETAILED DESCRIPTION

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

[0075] As shown in FIG1 , a flow chart of a data access method provided in an embodiment of the present application is shown. The method of this embodiment is applied to an operating system based on a WebAssembly virtual machine.

[0076] WebAssembly (Wasm) is a binary format. A WebAssembly virtual machine-based operating system is a system corresponding to an embedded operating system based on the WebAssembly virtual machine. This system includes a WebAssembly virtual machine and a runtime environment corresponding to the WebAssembly virtual machine. Within this system, the WebAssembly virtual machine can run the bytecode of applications written in WebAssembly with the help of the runtime environment.

[0077] Operating systems based on the WebAssembly virtual machine are generally deployed in resource-constrained devices. Resource-constrained devices refer to chips or devices with limited computing power, power or storage capacity.

[0078] The data access method of this embodiment may include:

[0079] S101: Obtain a data access instruction initiated by an application.

[0080] The data access instruction carries first variable data of a reference variable, and the first variable data of the reference variable is used to indicate a data address of target data to be accessed.

[0081] The reference variable is a variable in the application program that is used to record the data storage area of ​​the application program and the address of the data to be accessed in the data storage area.

[0082] It is understandable that the variable data of a reference variable is actually the data content of the reference variable, also known as the value of the reference variable. When an application requests a data storage area from a runtime system based on a WebAssembly virtual machine, the runtime system will determine the initial value of the reference variable for the application, so that the application assigns a value to the reference variable in the application based on the initial value of the reference variable determined by the runtime system. During the operation of the application, the data address related to the data to be accessed in the reference variable can be legally modified, so that the variable data of the reference variable sent when the application requests access to the data is not exactly the same as the variable data of the reference variable generated by the runtime system for the application.

[0083] Based on this, for ease of distinction, the variable data of the reference variable carried in the data access instruction initiated by the application is called the first variable data, and the variable data of the reference variable subsequently generated by the operating system for the application is called the second variable data or the third variable data.

[0084] It is understandable that in an operating system based on the WebAssembly virtual machine, the WebAssembly virtual machine can respond to a data access instruction initiated by an application, obtain the data that the application needs to access, and return it to the application.

[0085] S102: Determine a storage area address of a data storage area corresponding to the application program based on storage area identification information recorded in first variable data of the reference variable.

[0086] It is understood that the WebAssembly virtual machine-based operating system allocates different data storage areas to different applications. To distinguish the data storage areas corresponding to different applications, the WebAssembly virtual machine-based operating system records the storage area identification information of the data storage area corresponding to the application in the reference variable of the application. Accordingly, the first variable data of the reference variable will include the storage area identification information.

[0087] The storage area identification information is used to identify the data storage area corresponding to the application program. However, the storage area identification is different from the storage area address of the data storage area, wherein the storage area address of the data storage area may be the starting address of the data storage area.

[0088] In this application, there are many possible situations for the storage area identification information recorded in the reference variable.

[0089] For example, in one possible scenario, the storage area identification information recorded in the first variable data of the reference variable may be an address index, where the address index is used to indicate the storage location of the storage area address corresponding to the data storage area of ​​the application in an address storage table. For example, the address index may be the sequence number of the storage area address of the data storage area in the address storage table. The address storage table is used to record the storage area addresses of the data storage areas of different applications.

[0090] In this possible situation, after obtaining the address index from the first variable data of the reference variable, the storage area address corresponding to the data storage area of ​​the application program can be queried from the address storage table based on the address index.

[0091] In another possible scenario, the storage area identification information recorded in the first variable data of the reference variable may be offset information corresponding to the data storage area of ​​the application program, where the offset information is used to represent the relative offset address corresponding to the storage area address of the data storage area. The relative offset address corresponding to the storage area address of the data storage area refers to the offset address of the storage area address of the data storage area relative to the starting address of the total storage space in the running system. For ease of distinction, the starting address of the total storage space of the running system may also be referred to as the total space starting address.

[0092] The offset information may be the relative offset address. On this basis, based on the relative offset address and the starting address of the total storage space in the running system, the storage area address of the data storage area of ​​the application program may be determined.

[0093] In an optional manner, in order to use fewer bits to represent the storage area address corresponding to the data storage area, the offset information of the present application may further include first offset information and second offset information, wherein the first offset information is the remainder obtained by dividing the relative offset address corresponding to the data storage area by the target number of bytes. The second offset information is the quotient of the relative offset address corresponding to the data storage area by the target number of bytes.

[0094] The target number of bytes may be determined based on the number of bits in the reference variable that can be used to record address information of the data storage area, and is not specifically limited. For example, considering that the addressable range of a memory chip using 2 bytes (16 bits) is 64K, the target number of bytes may be 64K.

[0095] It is understandable that after dividing the relative offset address corresponding to the data storage area by the target number of bytes, the resulting quotient and remainder have relatively few bits. Therefore, when the remainder is used as the first offset information and the quotient as the second offset information, the first offset information and the second offset information occupy fewer bits in the reference variable. Furthermore, the relative offset address corresponding to the data storage area can be reversely deduced from the first offset information and the second offset information. Thus, the storage area address of the data storage area can be determined based on the relative offset address corresponding to the data storage area and the starting address of the total storage space of the operating system.

[0096] In practical applications, one of the two possible situations of the storage area identification information can be selected as needed, or the two situations can be used in combination, without limitation.

[0097] S103: Based on the storage area address, obtain basic attribute information recorded in the data storage area.

[0098] The basic attribute information includes attribute information associated with the data storage area and the application. The basic attribute information is the inherent attribute of the data storage area and the application, and is fixed information during the operation of the application.

[0099] For example, basic attribute information may include: the storage capacity of the data storage area (i.e., the size of the data storage area), information about the application to which the data storage area belongs (e.g., the name or identifier of the application), the data type used to store data generated during the operation of the application in the data storage area, and randomly generated random factors and other information.

[0100] It's understandable that an application's data storage area is divided into two parts: an attribute storage area and a data body storage area. The attribute storage area, also known as the data header, stores basic attribute information, hence the data header information. The data body storage area can store data generated during application execution, and therefore, the data stored in this data body storage area is also the data that the application needs to read during execution.

[0101] S104: Obtain a first check factor associated with the reference variable.

[0102] The first check factor is calculated based on the storage area address and basic attribute information of the data storage area when the operating system based on the WebAssembly virtual machine generates variable data for the reference variable for the application.

[0103] As previously mentioned, after the WebAssembly virtual machine-based runtime system allocates a data storage area for an application, the runtime system needs to record the address information related to the data storage area into the application's corresponding reference variable. Before the application runs, the variable data (i.e., the value) of the application's reference variable is empty or has a default value. Based on this, in order to be able to assign a value to the reference variable in the application, the runtime system needs to construct a reference variable containing the address information related to the data storage area, that is, generate the variable data of the reference variable, so that the application can assign a value to the reference variable in the application based on the variable data of the reference variable generated by the runtime system.

[0104] In this application, there are many possible data structures for reference variables and specific implementation methods for the operating system to determine the value of the reference variable, which are not limited by this application. Several possible situations will be used as examples to illustrate this, and will not be repeated here.

[0105] It is understandable that an application may modify the variable data of a reference variable during operation. For example, during operation, the application may modify the data offset address corresponding to the data storage address in the reference variable based on the data storage address of the data stored in the data storage area. However, as described in the background technology section, if an application illegally modifies the address information related to the address of the data storage area in the reference variable, it will cause subsequent data read anomalies, and data from other applications may be illegally read. Based on this, in order to verify whether the application has modified the address information related to the data storage area in the reference variable, this application has added a check factor related to the reference variable.

[0106] In order to distinguish it from the check factor generated in the verification phase in the subsequent step S105, the check factor determined in the process of the operating system generating variable data of the reference variable for the application is called the first check factor, and the check factor generated in the verification phase is called the second check factor.

[0107] It is understandable that, when the data storage area allocated to an application is determined, the storage area address and basic attribute information of the data storage area are fixed and will not change as the application runs. In the present application, the first check factor is associated with the storage area address corresponding to the data storage area of ​​the application. Therefore, if the application illegally modifies the storage area identification information recorded in the reference variable, the storage area address determined based on the storage area identification information recorded in the reference variable will no longer be the actual storage area address of the data storage area of ​​the application. Therefore, the subsequent check factor determined based on the storage area address will inevitably be inconsistent with the first check factor.

[0108] Furthermore, since the reference variable records the storage area identification information of the data storage area, which is different from the storage area address, applications generally cannot obtain the storage area address of the data storage area based on the storage area identification information, and therefore cannot forge or reconstruct the first verification factor. Furthermore, even if an application illegally obtains the storage area address of its data storage area, it cannot obtain the basic attribute information stored in the data storage area. For example, the application cannot obtain the capacity of the data storage area. Even if it can obtain the capacity of the data storage area, it cannot determine the random factor contained in the basic attribute information, thus greatly reducing the risk of the first verification factor being deciphered.

[0109] In this application, there are many possible implementations for calculating the first check factor based on the basic attribute information and the storage area address, and this application does not impose any restrictions on this. For example, this application can calculate the first check factor based on the basic attribute information and the storage area address using a checksum algorithm, for example, using an exclusive-or, or a cyclic redundancy check (CRC) algorithm, and other checksum algorithms, without any restrictions on this.

[0110] It is understood that in practical applications, in addition to combining the basic attribute information and the storage area address, other parameters related to the data storage area or the storage area address of the data storage area may also be considered when calculating the first check factor, without limitation. For example, in one possible implementation, the first check factor may be calculated based on the basic attribute information, the storage area address, and the storage area identification information.

[0111] S105: Calculate a second check factor based on the basic attribute information and the storage area address.

[0112] In this application, the algorithm used to calculate the second check factor is the same as the algorithm used to calculate the first check factor. For example, if the CRC algorithm is used to calculate the first check factor based on the attribute information and the storage area address, the CRC algorithm can also be used to calculate the second check factor. The details are not repeated here.

[0113] In an optional manner, on the premise that the first check factor is calculated based on basic attribute information, the storage area address and the storage area identification information, the present application can also calculate the second check factor based on the basic attribute information, the storage area address and the storage area identification information in the reference variable.

[0114] S106: If the first check factor is the same as the second check factor, obtain target data from the data storage area based on the first variable data of the reference variable and the storage area address.

[0115] Combined with the previous introduction, it can be seen that if the storage area identification information in the reference variable has not been illegally modified by the application, then the storage area address determined based on the storage area identification information is the actual storage address corresponding to the storage area of ​​the application. On this basis, the second check factor calculated based on the storage area address and basic attribute information must be the same as the first check factor.

[0116] Based on this, when the second check factor is the same as the first check factor, the operating system can determine that the storage area address identifier in the first variable data of the reference variable sent by the application has not been illegally modified. Therefore, the storage area address can be determined based on the storage area identifier, and the target data can be obtained from the data storage area pointed to by the storage area address.

[0117] In the present application, the first variable data of the reference variable can be used to indicate the data address of the target data to be accessed. Therefore, based on the first variable data of the reference variable and the storage area address, the target data can be obtained from the data storage area.

[0118] In this application, there is no limitation on the specific implementation method of the variable data of the reference variable indicating the data address of the target data.

[0119] In one possible implementation, the first variable data of the reference variable may include a data offset address of target data to be accessed by the application in a data storage area corresponding to the application. The data offset address is an offset address of the data storage address of the target data in the data storage area relative to the storage area address of the data storage area.

[0120] Accordingly, after obtaining the data offset address from the first variable data of the reference variable, the target data can be retrieved from the data storage area based on the data offset address and the storage area address of the data storage area. For example, the data storage address of the target data in the data storage area can be determined based on the data offset address and the storage area address of the data storage area, and the target data can be retrieved from the data storage area based on the data storage address.

[0121] It can be understood that the present application can read the target data from the data storage area based on the data offset address recorded in the variable data of the referenced variable and the storage area address of the data storage area. Determining the target data to be accessed from the data storage area based on the data offset address and the data storage address is essentially a process of implementing data access based on methods such as pointers, thereby realizing quick access to application data by combining methods such as pointers, array subscripts or structure member references.

[0122] As can be seen from the above, in this application, after the operating system allocates a data storage area to an application, during the process of generating variable data for a reference variable associated with the data storage area for the application, a first check factor associated with the reference variable is calculated based on the basic attribute information stored in the data storage area and the storage area address corresponding to the data storage area. Based on this, since the basic attribute information and storage area address corresponding to the data storage area are fixed and unchanging, if the storage area identification information of the data storage area in the reference variable is not illegally modified during the application's operation, then after the application initiates a data access instruction carrying the reference variable, the storage area address determined based on the storage area identification information in the variable data of the reference variable is the actual storage area address of the data storage area. Accordingly, the second check factor calculated based on the storage area address and the basic attribute information must be consistent with the first check factor. Therefore, it can be seen that the target data will only be retrieved from the data storage area when the first check factor and the second check factor are the same. This can reduce the possibility of data access errors or illegal acquisition of data from other applications due to illegal modification of the storage area identification information in the reference variable by the application, thereby improving the reliability and security of data access.

[0123] It will be appreciated that the embodiment of FIG1 illustrates an example in which the first check factor is calculated based on the storage area address corresponding to the application's data storage area and basic attribute information. However, it will be appreciated that in actual applications, since the storage area address corresponding to the data storage area is fixed, calculating the first check factor based solely on the storage area address of the application's data storage area is also applicable to this embodiment.

[0124] On this basis, after obtaining the data access indication, the present application can determine the storage area address of the data storage area corresponding to the application based only on the storage area identification information recorded in the first variable data of the reference variable, and calculate the second check factor based on the storage area address.

[0125] It is understandable that if the application does not illegally modify the storage area identification information of the data storage area in the reference variable during operation, then after the application initiates a data access instruction carrying the reference variable, the storage area address determined based on the storage area identification information in the variable data of the reference variable is the actual storage area address of the data storage area. Accordingly, the second check factor calculated based on the storage area address must be consistent with the first check factor. Based on this, the target data will only be obtained from the data storage area when the first check factor and the second check factor are the same. This can also reduce the possibility of data access errors or illegal acquisition of data from other applications due to the application illegally modifying the storage area identification information in the reference variable, thereby improving the reliability and security of data access.

[0126] In this application, the first check factor and the reference variable can be associated in a variety of ways, without limitation. The following two possible cases are used as examples:

[0127] In the first possible scenario, the present application may record the first check factor in the variable data of the reference variable, for example, by setting 6 consecutive digits or other number of digits in the reference variable to record the first check factor. Accordingly, the present application may obtain the first check factor from the first variable data of the reference variable.

[0128] In the second possible scenario, the first check factor can also be stored in an attribute storage area within the data storage area corresponding to the application. As previously described, the attribute storage area is a storage area within the data storage area used to store basic attribute information. Accordingly, the application can obtain the first check factor associated with the reference variable from the attribute storage area within the data storage area.

[0129] In the first possible scenario, the first check factor needs to occupy the number of bits of the reference variable, which may result in a relatively small number of data storage areas for different applications that can be represented by the reference variable. In the second possible scenario, the first check factor does not need to occupy the number of bits of the reference variable, allowing the reference variable to be used to represent data storage areas for more different applications.

[0130] In practical applications, this application can select any of the above possible situations to record the first check factor in combination with the actual requirements of the operating system based on the WebAssembly virtual machine.

[0131] In one implementation, the present application may also determine which of the above two possible situations to select for recording the first verification factor based on the different sizes of the data storage areas requested by the application.

[0132] For ease of understanding, the following first introduces the process of allocating data storage areas for applications and constructing variable data for reference variables by the operating system based on the WebAssembly virtual machine in this application.

[0133] As shown in Figure 2, it shows a schematic diagram of an implementation process of allocating data storage areas for applications and constructing variable data for reference variables in an embodiment of the present application. The method of this embodiment may include:

[0134] S201: Obtain a storage area application initiated by an application, where the storage area application is used to apply for allocating storage space of a target storage capacity for the application.

[0135] For example, an application initiates a storage area request to the operating system based on the WebAssembly virtual machine by calling a specified interface provided by the operating system based on the WebAssembly virtual machine.

[0136] The target storage capacity is the size of the storage space that the application program requests to be allocated, for example, the target storage capacity can be 6K, 12K, or 20K, etc., without limitation.

[0137] S202: Create a data storage area for the application based on the target storage capacity, and determine a storage area type identifier corresponding to the data storage area.

[0138] It is understandable that in a running system based on a WebAssembly virtual machine, an embedded operating system based on a WebAssembly virtual machine can determine the data storage area that can be allocated to the application from the total storage space of the running system based on a storage area request initiated by the application.

[0139] The data storage area can be divided into an attribute storage area and a data body storage area. The attribute storage area records basic attribute information associated with the data storage area and the application. For example, basic attribute information may include: the target storage capacity of the data storage area, information about the application to which the data storage area belongs, a randomly generated random factor, and the type of data used by the data storage area to store data generated by the application.

[0140] The storage area type identifier is used to identify the category to which the storage capacity of the data storage area belongs. Specifically, data storage areas are divided into two types: a first storage area type, which indicates that the storage capacity of the data storage area is not less than a set threshold; and a second storage area type, which indicates that the storage capacity of the data storage area is less than a set threshold.

[0141] The threshold value can be set as needed. For example, considering that the largest data storage area requested by the application in the running system is 8K, the threshold value can be set to 8K.

[0142] Accordingly, the storage area type identifier may include: a first type identifier corresponding to the first storage area type, and a second type identifier corresponding to the second storage area type. Based on this, it can be seen that if the target storage capacity is not less than the set threshold, the storage area type identifier corresponding to the data storage area of ​​the application is the first type identifier; if the target storage capacity is less than the set threshold, the storage area type identifier of the data storage area is the second type identifier.

[0143] S203: Determine storage area identification information of the data storage area based on the storage area address of the data storage area.

[0144] It is understandable that using storage area identification information to identify the storage area address of the data storage area in the reference variable (i.e., the variable data of the reference variable) instead of directly using the storage area address can improve the security of the storage area address corresponding to the data storage area of ​​each application.

[0145] As previously described, the storage area identification information can be the address index of the storage area address of the data storage area in the address storage table; or it can be the offset information corresponding to the storage area address of the data storage area, and the offset information is used to represent the relative offset address corresponding to the storage area address of the data storage area.

[0146] In one possible implementation, if the target storage capacity is not less than a set threshold, the storage area address of the data storage area is stored in an address storage table, the address index of the storage area address in the address storage table is determined, and the address index is used as the storage area identification information of the data storage area corresponding to the application.

[0147] If the target storage capacity is less than the set threshold, offset information corresponding to the storage area address of the data storage area is determined, and the offset information is used as storage area identification information of the data storage area.

[0148] S204: Calculate a first check factor based on the storage area address and basic attribute information of the data storage area.

[0149] The specific process of calculating the first check factor is as described above and will not be repeated here.

[0150] In an optional manner, the first check factor may be calculated based on the storage area address of the data storage area, the basic attribute information, and the storage area type identifier. It is understood that when the first check factor is calculated in this manner, during the data access phase, the second check factor may be calculated based on the basic attribute information, the storage area address, and the storage area type identifier.

[0151] Of course, the present application may also combine the various methods for calculating the first check factor mentioned in this embodiment to comprehensively calculate the first check factor. For example, the first check factor may be calculated based on the storage area address, basic attribute information, storage area type identifier, and storage area identification information of the data storage area. Correspondingly, in a subsequent data access phase, the second check factor may be calculated based on the storage area address, basic attribute information, storage area type identifier, and storage area identification information of the data storage area.

[0152] S205: If the target storage capacity is not less than the set threshold, construct second variable data including a storage area type identifier, a first check factor, and storage area identification information for the reference variable of the application.

[0153] S206: If the target storage capacity is less than the set threshold, construct third variable data including storage area type identification and storage area identification information for the reference variable of the application, and store the first check factor in the attribute storage area in the data storage area.

[0154] It's understandable that if the data storage area requested by an application has a larger capacity, the number of data storage areas that can be allocated to the application from the total system storage space will be relatively small. For example, for ease of understanding, assuming the total system storage space is 6400KB, then if each application requests a 32KB data storage area, then the total storage space can only allocate data storage areas for 200 applications. If each application requests an 8KB data storage area, then the total storage space can allocate data storage areas for 800 applications.

[0155] It is understandable that if the data storage area requested by an application has a larger storage capacity, fewer data storage areas can be divided based on the total storage space. Therefore, to distinguish the data storage areas of each application, the number of bits required in the reference variable for the storage area identification information will be relatively smaller. Conversely, if the data storage area requested by an application has a smaller capacity, more data storage areas can be divided based on the total storage space. Therefore, to distinguish the data storage areas of each application, the number of bits required in the reference variable for the storage area identification information will be relatively larger.

[0156] It is understandable that since the number of bits of the reference variable is fixed and limited, the number of bits in the reference variable that can be used to represent the storage area identification information of the data storage area is also relatively limited. Based on this, if the storage capacity of the data storage area requested by the application is small, resulting in a large number of bits required for the data storage area, that is, when the target storage capacity is less than a set threshold, the application may not include the first check factor in the variable data of the reference variable, but instead store the first check factor in the attribute storage area of ​​the data storage area of ​​the application.

[0157] Correspondingly, if the target storage capacity is not less than the set threshold, then considering that the number of bits used to represent the storage area identification information in the reference variable is relatively small, the first check factor can be included in the variable data of the reference variable.

[0158] There are many possible composition structures of the referenced variables in this application, and there is no limitation on this.

[0159] It can be understood that after constructing the second variable data or third variable data of the reference variable, the operating system can send the second variable data or third variable data of the reference variable to the application, so that the application can assign a value to the reference variable in the application based on the second variable data or third variable data of the reference variable.

[0160] Based on this embodiment, after the operating system obtains the data access instruction of the application, the operating system obtains the first variable data of the reference variable from the data access instruction, and then can first obtain the storage area type identifier in the first variable data. As described above, the storage area type identifier in the first variable data of the reference variable can be a first storage type identifier or a second storage type identifier. The first type identifier indicates that the storage capacity of the data storage area corresponding to the application is not less than a set threshold, and the second type identifier indicates that the storage capacity of the data storage area is less than the set threshold.

[0161] Accordingly, if the storage area type identifier corresponding to the application is the first type identifier, the first check factor can be obtained from the first variable data of the reference variable. If the storage area type identifier corresponding to the application is the second type identifier, the first check factor associated with the reference variable can be obtained from the attribute storage area of ​​the data storage area.

[0162] It is understandable that when the storage area types corresponding to the data storage area of ​​the application are different, the storage area identification information determined based on the storage area address corresponding to the data storage area of ​​the application may also have different possibilities.

[0163] As previously described, in the process of constructing variable data for a reference variable in an application, if the target storage capacity of the data storage area is not less than a set threshold, the storage area identification information is the index address. If the target storage capacity is less than the set threshold, the storage area identification information is the offset information.

[0164] Accordingly, during the data access phase, if the storage area type identifier obtained from the first variable data of the reference variable is the first type identifier, the address index recorded in the first variable data of the reference variable can be obtained, and the storage area address of the data storage area corresponding to the application can be determined based on the address index. If the storage area type identifier is the second type identifier, the offset information recorded in the first variable data of the reference variable is obtained, and the storage area address of the data storage area corresponding to the application can be determined based on the offset information.

[0165] The following is a detailed description of this situation.

[0166] To facilitate understanding, the possible composition structures of the referenced variables in this application are first described.

[0167] The total number of bits in a reference variable is fixed, but the specific number of bits can be set as needed. Typically, a reference variable is 4 bytes. For ease of explanation, the following example assumes a reference variable is 4 bytes.

[0168] In a possible implementation, as shown in FIG3 , a schematic diagram of a composition structure of reference variables is shown.

[0169] In Figure 3, the reference variables are divided into three parts.

[0170] Among them, the first part is the reference type area in Figure 3, specifically the highest bit of the reference variable, that is, bit 31, which is used to identify the variable category of the reference variable. In this application, bit 31 is used to record the characterization that the reference variable is used to represent a variable related to the data storage area of ​​the application.

[0171] The second part is the offset range area, specifically the 0th to 15th bits of the reference variable, which is used to record the offset range information of the reference variable that can be modified. The offset range information is up to 64K.

[0172] The offset range information belongs to the address range between the start address and the end address of the data storage area of ​​the application program. The application program can identify the data offset addresses of different data in the data storage area by modifying the specific value of the offset range information.

[0173] The third part is the address area, specifically the 16th to 30th bits of the reference variable, which is used to record the address information of the data storage area corresponding to the application associated with the reference variable, such as the storage area identification information mentioned above.

[0174] For example, consider the case where the storage area identification information is an address index. The total storage space in a WebAssembly virtual machine-based operating system is limited, meaning the addressable range is limited. Within this limited storage space, the addresses of the storage space can be recorded in an address storage table. Accordingly, bits 16 through 30 of the reference variable can be used to record the index address of the data storage area in the address storage table. For example, this index address is a sequence number in the address storage table.

[0175] On this basis, the index addresses of 32767 different data storage areas can be represented by the 16th to 30th bits.

[0176] Of course, the address information of 32,767 data storage areas may not be able to meet the data storage needs of all applications in the operating system based on the WebAssembly virtual machine. Based on this, the application can also appropriately adjust the number of bits occupied by the storage area identification information (such as address index) and offset range information in the reference variable based on actual application scenarios.

[0177] Considering that reference variables may be modified during the running of the application, in order to improve the security of data access, this application can use reference variables of different structural forms according to the size of the data storage area applied for by the application.

[0178] If the target storage capacity of the data storage area requested by the application is not less than a set threshold (eg, 8K), the present application may adopt the first reference variable composition structure solution.

[0179] Specifically, based on Figure 3, a check factor needs to be added to the reference variable. Therefore, the number of bits in the address area of ​​the reference variable needs to be adjusted, and a check factor area needs to be added. Figure 4 shows a schematic diagram of a composition structure of a reference variable applicable to the first storage area type in this application, that is, a schematic diagram of the data composition structure of the first reference variable.

[0180] As can be seen from Figure 4, the reference variables are divided into four parts:

[0181] The 31st bit of the reference variable is the storage type area. The storage type area is used to identify the storage area type identifier corresponding to the data storage area of ​​the application associated with the reference variable. In this application, in order to identify the data storage area corresponding to the reference variable as the first storage area type, the value of the 31st bit is a target value, such as 1. Accordingly, when the value of the 31st bit in the reference variable is 1, the storage area type identifier in the reference variable is determined to be the first type identifier.

[0182] Bits 0 to 15 of the reference variable are still used as a 64K offset range area for recording the offset range information of the data in the data storage area.

[0183] The 16th to 22nd bits of the reference variable are the index area, which is used to record the address index of the data storage area.

[0184] The 23rd to 30th bits of the reference variable are the check factor area, which is used to record the first check factor generated for the data storage area.

[0185] In the reference variable of Figure 4 , the total number of index bits is 7, which can represent 256 different index addresses. The number of data storage areas that can be used to identify an application is relatively small. As previously mentioned, given a fixed total system storage space, the number of data storage areas that can be allocated with larger capacity is also relatively small. Therefore, the reference variable structure of Figure 4 is suitable for representing the address information of a data storage area whose target storage capacity is not less than a set threshold.

[0186] If the target storage capacity of the data storage area requested by the application is less than a set threshold (eg, 8K), the second reference variable composition structure solution may be adopted.

[0187] Specifically, in order to be able to represent the data storage area of ​​more applications through the address area of ​​the reference variable, based on Figure 3, the present application can reduce the number of bits occupied by the offset range area and increase the number of bits occupied by the address area used to record the address information of the data storage area, as shown in Figure 5. A data composition structure diagram of a reference variable suitable for the second storage area type, that is, a data composition structure diagram of the second reference variable.

[0188] As can be seen from Figure 5:

[0189] Bits 31 and 30 of the reference variable serve together as the storage type area. For example, in Figure 5 , bit 31 is storage type area 1, and bit 30 is storage type area 2. The storage type area is used to identify the storage area type identifier corresponding to the data storage area of ​​the application associated with the reference variable. The value of bit 31 of the second reference variable is different from the value of bit 31 of the first reference variable.

[0190] At the same time, in this application, the storage type areas of the first reference variable and the second reference variable can also be reused as the reference type area.

[0191] For example, in the present application, when the value of the 31st bit of the first reference variable is set to 1, the value of the 31st bit of the second reference variable can be set to 0, and at the same time, the value of the 30th bit of the second reference variable is set to 1. Based on this, if the operating system recognizes that the value of the 31st bit of the reference variable is 1, it determines that the storage area type identifier in the reference variable is the first type identifier, and can confirm that the reference variable belongs to a reference variable that identifies a data storage area.

[0192] If it is determined that the 31st bit of the reference variable is 0, the 30th bit of the reference variable can be identified. If the value of the 30th bit is 1, it is determined that the storage area type identifier in the reference variable is the second type identifier, and it can be confirmed that the reference variable is a reference variable that identifies a data storage area. If the value of the 30th bit in the reference variable is 0, it is determined that it is not a reference variable used to identify a data storage area.

[0193] The 0th to 12th bits of the reference variable are an 8K offset range area, which is used to record the data offset address of the data in the data storage area relative to the data storage area.

[0194] The 13th to 29th bits of the reference variable are the recording area of ​​the storage area offset information. This part can record the offset information corresponding to the data storage area of ​​the application. The offset information is used to represent the relative offset address corresponding to the storage area address of the data storage area.

[0195] Furthermore, in order to enable bits 13 to 29 to be used to distinguish the data storage areas of more applications, bits 16 to 29 in this application can be used to record the first offset information, while bits 13 to 15 are used to record the second offset information.

[0196] As previously mentioned, the first offset information is the remainder obtained by dividing the relative offset address corresponding to the storage area address of the data storage area by the target number of bytes. For example, if the target number of bytes is 64KB, then bits 13 to 29 of the reference variable actually record the relative offset address of the data storage area within the 64KB.

[0197] The second offset information is the quotient of the relative offset address of the data storage area divided by the target number of bytes, that is, how many complete 64K offsets there are in the relative offset address of the data storage area.

[0198] In order to avoid the check factor occupying the position of the reference variable, which would reduce the number of data storage areas that can be represented by the reference variable in Figure 5, in the data composition structure scheme of the second reference variable shown in Figure 5, the reference variable does not include the first check factor.

[0199] The first check factor may be stored in an attribute storage area in the data storage area.

[0200] In combination with the above two structural schemes of reference variables, another implementation method of allocating data storage area and constructing variable data of reference variables in the application of this application is described below.

[0201] FIG6 shows another implementation flow diagram of an application allocating data storage areas and constructing reference variables in an embodiment of the present application. This embodiment is applied to an operating system based on a WebAssembly virtual machine. This embodiment may include:

[0202] S601: Obtain a storage area application initiated by an application.

[0203] The storage area application is used to apply for storage space with a target storage capacity allocated to the application.

[0204] S602: If the target storage capacity is not less than the set threshold, create a data storage area for the application program, and determine that the storage area type identifier corresponding to the data storage area is a first type identifier.

[0205] For example, in the data composition structure of the reference variable shown in FIG. 4 and FIG. 5 , the first type identifier may be represented as 1, and the second type identifier may be represented as 01.

[0206] The attribute storage area of ​​the data storage area stores basic attribute information, which is generated based on the attributes of the data storage area and the attributes of the application after the operating system determines the data storage area that can be allocated to the application.

[0207] For example, basic attribute information may include: the size of the data storage area (i.e., the target storage capacity), the name or other identification information of the application to which the data storage area belongs, a randomly generated random factor, and the data type used by the data storage area to store data generated by the application.

[0208] S603: Store the storage area address of the data storage area into an address storage table, and determine the address index of the storage area address in the address storage table.

[0209] The address index is used to indicate the storage location of the storage area address of the data storage area in the address storage table. For example, the address index may be the serial number of the storage area address of the data storage area in the address storage table.

[0210] In an optional embodiment, before storing the storage area address of the data storage area in the address storage table, it is further possible to detect whether there is a free position in the address storage table. If there is no free position in the address storage table, the data storage area cannot be allocated to the application, and an indication indicating the data storage area allocation failure can be returned to the application. If there is a free position in the address storage table, the storage area address can be recorded in the address storage table.

[0211] S604: Calculate a first check factor based on the storage area address of the data storage area, basic attribute information recorded in the data storage area, the address index, and the first type identifier.

[0212] For example, a checksum algorithm such as a CRC algorithm is used to calculate a checksum based on the storage area address, basic attribute information, the address index, and the first type identifier of the data storage area to obtain a first check factor.

[0213] It is understood that in this embodiment, the calculation of the first check factor is described as an example. However, in actual applications, the first check factor can also be calculated based on the storage area address of the data storage area, basic attribute information, and the first type identifier.

[0214] Similarly, calculating the first check factor based on the storage area address of the data storage area and the basic attribute information, or calculating the first check factor based on the storage area address of the data storage area, basic attribute information and address index, is also applicable to this embodiment and is not limited to this.

[0215] S605 , constructing second variable data including a first type identifier, a first check factor, and an address index for the reference variable of the application, and sending the second variable data of the reference variable to the application.

[0216] For example, taking the reference variable as 4-byte data as an example, the data composition structure of the constructed second variable data of the reference variable can be shown in Figure 4, which will not be repeated here.

[0217] It can be understood that in this embodiment, the first verification factor is associated with the storage area address. Moreover, since the application cannot usually obtain the storage area address, even if the application can obtain the storage area address, the application cannot obtain information such as the random factor in the basic attribute information, thereby reducing the possibility of the first verification factor being cracked or arbitrarily forged.

[0218] In addition, to further enhance the security of the first check factor, the present application also incorporates the first type identifier and address index when calculating the first check factor, thereby reducing the risk of being easily cracked due to the small number of parameters used in calculating the first check factor. Based on this, after the reference variable is sent to the application, the application can modify the first check factor based on the corresponding information, reducing the likelihood of forging the first check factor.

[0219] S606: If the target storage capacity is less than the set threshold, create a data storage area for the application program, and determine that the storage area type identifier corresponding to the data storage area is a second type identifier.

[0220] S607: Determine the relative offset address of the storage area address of the data storage area relative to the start address of the total space.

[0221] As mentioned above, the total space starting address is the starting address of the total storage space of the running system.

[0222] S608: Determine a quotient and a remainder obtained by dividing the relative offset address by the target number of bytes, determine the remainder as first offset information, and determine the quotient as second offset information.

[0223] For example, the target number of bytes is 64K, but it can also be other values ​​without limitation.

[0224] S609: Calculate a first check factor based on the storage area address of the data storage area, the basic attribute information recorded in the data storage area, the first offset information, the second offset information, and the second type identifier.

[0225] It can be understood that, when the target storage capacity of the data storage area is less than the set threshold, step S609 is explained as an example of an implementation method of calculating the first check factor. In actual applications, the first check factor is calculated based on the storage area address and basic attribute information of the data storage area; or the first check factor is calculated based on the storage area address, basic attribute information and second type identification information; or the first check factor is calculated based on the storage area address, basic attribute information, first offset information and second offset information, which is also applicable to this embodiment.

[0226] In this embodiment, the offset information includes the first offset information and the second offset information as an example. For the case where the relative offset address corresponding to the data storage area is directly used as the offset information, it is only necessary to calculate the first check factor based on the storage area address, the basic attribute information and the relative offset address (i.e., one type of offset information). Alternatively, the first check factor can be calculated based on the storage area address, the basic attribute information, the relative offset address and the second type identifier. These two methods are also applicable to this embodiment and will not be described in detail.

[0227] S610, constructing third variable data including the second type identifier, the first offset information and the second offset information for the reference variable of the application, storing the first check factor in the attribute storage area in the data storage area, and sending the third variable data of the reference variable to the application.

[0228] For example, taking the reference variable as 4-byte data, the data composition structure of the third variable data of the reference variable constructed in step S610 can be seen in FIG5 .

[0229] As shown in Figure 5 , the second type identifier can be recorded in bits 31 and 30 of the reference variable, the first offset information can be recorded in bits 16 to 29 of the reference variable, and the second offset information can be recorded in bits 13 to 15 of the reference variable, so that bits 13 to 29 constitute the storage area offset information. The offset range of the reference variable belongs to the address range that can be modified by the application, and this application does not impose any restrictions on this.

[0230] Based on FIG6 , an implementation of the data access method of the present application is introduced.

[0231] FIG7 shows another flow chart of a data access method provided in an embodiment of the present application, which is applied to an operating system based on a WebAssembly virtual machine. The method of this embodiment may include:

[0232] S701: Obtain a data access instruction initiated by an application.

[0233] The data access instruction carries first variable data of a reference variable, and the first variable data of the reference variable is used to indicate the data address of the target data to be accessed. For example, the first variable data of the reference variable includes a data offset address corresponding to the target data to be accessed.

[0234] It can be understood that the first variable data of the reference variable sent by the application is different from the second variable data or the third variable data of the reference variable sent to the application by the previous running system. For example, the offset range area in the first variable data of the reference variable can record the data offset address corresponding to the target data to be accessed, while the offset range area in the reference variable sent to the application by the previous running system can be a default value.

[0235] S702: Obtain a storage area type identifier in the first variable data of the reference variable.

[0236] S703: If the storage area type identifier is the first type identifier, obtain a first check factor and an address index from the first variable data of the reference variable.

[0237] For example, in the data structure of the reference variable shown in FIG4 , if bit 31 of the reference variable is 1 (of course, it can also be set to other target values ​​based on actual needs), the storage area type identifier of the application's data storage area is determined to be the first type identifier. Accordingly, the first check factor can be obtained from bits 23 to 30 of the reference variable, and the address index can be obtained from bits 16 to 22.

[0238] S704: Determine a storage area address of a data storage area corresponding to the application based on the address index.

[0239] For example, based on the address index, the storage area address corresponding to the address index is searched from the address storage table to obtain the storage area address of the data storage area.

[0240] S705: Based on the storage area address, obtain basic attribute information from the data storage area of ​​the application.

[0241] S706: Calculate a second check factor based on the storage area address, basic attribute information, the address index, and the first type identifier of the data storage area.

[0242] For example, based on the storage area address, basic attribute information, the address index and the first type identifier, a checksum calculation algorithm such as a CRC algorithm is used to calculate the second check factor.

[0243] It is understood that step S706 is described as an example of an implementation method for calculating the second check factor when the storage area type identifier is the first type identifier. However, if the first check factor is calculated based on the storage address and basic attribute information of the data storage area when the storage area type identifier is the first type identifier, then the present application can also calculate the second check factor based on the storage area address and basic attribute information of the data storage area.

[0244] Similarly, if the first check factor is calculated based on the storage area address, basic attribute information, and the first type identifier, then the second check factor can be calculated based on the storage area address, basic attributes, and the first type identifier. If the first check factor is calculated based on the storage area address, basic attribute information, and the address index, then the second check factor can also be calculated based on the storage area address, basic attribute information, and the address index.

[0245] S707: If the storage area type identifier is the second type identifier, obtain the first offset information and the second offset information recorded in the first variable data of the reference variable.

[0246] For example, according to the data composition structure of the reference variable shown in FIG5 , after determining the number of bits each of the first offset information and the second offset information occupies in the reference variable, the first offset information and the second offset information can be obtained from the corresponding bits.

[0247] S708 : Determine a relative offset address corresponding to the data storage area based on the first offset information and the second offset information.

[0248] For example, the second offset information is multiplied by the target number of bytes and added to the first offset information to obtain the relative offset address.

[0249] The relative offset address is a relative offset address of the storage area address of the data storage area relative to the starting address of the total space, and the starting address of the total space is the starting address of the total storage space of the running system.

[0250] It can be understood that in this embodiment, the first offset information and the second offset information are recorded in the reference variable as an example. It can be understood that if the offset information such as the relative offset address is recorded in the reference variable, then the offset information such as the relative offset address can be directly obtained from the reference variable.

[0251] S709: Determine the storage area address of the data storage area based on the relative offset address.

[0252] For example, based on the relative offset address and the starting address of the total storage space of the operating system, the storage area address of the data storage area can be determined.

[0253] S710 : Based on the storage area address of the data storage area, obtain basic attribute information and a first check factor from the data storage area.

[0254] S711 : Calculate a second check factor based on the storage area address, basic attribute information, first offset information, second offset information, and the second type identifier of the data storage area.

[0255] It is understood that step S711 is described as an example of an implementation method for calculating the second check factor when the storage type identifier is the second type identifier. It is understood that when the storage type identifier is the second type identifier, the first check factor can also be calculated based on the storage area address of the data storage area and the basic attribute information. Correspondingly, the second check factor can also be calculated based on the storage area address of the data storage area and the basic attribute information.

[0256] Similarly, the second check factor may be calculated based on the storage area address, basic attribute information, and second type identifier of the data storage area; or, the second check factor may be calculated based on the storage area address, basic attribute information, first offset information, and second offset information.

[0257] Of course, if the first offset information and the second offset information are replaced with offset information such as a relative offset address, in step S711, the second check factor can also be calculated based on the storage area address, basic attribute information, offset information (such as a relative offset address) and the second type identifier; or, the second check factor can be calculated based on the storage area address, basic attribute information and offset information (such as a relative offset address).

[0258] S712: If the first check factor is the same as the second check factor, obtain the target data from the data storage area based on the first variable data of the reference variable and the storage area address.

[0259] For example, based on the data offset address in the first variable data of the reference variable and the storage area address, the data storage address of the target data in the data storage area is determined, and the target data is obtained from the data storage area based on the data storage address.

[0260] It is understandable that after obtaining the target data, the target data may also be sent to the application.

[0261] Corresponding to a data access method provided in an embodiment of the present application, the present application also provides a data access device.

[0262] As shown in FIG8 , it shows a schematic diagram of the structure of a data access device provided in an embodiment of the present application. The device of this embodiment is applied to an operating system based on a WebAssembly virtual machine, and the device includes:

[0263] An indication obtaining unit 801 is configured to obtain a data access indication initiated by an application program, wherein the data access indication carries first variable data of a reference variable, and the first variable data of the reference variable is used to indicate a data address of target data to be accessed;

[0264] An address determining unit 802 is configured to determine a storage area address of a data storage area corresponding to the application based on storage area identification information recorded in the first variable data of the reference variable, where the storage area identification information is used to identify the data storage area corresponding to the application;

[0265] A factor acquisition unit 803 is configured to acquire a first check factor associated with the first variable data of the reference variable, the first check factor being calculated by the running system based on a storage area address of the data storage area when generating the variable data of the reference variable for the application program;

[0266] A first factor calculation unit 804 is configured to calculate a second check factor based on the storage area address;

[0267] The data acquisition unit 805 is configured to acquire the target data from the data storage area based on the first variable data of the reference variable and the storage area address if the first check factor is the same as the second check factor.

[0268] In a possible implementation, the data access device may further include: an attribute acquisition unit configured to, after the address determination unit determines the storage area address of the data storage area corresponding to the application, acquire basic attribute information recorded in the data storage area based on the storage area address, the basic attribute information including attribute information associated with the data storage area and the application;

[0269] Accordingly, the first check factor obtained by the factor acquisition unit is calculated based on the storage area address and basic attribute information of the data storage area;

[0270] The first factor calculation unit is specifically configured to calculate a second check factor based on the basic attribute information recorded in the data storage area and the storage area address.

[0271] In a possible implementation, the factor acquisition unit includes at least one of the following:

[0272] A first factor obtaining unit, configured to obtain a first check factor from the first variable data of the reference variable;

[0273] The second factor acquisition unit is configured to acquire a first check factor associated with the reference variable from an attribute storage area in the data storage area, where the attribute storage area is a storage area for storing the basic attribute information.

[0274] In yet another possible implementation, the apparatus further includes: a type obtaining unit configured to obtain, after the indication obtaining unit obtains the data access indication initiated by the application, a storage area type identifier in the first variable data of the reference variable, the storage area type identifier being one of a first type identifier and a second type identifier, the first type identifier indicating that a storage capacity of a data storage area corresponding to the application is not less than a set threshold, and the second type identifier indicating that the storage capacity of the data storage area is less than the set threshold;

[0275] Accordingly, the first check factor is calculated based on the storage area address, basic attribute information and storage area type identifier of the data storage area;

[0276] The first factor calculation unit is specifically configured to calculate a second check factor based on the basic attribute information recorded in the data storage area, the storage area address, and the storage area type identifier.

[0277] In another possible implementation, the first factor acquisition unit is specifically configured to acquire a first check factor from first variable data of the reference variable if the storage area type identifier is the first type identifier;

[0278] The second factor acquisition unit is specifically configured to acquire the first verification factor associated with the reference variable from the attribute storage area of ​​the data storage area if the storage area type identifier is the second type identifier.

[0279] In yet another possible implementation, the address determining unit includes:

[0280] a first address determining unit configured to, if the storage area type identifier is the first type identifier, obtain an address index recorded in the first variable data of the reference variable, and determine a storage area address of the data storage area corresponding to the application based on the address index, wherein the address index is used to indicate a storage location of the storage area address of the data storage area in the address storage table;

[0281] The second address determination unit is used to obtain the offset information recorded in the first variable data of the reference variable if the storage area type identifier is the second type identifier, and determine the storage area address of the data storage area based on the offset information, and the offset information is used to represent the relative offset address of the storage area address of the data storage area relative to the starting address of the total space, and the starting address of the total space is the starting address of the total storage space of the running system.

[0282] In yet another possible implementation, the second address determining unit includes:

[0283] an offset obtaining subunit, configured to obtain, if the storage area type identifier is the second type identifier, first offset information and second offset information recorded in the first variable data of the reference variable, the first offset information being a remainder obtained by dividing a relative offset address corresponding to a storage area address of the data storage area by a target number of bytes, and the second offset information being a quotient obtained by dividing the relative offset address by the target number of bytes;

[0284] an offset determining subunit, configured to determine the relative offset address corresponding to the data storage area based on the first offset information and the second offset information;

[0285] The address determining subunit is configured to determine a storage area address of the data storage area based on the relative offset address.

[0286] In yet another possible implementation, the first factor calculation unit is specifically configured to calculate a second check factor based on the data storage area identifier, basic attribute information, and storage area address.

[0287] In another possible implementation, the first variable data of the reference variable obtained by the instruction obtaining unit of the device includes a data offset address of the target data in a data storage area corresponding to the application program;

[0288] The data obtaining unit is specifically configured to obtain target data from the data storage area based on the data offset address and the storage area address if the first check factor is the same as the second check factor.

[0289] In yet another possible implementation, the apparatus further includes:

[0290] an application obtaining unit, configured to obtain a storage area application initiated by the application before the indication obtaining unit obtains the data access indication initiated by the application, the storage area application being used to apply for allocating storage space of a target storage capacity for the application;

[0291] a storage area determining unit, configured to create a data storage area for the application based on the target storage capacity, and determine a storage area type identifier corresponding to the data storage area, wherein an attribute storage area of ​​the data storage area records basic attribute information associated with the data storage area and the application, wherein if the target storage capacity is not less than a set threshold, the storage area type identifier is a first type identifier, and if the target storage capacity is less than the set threshold, the storage area type identifier is a second type identifier;

[0292] an identification determining unit, configured to determine storage area identification information of the data storage area based on a storage area address of the data storage area;

[0293] a second factor calculation unit, configured to calculate a first check factor based on the storage area address and basic attribute information;

[0294] A first variable construction unit is configured to construct, for a reference variable of the application program, second variable data including a storage area type identifier, a first check factor, and storage area identification information if the target storage capacity is not less than a set threshold;

[0295] The second variable construction unit is used to construct third variable data including storage area type identification and storage area identification information for the reference variable of the application if the target storage capacity is less than the set threshold, and store the first check factor in the attribute storage area in the data storage area.

[0296] In yet another possible implementation, the identification determination unit includes:

[0297] an index determining unit, configured to, if the target storage capacity is not less than a set threshold, store the storage area address of the data storage area into an address storage table, and determine an address index of the storage area address in the address storage table, the address index being used to indicate a storage position of the storage area address in the address storage table;

[0298] an offset determining unit, configured to determine, if the target storage capacity is less than a set threshold, offset information corresponding to the storage area address of the data storage area, the offset information being used to represent a relative offset address of the storage area address of the data storage area relative to a starting address of a total space, the starting address of the total space being a starting address of a total storage space of the running system;

[0299] Accordingly, the first variable construction unit is specifically configured to construct, for the reference variable of the application, second variable data including a storage area type identifier, a first check factor, and an address index if the target storage capacity is not less than a set threshold;

[0300] The second variable construction unit is specifically configured to construct third variable data including a storage area type identifier and offset information for a reference variable of the application program if the target storage capacity is less than a set threshold.

[0301] In yet another possible implementation, the offset determining unit includes:

[0302] An address determination subunit, configured to determine a relative offset address of a storage area address of the data storage area relative to a start address of the total space if the storage capacity is less than a set threshold;

[0303] an offset splitting subunit, configured to determine a quotient and a remainder obtained by dividing the relative offset address by the target number of bytes, determine the remainder as first offset information, and determine the quotient as second offset information;

[0304] The second variable construction unit is specifically configured to construct third variable data including a storage area type identifier, first offset information, and second offset information for a reference variable of the application program if the target storage capacity is less than a set threshold.

[0305] It is understood that in this application, the terms "first," "second," "third," "fourth," and so on (if any) in the specification and claims and the above-mentioned drawings are used to distinguish similar parts, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated herein.

[0306] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. At the same time, the features described in the various embodiments in this specification can be replaced or combined with each other, so that professionals in this field can implement or use this application. For device embodiments, since they are basically similar to method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0307] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.

[0308] The above description of the disclosed embodiments will enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

[0309] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A data access method, characterized in that: Applicable to the operating system based on the WebAssembly virtual machine, including: Obtaining a data access indication initiated by an application, wherein the data access indication carries first variable data of a reference variable, wherein the first variable data of the reference variable is used to indicate a data address of target data to be accessed; Determine the storage area address of the data storage area corresponding to the application based on the storage area identification information recorded in the first variable data of the reference variable, wherein the storage area identification information is used to identify the data storage area corresponding to the application; Acquire a first check factor associated with the reference variable, where the first check factor is calculated by the running system based on a storage area address of the data storage area when generating variable data corresponding to the reference variable for the application; Calculating a second check factor based on the storage area address; If the first check factor is the same as the second check factor, the target data is obtained from the data storage area based on the first variable data of the reference variable and the storage area address.

2. The data access method according to claim 1, characterized in that: After determining the storage area address of the data storage area corresponding to the application, the method further includes: Based on the storage area address, basic attribute information recorded in the data storage area is obtained, wherein the basic attribute information includes attribute information associated with the data storage area and the application program; The first check factor is calculated based on the storage area address and basic attribute information of the data storage area; The calculating a second check factor based on the storage area address includes: A second check factor is calculated based on the basic attribute information recorded in the data storage area and the storage area address.

3. The data access method according to claim 2, characterized in that: After obtaining the data access instruction initiated by the application, it also includes: Obtaining a storage area type identifier in the first variable data of the reference variable, the storage area type identifier being one of a first type identifier and a second type identifier, the first type identifier indicating that the storage capacity of the data storage area corresponding to the application is not less than a set threshold, and the second type identifier indicating that the storage capacity of the data storage area is less than the set threshold; The first check factor is calculated based on the storage area address, basic attribute information and storage area type identifier of the data storage area; The calculating the second check factor based on the basic attribute information recorded in the data storage area and the storage area address includes: A second check factor is calculated based on the basic attribute information recorded in the data storage area, the storage area address and the storage area type identifier.

4. The data access method according to claim 3, characterized in that: The obtaining of the first check factor associated with the reference variable includes: If the storage area type identifier is a first type identifier, obtaining a first check factor from first variable data of the reference variable; If the storage area type identifier is a second type identifier, a first check factor associated with the reference variable is obtained from an attribute storage area of ​​the data storage area.

5. The data access method according to claim 3, characterized in that: The step of determining the storage area address of the data storage area corresponding to the application based on the storage area identification information recorded in the first variable data of the reference variable comprises: If the storage area type identifier is a first type identifier, obtaining an address index recorded in the first variable data of the reference variable, and determining a storage area address of the data storage area corresponding to the application based on the address index, wherein the address index is used to indicate a storage position of the storage area address of the data storage area in the address storage table; If the storage area type identifier is a second type identifier, obtain the offset information recorded in the first variable data of the reference variable, and determine the storage area address of the data storage area based on the offset information, wherein the offset information is used to characterize the relative offset address of the storage area address of the data storage area relative to the starting address of the total space, and the starting address of the total space is the starting address of the total storage space of the running system.

6. The data access method according to claim 5, characterized in that: The obtaining of the offset information recorded in the first variable data of the reference variable, and determining the storage area address of the data storage area based on the offset information, comprises: Obtaining first offset information and second offset information recorded in the first variable data of the reference variable, wherein the first offset information is a remainder obtained by dividing the relative offset address by the target number of bytes, and the second offset information is a quotient obtained by dividing the relative offset address by the target number of bytes; Determine the relative offset address corresponding to the data storage area based on the first offset information and the second offset information; A storage area address of the data storage area is determined based on the relative offset address.

7. The data access method according to claim 1, characterized in that: The first variable data of the reference variable includes: the data offset address of the target data in the data storage area corresponding to the application program; If the first check factor is the same as the second check factor, acquiring the target data from the data storage area based on the first variable data of the reference variable and the storage area address comprises: If the first check factor is the same as the second check factor, the target data is obtained from the data storage area based on the data offset address and the storage area address.

8. The data access method according to claim 3, characterized in that: Before obtaining the data access instruction initiated by the application, the method further includes: Obtaining a storage area application initiated by the application, wherein the storage area application is used to apply for allocating storage space of a target storage capacity for the application; Based on the target storage capacity, a data storage area is created for the application, and a storage area type identifier corresponding to the data storage area is determined, wherein the attribute storage area of ​​the data storage area records basic attribute information associated with the data storage area and the application, wherein if the target storage capacity is not less than a set threshold, the storage area type identifier is a first type identifier, and if the target storage capacity is less than the set threshold, the storage area type identifier is a second type identifier; Determining storage area identification information of the data storage area based on a storage area address of the data storage area; Calculating a first check factor based on the storage area address, basic attribute information, and storage area type identifier; If the target storage capacity is not less than a set threshold, constructing second variable data including the storage area type identifier, the first check factor and the storage area identification information for the reference variable of the application; If the target storage capacity is less than a set threshold, third variable data including the storage area type identifier and storage area identifier information is constructed for the reference variable of the application, and the first check factor is stored in the attribute storage area in the data storage area.

9. The data access method according to claim 8, characterized in that: The determining the storage area identification information of the data storage area based on the storage area address of the data storage area comprises: If the target storage capacity is not less than a set threshold, storing the storage area address of the data storage area into an address storage table, determining an address index of the storage area address in the address storage table, wherein the address index is used to indicate a storage position of the storage area address in the address storage table; If the target storage capacity is less than a set threshold, determine the offset information corresponding to the storage area address of the data storage area, the offset information is used to represent the relative offset address of the storage area address of the data storage area relative to the starting address of the total space, and the starting address of the total space is the starting address of the total storage space of the running system; If the target storage capacity is not less than a set threshold, constructing second variable data including the storage area type identifier, the first check factor and the storage area identification information for the reference variable of the application, comprising: If the target storage capacity is not less than a set threshold, construct second variable data including the storage area type identifier, the first check factor and the address index for the reference variable of the application; If the target storage capacity is less than a set threshold, constructing third variable data including the storage area type identifier and the storage area identifier information for the reference variable of the application program, comprising: If the target storage capacity is smaller than a set threshold, third variable data including the storage area type identifier and offset information is constructed for the reference variable of the application.

10. The data access method according to claim 9, characterized in that: If the target storage capacity is less than a set threshold, determining the offset information corresponding to the storage area address of the data storage area includes: If the storage capacity is less than a set threshold, determining a relative offset address of a storage area address of the data storage area relative to a start address of the total space; Determine a quotient and a remainder obtained by dividing the relative offset address by the target number of bytes, determine the remainder as first offset information, and determine the quotient as second offset information; If the target storage capacity is less than a set threshold, constructing third variable data including the storage area type identifier and offset information for the reference variable of the application program, comprising: If the target storage capacity is less than a set threshold, third variable data including the storage area type identifier, the first offset information and the second offset information is constructed for the reference variable of the application.

11. A data access device, characterized in that: Applied to an operating system based on a WebAssembly virtual machine, the device comprises: an indication obtaining unit, used for obtaining a data access indication initiated by an application, wherein the data access indication carries first variable data of a reference variable, and the first variable data of the reference variable is used for indicating a data address of target data to be accessed; An address determination unit, configured to determine a storage area address of a data storage area corresponding to the application based on storage area identification information recorded in the first variable data of the reference variable, wherein the storage area identification information is used to identify the data storage area corresponding to the application; a factor acquisition unit, configured to acquire a first check factor associated with the reference variable, wherein the first check factor is calculated by the operating system based on a storage area address of the data storage area when generating variable data corresponding to the reference variable for the application; A first factor calculation unit, configured to calculate a second check factor based on the storage area address; A data acquisition unit is configured to acquire the target data from the data storage area based on the first variable data of the reference variable and the storage area address if the first check factor is the same as the second check factor.

Citation Information

Patent Citations

  • Method and device for function call and terminal

    CN108897533A

  • Data processing method and device, electronic equipment and computer readable storage medium

    CN114943062A

  • Data processing method and device, computing equipment and storage medium

    CN116382785A

  • Data processing method and device

    CN116755845A

  • Data access method and device

    CN117573290A