Data access method, data access device and storage medium

By using compiler plug-ins to determine the type of data access instructions and preventing data writing during Wasm compilation, the problem that inherent data in Wasm application memory can be modified is solved, and the security and stability of the application are improved.

CN119885213APending Publication Date: 2025-04-25BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311394854.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-25
Publication Date
2025-04-25

AI Technical Summary

Technical Problem

The entire application memory of the low-level bytecode format Wasm application is readable and writable, resulting in the inherent data stored in the application memory that supports the normal function of the application can be modified, affecting the normal operation of the application.

Method used

The compiler plug-in determines the instruction type of the data access instruction during Wasm compilation, and reports an error when the data access instruction writes the instruction to the data to ensure that the inherent data is stored in read-only memory and prevents modification.

Benefits of technology

It effectively prevents the inherent data of Wasm applications from being modified, improves the security of applications, reduces the security risks of applications, and reduces the use of memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119885213A_ABST
    Figure CN119885213A_ABST
Patent Text Reader

Abstract

The invention relates to a data access method, a data access device and a storage medium. The data access method comprises the following steps: in response to a received data access instruction sent by a low-level byte code format Wasm application, determining an access address corresponding to the data access instruction; in response to the fact that the access address is in the address range corresponding to the first memory, in the Wasm compiling process, the instruction type of the data access instruction is determined through the compiler plug-in. And in response to the data access instruction being a data write-in instruction, reporting an error, and prompting that the data access process has an error. The first memory is a read-only memory and is used for storing the inherent data of the low-level byte code format Wasm application. According to the method and the device, the inherent data in the low-level byte code format Wasm application is stored in the read-only memory of a system, so that the inherent data cannot be modified, the security of the application is improved, the security risk of the application is reduced, and the use of the memory is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data interaction, and in particular to a data access method, a data access device and a storage medium. Background Art

[0002] The low-level bytecode format (Wasm, WebAssembly) is an intermediate representation that is often used to interact or transfer code between different programming languages, platforms, or execution environments. It is a representation that is closer to the underlying machine language than the source code, and contains lower-level instructions, data, and opcodes, as well as corresponding operands. WebAssembly is a low-level bytecode format for executing high-performance binary code in web browsers. It enables developers to run applications in browsers in a way that is closer to native code than traditional JavaScript.

[0003] In the related art, the entire application memory of the low-level bytecode format Wasm application is readable and writable, resulting in that the inherent data stored in the application memory that supports the normal functions of the application can be changed, affecting the normal operation of the low-level bytecode format application. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present disclosure provides a data access method, a data access device and a storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, a data access method is provided, including: in response to receiving a data access instruction issued by a low-level bytecode format Wasm application, determining an access address corresponding to the data access instruction; in response to the access address being within an address range corresponding to a first memory, during a Wasm compilation process, determining the instruction type of the data access instruction through a compiler plug-in; in response to the data access instruction being a data write instruction, reporting an error to indicate that an error has occurred in the data access process, the first memory being a read-only memory for storing inherent data of the low-level bytecode format Wasm application.

[0006] In one embodiment, the first memory is determined in the following manner: in response to receiving a data definition instruction, during the Wasm compilation process, additional attributes are added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attributes is determined as read-only data; the read-only data is stored in a custom area, and the custom area storing the read-only data is determined as the first memory.

[0007] In one implementation, the capacity of the first memory is equal to the data segment length of the read-only data.

[0008] In one embodiment, the method also includes: in response to an access address being within an address range corresponding to a first memory, during a Wasm compilation process, recording the access address through a compiler plug-in, and replacing the data access instruction with a calling function whose calling parameter is the access address, wherein the calling function is used to call inherent data within the address range corresponding to the first memory.

[0009] In one embodiment, the method further includes: in response to an access address being within an address range corresponding to the first memory and the data access instruction being a data read instruction, reading data in a memory address corresponding to the data read instruction by calling a function.

[0010] In one embodiment, reading the data in the memory address corresponding to the data read instruction by calling a function includes: in response to the access address being within the address range corresponding to the first memory, parsing the data access instruction by the compiler plug-in to determine the instruction type of the data access instruction; in response to the data access instruction being a data read instruction, returning the character value of the inherent data to be read by the data access instruction through the calling function obtained by converting the data access instruction.

[0011] According to a second aspect of an embodiment of the present disclosure, a data access device is provided, including: a determination unit, for determining an access address corresponding to the data access instruction in response to receiving a data access instruction issued by a low-level bytecode format Wasm application; a processing unit, for determining the instruction type of the data access instruction through a compiler plug-in during a Wasm compilation process in response to the access address being within an address range corresponding to a first memory, and reporting an error in response to the data access instruction being a data write instruction, indicating that an error has occurred in the data access process, wherein the first memory is a read-only memory, for storing inherent data of the low-level bytecode format Wasm application.

[0012] In one embodiment, the first memory is determined by the processing unit in the following manner: in response to receiving a data definition instruction, during the Wasm compilation process, additional attributes are added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attributes is determined as read-only data; the read-only data is stored in a custom area, and the custom area storing the read-only data is determined as the first memory.

[0013] In one implementation, the capacity of the first memory is equal to the data segment length of the read-only data.

[0014] In one embodiment, the processing unit is also used to: in response to an access address being within an address range corresponding to a first memory, during a Wasm compilation process, record the access address through a compiler plug-in, and replace the data access instruction with a calling function whose calling parameter is the access address, wherein the calling function is used to call inherent data within the address range corresponding to the first memory.

[0015] In one embodiment, the processing unit is further used for: in response to an access address being within an address range corresponding to the first memory and the data access instruction being a data read instruction, reading data in a memory address corresponding to the data read instruction by calling a function.

[0016] In one embodiment, the processing unit reads the data in the memory address corresponding to the data read instruction by calling a function in the following manner: in response to the access address being within the address range corresponding to the first memory, the data access instruction is parsed by the compiler plug-in to determine the instruction type of the data access instruction; in response to the data access instruction being a data read instruction, the calling function obtained by converting the data access instruction returns the character value of the inherent data to be read by the data access instruction.

[0017] According to a third aspect of an embodiment of the present disclosure, a data access device is provided, comprising: a processor; and a memory for storing processor executable instructions; wherein the processor is configured to: execute the data access method described in the first aspect or any one of the implementations of the first aspect.

[0018] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor, the processor is enabled to execute the data access method described in the first aspect or any one of the embodiments of the first aspect.

[0019] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: upon receiving a data access instruction issued by a low-level bytecode format Wasm application, and determining that the corresponding access address is within the address range corresponding to the read-only memory, the instruction type of the data access instruction is determined by the compiler plug-in during the Wasm compilation process. When the data access instruction is a data write instruction, an error is reported, indicating that an error has occurred in the data access process. Through the present disclosure, the inherent data in the low-level bytecode format Wasm application is stored in the system's read-only memory, so that the inherent data cannot be modified, thereby improving the security of the application, reducing the security risk of the application, and reducing the use of memory.

[0020] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0022] Figure 1 The invention is a flowchart of a data access method according to an exemplary embodiment.

[0023] Figure 2 The present invention is a flowchart showing a method for determining a first memory according to an exemplary embodiment.

[0024] Figure 3 The present invention is a flowchart of a data access method according to yet another exemplary embodiment.

[0025] Figure 4 The present invention is a flowchart of a data access method according to yet another exemplary embodiment.

[0026] Figure 5 The invention is a flowchart of a data access method according to an exemplary embodiment.

[0027] Figure 6 The invention is a block diagram of a data access device according to an exemplary embodiment.

[0028] Figure 7 It is a block diagram of a device for data access according to an exemplary embodiment. DETAILED DESCRIPTION

[0029] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.

[0030] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.

[0031] The data access method provided by the embodiment of the present disclosure is applied to a scenario in which a low-level bytecode format Wasm application accesses application memory based on data access instructions.

[0032] The data access method provided in the embodiments of the present disclosure is mainly applicable to the scenario of developing Wasm applications using static type languages ​​(e.g., C, C++, Rust, etc.). If the dynamic type language compiler can provide sufficient type information, the data access method provided in the embodiments of the present disclosure can also be applied to Wasm applications developed in dynamic type languages ​​(e.g., TypeScript, Dart, etc.).

[0033] The low-level bytecode format (WebAssembly, Wasm) is a new type of low-level language. Its goal is to become a universal compilation target for the Web platform, but it can also be used in non-Web scenarios. It is designed as a portable target, and it is designed as a portable high-performance execution format. The technical fields in which Wasm technology is located are mainly Web development, mobile development, and system programming. Wasm technology is currently in the development stage, and there are already some mature applications, such as: Google Earth, AutoCAD, Unity, etc. The development prospects of Wasm technology are very good. It can realize high-performance graphics rendering, game development, video editing and other applications on the Web platform, and can also realize high-performance graphics rendering, game development, video editing and other applications on the mobile terminal, and can also realize high-performance graphics rendering, game development, video editing and other applications in the field of system programming.

[0034] In the related art, the specification definition of the low-level bytecode format Wasm defines the application memory as follows: the memory is a byte array, and the memory is a linear byte array, the length of the memory is in pages, and the page size is 64KB. The initial size of the application memory of the low-level bytecode format Wasm application is defined by the application, but the size of the memory cannot exceed the maximum size defined by the engine. The maximum size of the application memory is defined by the engine running the application, and the engine can dynamically adjust the size of the application memory within the maximum memory size it supports according to the application's demand for memory capacity. However, the entire application memory of the low-level bytecode format Wasm application is readable and writable. It can be understood that the data stored in the application memory includes inherent data and additional data, wherein the additional data will not affect the normal operation of the low-level bytecode format Wasm application, and is the operating data generated during the operation of the low-level bytecode format Wasm application and the data added by the user based on personal needs, which can be deleted or modified. The inherent data is necessary data to support the normal operation of the low-level bytecode format Wasm application or the data that the application developer believes needs to be retained. This part of the data should be readable but not modifiable. If modified, it will affect the stability of the low-level bytecode format Wasm application, causing the low-level bytecode format Wasm application to fail to operate normally, and abnormal situations such as some functions cannot be used, flash back, etc. Therefore, in the related art, the application memory of the low-level bytecode format Wasm application is readable and writable as a whole, which will cause the inherent data stored in the application memory to change based on the data write instruction, resulting in unstable operation of the Wasm application and operational risks.

[0035] In view of this, the present disclosure proposes a data access method, which sets a read-only memory for a Wasm application in a Wasm module in advance through a compiler plug-in, and stores the inherent data of the Wasm application in the read-only memory. After receiving a data access instruction for accessing an address corresponding to the read-only memory, the compiler plug-in determines the instruction type of the data access instruction, and when it is determined to be a data write instruction, an error is reported, indicating that an abnormality has occurred in the data access process. The present disclosure ensures that the application cannot modify the inherent data, improves the security of the application, and reduces the security risk of the application.

[0036] Figure 1 FIG. 1 is a flow chart of a data access method according to an exemplary embodiment. Figure 1 As shown, the method includes step S101 to step S102.

[0037] In step S101, in response to receiving a data access instruction issued by a low-level bytecode format Wasm application, an access address corresponding to the data access instruction is determined.

[0038] In step S102, in response to the access address being within the address range corresponding to the first memory, during the Wasm compilation process, the instruction type of the data access instruction is determined by the compiler plug-in.

[0039] In step S103, in response to the data access instruction being a data write instruction, an error is reported, indicating that an error occurs in the data access process.

[0040] Among them, the first memory is a read-only memory, which is used to store the inherent data of the low-level bytecode format Wasm application.

[0041] In the disclosed embodiment, a compiler plug-in is provided in the compiler of the Wasm module, and after the Wasm module receives a data access instruction issued by a Wasm application in a low-level bytecode format, an access address range corresponding to the data access instruction is determined. When it is determined that the corresponding access address is in the address range corresponding to the read-only memory of the Wasm module, the instruction type of the data access instruction is determined by the compiler plug-in during the Wasm compilation process. When the data access instruction is a data write instruction, an error is reported, indicating that an error occurs in the data access process, and the data access process is stopped.

[0042] In the disclosed embodiment, a read-only memory is preset in the Wasm module, and the inherent data in the low-level bytecode format Wasm application is stored in the read-only memory in the Wasm module, so that the inherent data of the Wasm application cannot be modified, thereby improving the security of the application, reducing the security risk of the application and reducing the use of memory.

[0043] In this embodiment, the compiler plug-in set in the compiler of the Wasm module can be a plug-in based on different language settings, such as: gcc, llvm and clang.

[0044] It is understandable that the purpose of setting up the read-only memory in the present disclosure is to prevent the inherent data of the Wasm application from being rewritten, so the present disclosure needs to first determine the inherent data of the Wasm application, and then determine the read-only memory used to store the data based on the inherent data of the Wasm application. The following embodiment of the present disclosure describes a method for determining the read-only memory (first memory) in the Wasm module.

[0045] Figure 2 FIG. 1 is a flow chart showing a method for determining a first memory according to an exemplary embodiment. Figure 2 As shown, the method includes step S201 to step S202.

[0046] In step S201, in response to receiving a data definition instruction, during the Wasm compilation process, an additional attribute is added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attribute is determined as read-only data.

[0047] In step S202, the read-only data is stored in a custom area, and the custom area storing the read-only data is determined as a first memory.

[0048] In the disclosed embodiment, the inherent data of the Wasm application is defined as read-only data based on the data definition instruction, and then the read-only memory (first memory) in the Wasm module is determined based on the read-only data corresponding to the inherent data of the Wasm application: after receiving the data definition instruction, the data segment specified by the data definition instruction (i.e., the inherent data segment of the Wasm application) is determined. When Wasm is compiled through the compiler, an additional attribute is added to the data segment specified by the data definition instruction using a compiler plug-in, and the specified data segment is defined as read-only data through the added additional data attribute. After determining the read-only data, the read-only data is stored in a custom area (custom section) of the Wasm module, and the data segment storing the read-only data in the custom area is determined as the read-only memory (first memory) in the Wasm module.

[0049] In the disclosed embodiment, an additional attribute is added to the data segment specified by the data definition instruction (i.e., the inherent data segment of the Wasm application) to define the specified data segment as read-only data, and a read-only memory is set according to the determined read-only data. The read-only memory in the Wasm module is determined according to the inherent data of the Wasm application, so that the read-only memory capacity corresponds to the inherent data of the Wasm, and the consumption of application memory is reduced while ensuring that the inherent data of the Wasm application is not modified.

[0050] In an exemplary embodiment of the present disclosure, the first memory (read-only memory) is determined in the following manner: a compiler plug-in (e.g., a compiler plug-in based on the clang language) is created in the Wasm compiler, and the function of the compiler plug-in includes scanning all data definition instructions and setting read-only memory (i.e., the first memory) according to the data instructions: in the process of compiling the Wasm module through the Wasm compiler, after receiving the data definition instruction, the compiler determines the data segment corresponding to the data definition instruction through the compiler plug-in (i.e., the inherent data of the Wasm application), and adds an additional data attribute to the data segment, and marks the data segment as a read-only data segment of the Wasm application through the data attribute. After the compilation of the Wasm module is completed, all the inherent data of the Wasm application are stored in a custom area (custom section) of the Wasm module, and the area is named const_data_section, and the determination of the first memory is completed.

[0051] It is understandable that the setting of the read-only memory capacity needs to be the same as the data segment length of the inherent data of the Wasm application. The following embodiments of the present disclosure illustrate the first memory.

[0052] In one implementation of the disclosed embodiment, the capacity of the first memory is equal to the data segment length of the read-only data.

[0053] In the disclosed embodiment, the content of the custom area (first memory) in the Wasm module for storing the inherent data of the Wasm application is a byte array, the content of the byte array includes the content of all the inherent data segments of the Wasm application, and the length of the byte array corresponding to the first memory is the sum of the lengths of all the inherent data segments, and the content of the byte array is the concatenation of the contents of all the inherent data segments of the Wasm application.

[0054] In the disclosed embodiment, read-only memory is determined in the custom area of ​​the Wasm module according to the actual size of the inherent data of the Wasm application (total character segment length), so that the capacity of the read-only memory is the same as the size of the inherent data of the Wasm, and the inherent data of the Wasm application is stored in the read-only memory, while ensuring that the inherent data of the Wasm application is not modified, reducing the consumption of application memory.

[0055] In the embodiments of the present disclosure, in addition to setting the read-only memory according to the data definition instruction, recording the address when the access address of the data access instruction is the address corresponding to the read-only memory, and determining the instruction type of the data access instruction, the compiler plug-in can also perform conversion operations on the data access, converting the data access instruction into other forms of obtaining data. The following embodiments of the present disclosure further illustrate the above data access method.

[0056] Figure 3 FIG. 1 is a flow chart of a data access method according to another exemplary embodiment. Figure 3 As shown, the method includes step S301 to step S302.

[0057] In step S301, an access address corresponding to a data access instruction is determined.

[0058] In step S302, in response to the access address being within the address range corresponding to the first memory, during the Wasm compilation process, the access address is recorded by the compiler plug-in, and the data access instruction is replaced with a calling function whose calling parameter is the access address.

[0059] The calling function is used to call the inherent data within the address range corresponding to the first memory.

[0060] In the disclosed embodiment, when a data access instruction issued by a Wasm application is received and the corresponding access address is determined to be the address corresponding to the first memory, the memory address to be accessed by the data access instruction is recorded by the compiler plug-in while Wasm is compiled by the compiler, and the data access instruction is replaced by a calling function for reading inherent data, and the parameter corresponding to the calling function is the address corresponding to the first memory. The calling function can be named __read_const_data, and the return value of the first memory is the value of the inherent data corresponding to the data access instruction in the first memory address.

[0061] In the embodiment of the present disclosure, when a data access instruction is received and the corresponding access address is determined to be the address corresponding to the first memory, the data access instruction is converted into a call function that can only be used for data acquisition but not for data writing. As a result, the data access instruction whose access address is the address corresponding to the first memory (i.e., the address where the inherent data of the Wasm application is located) can only read the inherent data of the Wasm application in the first memory, but cannot rewrite the inherent data of the Wasm application. Through the present disclosure, the inherent data of the Wasm application in the Wasm module is prevented from being rewritten, and the normal operation of the Wasm application is guaranteed.

[0062] It is understandable that the instruction type of the data access instruction issued by the Wasm application is used to indicate the execution of data writing, in addition to the data writing instruction, and also includes a data reading instruction for indicating the execution of a read operation. The following embodiment of the present disclosure describes a method for reading data based on a data reading instruction.

[0063] Figure 4 FIG. 1 is a flow chart of a method for reading data according to an exemplary embodiment. Figure 4 As shown, the method includes step S401 to step S402.

[0064] In step S401, an access address corresponding to a data access instruction is determined, and an instruction type of the data access instruction is determined.

[0065] In step S402, in response to the access address being within the address range corresponding to the first memory and the data access instruction being a data read instruction, data in the memory address corresponding to the data read instruction is read by calling a function.

[0066] In the disclosed embodiment, the inherent data stored in the first memory is read-only data, supports normal reading, and reading the inherent data in the first memory has no effect on the normal operation of the Wasm application. Therefore, when a data access instruction is received and the access address corresponding to the data access instruction is determined to be a related address in the first memory, and the data access instruction is determined to be a data read instruction, the inherent data of the Wasm application in the corresponding address can be read by calling the access address parameter corresponding to the function data access instruction.

[0067] The following embodiments of the present disclosure further illustrate the method of reading data by calling a function.

[0068] Figure 5 FIG. 1 is a flow chart of a data access method according to an exemplary embodiment. Figure 5 As shown, the method includes steps S501 to S503.

[0069] In step S501, an access address corresponding to a data access instruction is determined.

[0070] In step S502, in response to the access address being within the address range corresponding to the first memory, the data access instruction is parsed by the compiler plug-in to determine the instruction type of the data access instruction.

[0071] In step S503, in response to the data access instruction being a data read instruction, the calling function obtained by converting the data access instruction returns the character value of the inherent data to be read by the data access instruction.

[0072] In the embodiment of the present disclosure, when a data access instruction is received and the corresponding access address is determined to be the address corresponding to the first memory, the data access instruction is converted into a call function for data acquisition. When the data access instruction is confirmed to be a data access instruction, the value of the inherent data in the corresponding address is acquired and returned according to the access address parameter corresponding to the data access instruction.

[0073] In an exemplary embodiment of the present disclosure, the inherent data of the Wasm application is accessed based on the data access instruction in the following manner: during the operation of the Wasm module (e.g., WAMR, wasm micro runtime), when a data access instruction is received and the corresponding access address is determined to be the address corresponding to the first memory, the data access instruction is converted into a calling function (__read_const_data) for reading the inherent data of the Wasm application from the read-only memory (const_data_section) in the Wasm module, and the parameter of the calling function is set to the address corresponding to the first memory (the storage address of the inherent data), and the return value of the function is the value of the inherent data. All data access instructions issued by the Wasm application are scanned again, and when it is determined that there is a data write instruction in the data access instruction, an error is reported, indicating that there is an error in the data access process. When it is determined that the data access instruction is a data read instruction, the value of the inherent data in the corresponding address is obtained and returned according to the access address parameter corresponding to the data access instruction.

[0074] It is understandable that the data access instruction issued by the Wasm application can perform data access operations on the read-only data in the first memory, and can also perform data access on the additional memory data stored in other memories. In addition to the inherent data that affects the normal operation of the Wasm application, the data stored in the application memory also stores additional data such as the operation data generated during the operation of the Wasm application and the data added by the user based on personal needs. Therefore, in addition to the read-only memory (first memory) for storing the inherent data of the Wasm application, the present disclosure also sets a read-write memory for storing additional data (for example, a linear memory at one end is selected in the custom area of ​​the Wasm module as the second memory for storing additional data). It is further understandable that the additional data of the Wasm application will not affect the normal operation of the application, so the additional data is readable data, and the memory where the additional data is located is a readable and writable memory. After receiving the data access instruction, the access address of the data access instruction is determined to correspond to the address of the memory where the additional data is located, then the additional data can be read when the data access instruction is a data read instruction, and the additional data can be modified when the data access instruction is a data write instruction. Furthermore, the memory size of the overall memory of the Wasm application in the present disclosure can be customized, so when determining the memory where the additional data is located, the memory size of the overall memory of the Wasm application is determined, and the memory size of the memory where the additional data is located is determined based on the difference between the memory size of the overall memory of the Wasm application and the memory size of the first memory, and then the memory where the additional data is located is set according to the determined memory size.

[0075] In the disclosed embodiment, the read-only memory for storing the inherent data of the Wasm application in the Wasm module is determined by the compiler plug-in: after receiving the data definition instruction, the data segment specified by the data definition instruction is determined, and the data segment specified by the data definition instruction (the inherent data of the Wasm application) is defined as read-only data by adding additional attributes when compiling and using the compiler plug-in. After determining the read-only data, the read-only data is stored in the custom area of ​​the Wasm module, and the data segment storing the read-only data in the custom area is determined as the read-only memory in the Wasm module. During the operation of the Wasm module, when a data access instruction is received and the corresponding access address is determined to be the address corresponding to the first memory, the data access instruction is converted into a calling function for reading the inherent data of the Wasm application from the read-only memory in the Wasm module by the compiler plug-in, and the parameter of the calling function is set to the address corresponding to the first memory. Then determine the instruction type of the data access instruction, and when it is determined that the data access instruction is a data write instruction, an error is reported, indicating that there is an error in the data access process. When the data access instruction is determined to be a data read instruction, according to the access address parameter corresponding to the data access instruction, the value of the inherent data in the corresponding address is obtained and returned to complete the data reading. Through the present disclosure, it is ensured that the application cannot modify inherent data, the security of the application is improved, the security risk of the application is reduced, and the consumption of application memory is reduced.

[0076] Based on the same concept, the embodiment of the present disclosure also provides a data access device 100 .

[0077] It is understandable that the data access device 100 provided in the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function in order to realize the above functions. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.

[0078] Figure 6 1 is a block diagram of a data access device 100 according to an exemplary embodiment. Figure 6 , the device includes a determining unit 101 and a processing unit 102.

[0079] The determination unit 101 is used to determine an access address corresponding to the data access instruction in response to receiving a data access instruction issued by a low-level bytecode format Wasm application.

[0080] The processing unit 102 is configured to determine the instruction type of the data access instruction through the compiler plug-in in response to the access address being within the address range corresponding to the first memory during the Wasm compilation process, and to report an error in response to the data access instruction being a data write instruction, indicating that an error occurs in the data access process.

[0081] Among them, the first memory is a read-only memory, which is used to store the inherent data of the low-level bytecode format Wasm application.

[0082] In one implementation, the first memory is determined by the processing unit 102 in the following manner: in response to receiving a data definition instruction, during the Wasm compilation process, an additional attribute is added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attribute is determined as read-only data. The read-only data is stored in a custom area, and the custom area storing the read-only data is determined as the first memory.

[0083] In one implementation, the capacity of the first memory is equal to the length of the data segment of the read-only data.

[0084] In one embodiment, the processing unit 102 is also used to: in response to an access address being within an address range corresponding to the first memory, during the Wasm compilation process, record the access address through a compiler plug-in, and replace the data access instruction with a calling function whose calling parameter is the access address, wherein the calling function is used to call the inherent data within the address range corresponding to the first memory.

[0085] In one implementation, the processing unit 102 is further configured to: in response to an access address being within an address range corresponding to the first memory and the data access instruction being a data read instruction, read data in a memory address corresponding to the data read instruction by calling a function.

[0086] In one implementation, the processing unit 102 reads the data in the memory address corresponding to the data read instruction by calling the function in the following manner: in response to the access address being within the address range corresponding to the first memory, the data access instruction is parsed by the compiler plug-in to determine the instruction type of the data access instruction. In response to the data access instruction being a data read instruction, the calling function obtained by converting the data access instruction returns the character value of the inherent data to be read by the data access instruction.

[0087] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0088] Figure 72 is a block diagram of a device 200 for data access according to an exemplary embodiment. The device 200 may be provided as a terminal. For example, the device 200 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0089] Reference Figure 7 , the device 200 may include one or more of the following components: a processing component 202 , a memory 204 , a power component 206 , a multimedia component 208 , an audio component 210 , an input / output (I / O) interface 212 , a sensor component 214 , and a communication component 216 .

[0090] The processing component 202 generally controls the overall operation of the device 200, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 202 may include one or more processors 220 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 202 may include one or more modules to facilitate interaction between the processing component 202 and other components. For example, the processing component 202 may include a multimedia module to facilitate interaction between the multimedia component 208 and the processing component 202.

[0091] The memory 204 is configured to store various types of data to support operations on the device 200. Examples of such data include instructions for any application or method operating on the device 200, contact data, phone book data, messages, pictures, videos, etc. The memory 204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0092] The power component 206 provides power to the various components of the device 200. The power component 206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 200.

[0093] The multimedia component 208 includes a screen that provides an output interface between the device 200 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 208 includes a front camera and / or a rear camera. When the device 200 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0094] The audio component 210 is configured to output and / or input audio signals. For example, the audio component 210 includes a microphone (MIC), and when the device 200 is in an operation mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 204 or sent via the communication component 216. In some embodiments, the audio component 210 also includes a speaker for outputting audio signals.

[0095] I / O interface 212 provides an interface between processing component 202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0096] The sensor assembly 214 includes one or more sensors for providing various aspects of the status assessment of the device 200. For example, the sensor assembly 214 can detect the open / closed state of the device 200, the relative positioning of components, such as the display and keypad of the device 200, the sensor assembly 214 can also detect the position change of the device 200 or a component of the device 200, the presence or absence of user contact with the device 200, the orientation or acceleration / deceleration of the device 200 and the temperature change of the device 200. The sensor assembly 214 can include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 214 can also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 214 can also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.

[0097] The communication component 216 is configured to facilitate wired or wireless communication between the device 200 and other devices. The device 200 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 216 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 216 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0098] In an exemplary embodiment, the apparatus 200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above method.

[0099] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 204 including instructions, and the instructions can be executed by the processor 220 of the device 200 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0100] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.

[0101] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.

[0102] It will be further understood that the terms “center”, “longitudinal”, “lateral”, “front”, “back”, “up”, “down”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present embodiment and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation.

[0103] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.

[0104] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.

[0105] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present solution, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.

[0106] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.

Claims

1. A data access method, characterized in that: include: In response to receiving a data access instruction issued by a low-level bytecode format Wasm application, determining an access address corresponding to the data access instruction; In response to the access address being within the address range corresponding to the first memory, during the Wasm compilation process, determining, by the compiler plug-in, an instruction type of the data access instruction; In response to the data access instruction being a data write instruction, an error is reported, indicating that an error occurs in the data access process. The first memory is a read-only memory used to store inherent data of the low-level bytecode format Wasm application.

2. The method according to claim 1, characterized in that The first memory is determined in the following manner: In response to receiving the data definition instruction, during the Wasm compilation process, an additional attribute is added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attribute is determined as read-only data; The read-only data is stored in a custom area, and the custom area storing the read-only data is determined as the first memory.

3. The method according to claim 2, characterized in that The capacity of the first memory is equal to the data segment length of the read-only data.

4. The method according to claim 1, characterized in that: The method further comprises: In response to the access address being within the address range corresponding to the first memory, during the Wasm compilation process, the access address is recorded by a compiler plug-in, and the data access instruction is replaced by a calling function whose calling parameter is the access address, The calling function is used to call the inherent data within the address range corresponding to the first memory.

5. The method according to claim 1, characterized in that The method further comprises: In response to the access address being within the address range corresponding to the first memory and the data access instruction being a data read instruction, data in the memory address corresponding to the data read instruction is read by calling a function.

6. The method according to claim 5, characterized in that The step of reading the data in the memory address corresponding to the data reading instruction by calling a function includes: In response to the access address being within the address range corresponding to the first memory, parsing the data access instruction by the compiler plug-in to determine the instruction type of the data access instruction; In response to the data access instruction being a data read instruction, the calling function converted from the data access instruction returns the character value of the inherent data to be read by the data access instruction.

7. A data access device, characterized in that: include: A determination unit, configured to determine an access address corresponding to the data access instruction in response to receiving a data access instruction issued by a Wasm application in a low-level bytecode format; The processing unit, in response to the access address being within the address range corresponding to the first memory, determines the instruction type of the data access instruction through the compiler plug-in during the Wasm compilation process, and in response to the data access instruction being a data write instruction, reports an error, indicating that an error occurs in the data access process, The first memory is a read-only memory, used to store the inherent data of the low-level bytecode format Wasm application.

8. The device according to claim 7, characterized in that The first memory is determined by the processing unit in the following manner: In response to receiving the data definition instruction, during the Wasm compilation process, an additional attribute is added to the inherent data segment of the low-level bytecode format Wasm application through a compiler plug-in, and the inherent data segment with the additional attribute is determined as read-only data; The read-only data is stored in a custom area, and the custom area storing the read-only data is determined as the first memory.

9. The device according to claim 8, characterized in that The capacity of the first memory is equal to the data segment length of the read-only data.

10. The device according to claim 7, characterized in that The processing unit is also used for: In response to the access address being within the address range corresponding to the first memory, during the Wasm compilation process, the access address is recorded by a compiler plug-in, and the data access instruction is replaced by a calling function whose calling parameter is the access address, The calling function is used to call the inherent data within the address range corresponding to the first memory.

11. The device according to claim 7, characterized in that The processing unit is also used for: In response to the access address being within the address range corresponding to the first memory and the data access instruction being a data read instruction, data in the memory address corresponding to the data read instruction is read by calling a function.

12. The device according to claim 11, characterized in that The processing unit reads the data in the memory address corresponding to the data read instruction by calling a function in the following manner: In response to the access address being within the address range corresponding to the first memory, parsing the data access instruction by the compiler plug-in to determine the instruction type of the data access instruction; In response to the data access instruction being a data read instruction, the calling function converted from the data access instruction returns the character value of the inherent data to be read by the data access instruction.

13. A data access device, characterized in that: include: processor: a memory for storing processor-executable instructions; Wherein, the processor is configured to: execute the data access method according to any one of claims 1 to 6.

14. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor, the processor is enabled to execute the data access method according to any one of claims 1 to 6.