Data access method, data access device and storage medium

By setting read-only memory for the constant data of Wasm application and reporting error processing in the data access instructions, the problem that constant data in the memory of Wasm application can be modified is solved, improving the security and stability of the application.

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

Patent Information

Application Number
CN202311385217.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-24
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 constant data stored in the application memory that supports the normal function of the application can be changed, affecting the normal operation of the low-level bytecode format applications.

Method used

Read-only memory is set for the constant data of the Wasm application in advance. When receiving a data access instruction to instruct the data writing operation, if the access address is within the address range corresponding to the read-only memory, an error will be reported, prompting an abnormality in the data access process to avoid the constant data being modified.

Benefits of technology

By storing constant data in read-only memory, it ensures that the application cannot modify constant data, improve application security, reduce application security risks, and reduce application memory consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119885212A_ABST
    Figure CN119885212A_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: acquiring and analyzing a data access instruction sent by a low-level byte code format Wasm application; and when the data access instruction is used for indicating execution of data writing operation and the access address is in the address range corresponding to the first memory, reporting an error, and prompting that the data access process is abnormal. The first memory is a read-only memory and is used for storing constant data applied by the low-level byte code format Wasm. Through the method and the device, the constant data of the low-level byte code format application is stored in the read-only memory, and when the read-only memory where the constant data is located is accessed based on the data access instruction, an error is reported, so that the application cannot modify the constant data, the security of the application is improved, and the security risk of the application 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 WASN application is readable and writable, resulting in that constant data stored in the application memory to support the normal functions of the application can be modified, 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: obtaining and parsing a data access instruction issued by a low-level bytecode format Wasm application; in response to the data access instruction being used to instruct the execution of a data write operation, and the access address being within an address range corresponding to a first memory, reporting an error, indicating that an abnormality has occurred in the data access process, wherein the first memory is a read-only memory, and is used to store constant data of the low-level bytecode format Wasm application.

[0006] In one implementation, the address range corresponding to the first memory is determined in the following manner: in response to completing the compilation of Wasm, exporting the starting address and the ending address of the read-only data; determining the starting address as the zero address, and determining the memory corresponding to the starting address and the ending address as the first memory.

[0007] In one embodiment, the memory of the low-level bytecode format Wasm application includes the first memory and the second memory, the second memory is a readable and writable memory, and the second memory is determined in the following manner: determining the memory capacity of the first memory, and determining the memory capacity of the low-level bytecode format Wasm application memory; determining the difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory as the memory capacity of the second memory, and setting the second memory according to the memory capacity of the second memory.

[0008] In one embodiment, the memory capacity of the first memory is determined in the following manner: determine the first data byte corresponding to the starting address of the first memory, and determine the second data byte corresponding to the ending address of the first memory; and determine the memory capacity of the first memory by taking the difference between the second data byte and the first data byte.

[0009] In one embodiment, the method further includes: in response to the data access instruction being used to instruct execution of a data write operation, and the access address being within an address range corresponding to the second memory, writing data into an address corresponding to the data write instruction.

[0010] In one embodiment, the method further includes: in response to the data access instruction being used to instruct execution of a data read operation, reading data in a memory address corresponding to the data read instruction.

[0011] According to a second aspect of an embodiment of the present disclosure, a data access device is provided, including: a parsing unit, which obtains and parses a data access instruction issued by a low-level bytecode format Wasm application; a processing unit, which reports an error in response to the data access instruction for indicating the execution of a data write operation, and the access address is within the address range corresponding to a first memory, indicating that an abnormality has occurred in the data access process, wherein the first memory is a read-only memory, and is used to store constant data of the low-level bytecode format Wasm application.

[0012] In one embodiment, the address range corresponding to the first memory is determined by the processing unit in the following manner: in response to completing the compilation of Wasm, exporting the starting address and the ending address of the read-only data; determining the starting address as the zero address, and determining the memory corresponding to the starting address and the ending address as the first memory.

[0013] In one embodiment, the memory of the low-level bytecode format Wasm application includes the first memory and the second memory, the second memory is a readable and writable memory, and the second memory is determined by the processing unit in the following manner: determining the memory capacity of the first memory, and determining the memory capacity of the memory of the low-level bytecode format Wasm application; determining the difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory as the memory capacity of the second memory, and setting the second memory according to the memory capacity of the second memory.

[0014] In one embodiment, the memory capacity of the first memory is determined by a processing unit in the following manner: determining a first data byte corresponding to a starting address of the first memory, and determining a second data byte corresponding to an ending address of the first memory; and determining the memory capacity of the first memory by taking the difference between the second data byte and the first data byte.

[0015] In one embodiment, the processing unit is further used to: in response to the data access instruction for instructing to perform a data write operation, and the access address is within an address range corresponding to the second memory, write data into the address corresponding to the data write instruction.

[0016] In one embodiment, the processing unit is further configured to: in response to the data access instruction being used to instruct execution of a data read operation, read data in a memory address corresponding to the data read 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: a read-only memory for storing constant data of Wasm applications is pre-set in the low-level bytecode format Wasm module. The instruction is parsed after obtaining the data access instruction issued by the Wasm application. When the data access instruction is used to indicate the execution of a data write operation, and the access address is within the above-mentioned address range, it is prompted that an abnormality has occurred in the data access process. Through the present disclosure, the constant data of the low-level bytecode format application is stored in the read-only memory, and when the read-only memory where the constant data is located is accessed based on the data access instruction, an error is reported to ensure that the application cannot modify the constant data, thereby improving the security of the application and reducing the security risk of the application.

[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 an address range corresponding to a first memory according to an exemplary embodiment.

[0024] Figure 3 The invention is a flowchart showing a method for determining a second memory according to an exemplary embodiment.

[0025] Figure 4 The invention is a flowchart showing a method for determining a memory capacity of a first memory according to an 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 flowchart of a data access method according to an exemplary embodiment.

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

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

[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 statically typed languages ​​(e.g., C, C++, Rust, etc.). If the dynamic typed 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 typed 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 constant data and non-constant data, among which non-constant data will not affect the normal operation of the low-level bytecode format Wasm application. It 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. Constant data is necessary data to support the normal operation of low-level bytecode format Wasm applications or data that the application developer believes needs to be retained. This part of data should be readable but not modifiable. If modified, it will affect the stability of the operation of low-level bytecode format Wasm applications, causing low-level bytecode format Wasm applications to fail to operate normally, and causing abnormal situations such as some functions being unavailable and flashbacks. Therefore, in the related art, the application memory of low-level bytecode format Wasm applications is readable and writable as a whole, which will cause the constant data stored in the application memory to change based on the data write instruction, resulting in unstable operation of Wasm applications and operational risks.

[0035] In view of this, the present disclosure proposes a data access method, which pre-sets a read-only memory for the constant data of the Wasm application. When a data access instruction for instructing to perform a data write operation is received, and its access address is the address corresponding to the above-mentioned read-only memory, an error is reported, indicating that an abnormality occurs in the data access process, ensuring that the application cannot modify the constant data, improving the security of the application, and reducing 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, a data access instruction issued by a low-level bytecode format Wasm application is obtained and parsed.

[0038] In step S102, in response to a data access instruction for instructing to execute a data write operation, and the access address is within the address range corresponding to the first memory, an error is reported to indicate that an abnormality occurs in the data access process.

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

[0040] In the disclosed embodiment, after the Wasm module receives the data access instruction issued by the Wasm application, the data access instruction is parsed to determine the memory address to be accessed by the Wasm application, and the access operation performed by the data access instruction is determined. When it is determined that the memory address to be accessed by the Wasm application is a corresponding address in the read-only memory (used to store constant data of the low-level bytecode format Wasm application), and the data access instruction indicates to perform a write operation, the Wasm module reports an error, prompts an access exception, and terminates the write operation to avoid the constant data stored in the read-only memory from being modified. Through the present disclosure, it is ensured that the Wasm application cannot modify the constant data, improve the security of the application, and reduce the security risk of the application.

[0041] In an exemplary embodiment of the present disclosure, the address range of the read-only memory of the Wasm application is [_srodata_start, _srodata_end], wherein _srodata_start is the data byte corresponding to the start address of the read-only memory, and _srodata_end is the data byte corresponding to the end address of the read-only memory. When the present disclosure determines that the access address of the data access instruction is within [_srodata_start, _srodata_end], and the data access instruction is used to instruct the execution of a data write operation, the Wasm module reports an error, prompts a data access exception, and terminates the data write operation.

[0042] It is understandable that in order to prevent the constant data of the Wasm application from being modified, the constant data needs to be stored in a read-only memory (first memory), and the setting of the read-only memory capacity needs to be the same as the data segment length of the constant data. The following embodiments of the present disclosure illustrate the method for determining the first memory.

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

[0044] In step S201 , in response to completion of Wasm compilation, a start address and an end address of read-only data are exported.

[0045] In step S202, the starting address is determined as the zero address, and the memory corresponding to the starting address and the ending address is determined as the first memory.

[0046] In the disclosed embodiment, after the Wasm module is compiled, read-only data (such as data named __read_const_data) completely corresponding to the constant data of the Wasm application can be exported by modifying the script and the connector, and the data bytes corresponding to the starting address and the data bytes corresponding to the ending address of the read-only data are exported. The starting address of the read-only data is determined as the zero address of the read-only memory of the Wasm application, and the data range corresponding to the above starting address and the ending address is determined as the address range corresponding to the read-only memory (i.e., the first memory) of the Wasm application. The present disclosure determines the read-only memory according to the actual size of the read-only data (corresponding to the constant data of the Wasm application) after the Wasm module is compiled and the address range in which it is located, so that the read-only memory capacity is the same as the size of the constant data of Wasm, and the constant data of the Wasm application is stored in the read-only memory, while ensuring that the constant data of the Wasm application is not modified, reducing the consumption of application memory.

[0047] In an exemplary embodiment of the present disclosure, by modifying the Wasm-ld connector and link script in the Wasm module, the data byte _srodata_start representing the starting address of the read-only data in the Wasm module is exported in the compiled Wasm module, and the data byte _srodata_end representing the ending address of the read-only data in the Wasm module is exported. At the same time, it is necessary to set the starting address of the interval to 0, and determine [_srodata_start, _srodata_end] as the address range corresponding to the read-only memory of the Wasm application.

[0048] It can be understood that the data stored in the application memory, in addition to the constant data that affects the normal operation of the Wasm application, also stores non-constant 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 setting up a read-only memory (first memory) for storing Wasm application constant data, the present disclosure also needs to set up a read-write memory (second memory) for storing non-constant data.

[0049] Figure 3 FIG. 1 is a flow chart showing a method for determining a second memory according to an exemplary embodiment. Figure 3 As shown, the method includes step S301 to step S302.

[0050] In step S301, the memory capacity of the first memory is determined, and the memory capacity of the low-level bytecode format Wasm application memory is determined.

[0051] In step S302, the difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory is determined as the memory capacity of the second memory, and the second memory is set according to the memory capacity of the second memory.

[0052] In the disclosed embodiment, further, the overall memory capacity customized by the Wasm application is determined, and the memory capacity of the readable and writable memory (second memory) of the Wasm application is determined by the difference between the overall memory of the Wasm application and the memory capacity of the read-only memory (first memory) of the Wasm application. Then, the readable and writable memory (second memory) of the Wasm application is determined according to the memory capacity setting of the determined readable and writable memory (second memory), such as setting the readable and writable memory in the customized area of ​​the Wasm module. Through the present disclosure, the readable and writable memory (second memory) of the Wasm application is set according to the overall memory capacity of the Wasm application and the capacity of the read-only memory (first memory), so that the constant data of the Wasm application is only stored in the read-only memory, ensuring the capacity of the readable and writable memory used to store non-constant data, ensuring that the Wasm application is fully used, and reducing the consumption of the Wasm application memory.

[0053] In an exemplary embodiment of the present disclosure, the readable and writable memory of the Wasm application is set in the following manner: after the Wasm module is compiled and the read-only memory of the Wasm application is determined, the Wasm runtime (e.g., WAMR, wasmmicroruntime) is modified, and when a linear memory (second memory) for storing non-constant data is created after the Wasm module is parsed, it is determined that the overall memory size required by the Wasm module is N bytes, and the read-only memory capacity of the Wasm application, that is, the size occupied by constant data is M bytes, and the capacity of the linear memory for storing non-constant data in the Wasm application is determined to be N-M bytes, then a linear memory of a size of N-M bytes is created, and data other than the constant memory (non-constant data) is copied to the linear memory, thereby completing the creation of the readable and writable memory (second memory) of the Wasm application.

[0054] In the embodiment of the present disclosure, the Wasm module stores readable data in the form of linear memory, and different data segment nodes of the linear memory correspond to different data bytes. The present disclosure can determine the capacity of the read-only memory of the Wasm application according to the data bytes corresponding to the starting address and the data bytes corresponding to the ending address of the readable data of the Wasm module. The following embodiment of the present disclosure describes the method for determining the memory capacity of the first memory.

[0055] Figure 4 FIG. 1 is a flow chart showing a method for determining the memory capacity of a first memory according to an exemplary embodiment. Figure 4 As shown, the method includes step S401 to step S402.

[0056] In step S401, a first data byte corresponding to a start address of a first memory is determined, and a second data byte corresponding to an end address of the first memory is determined.

[0057] In step S402, the difference between the second data byte and the first data byte is determined as the memory capacity of the first memory.

[0058] In the embodiment of the present disclosure, after obtaining the data bytes corresponding to the starting address and the data bytes corresponding to the ending address of the read-only data of the Wasm module, the difference between the data bytes corresponding to the above-mentioned ending address and the data bytes corresponding to the starting address can be determined as the memory capacity of the read-only memory (first memory) of the Wasm application. The present disclosure determines the data segment length of the read-only data according to the address range (i.e., the starting address to the ending address) where the read-only data (corresponding to the constant data of the Wasm application) after the Wasm module completes compilation, and sets a read-only memory of the same size according to the determined data segment length, so that the read-only memory capacity is the same as the size of the constant data of Wasm, and the constant data of the Wasm application is stored in the read-only memory, while ensuring that the constant data of the Wasm application is not modified, reducing the consumption of application memory.

[0059] In an exemplary embodiment of the present disclosure, the memory capacity of the first memory is determined in the following manner: by modifying the Wasm-ld connector and the link script in the Wasm module, in the compiled Wasm module, the data byte _srodata_start representing the starting address of the read-only data in the Wasm module is exported, and the data byte _srodata_end representing the ending address of the read-only data in the Wasm module is exported, and the memory capacity of the first memory is calculated using _srodata_end-_srodata_start.

[0060] It is understandable that the data access instruction issued by the Wasm application can also be used to instruct writing data in a memory other than the first memory. The following embodiments of the present disclosure further illustrate the above data access method.

[0061] 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 step S501 and step S502.

[0062] In step S501, a data access instruction issued by a low-level bytecode format Wasm application is obtained and parsed.

[0063] In step S502, in response to a data access instruction for instructing to perform a data write operation, and the access address is within an address range corresponding to the second memory, data is written into an address corresponding to the data write instruction.

[0064] In the disclosed embodiment, the non-constant data of the Wasm application is stored in the readable and writable memory (i.e., the second memory) of the Wasm module, and the non-constant data of the Wasm application is the operation data generated during the operation of the Wasm application in low-level bytecode format and the newly added data based on personal needs of the user, which can be deleted or modified without affecting the normal operation of the Wasm application. Therefore, the data access instruction is used to indicate the execution of the data write operation and the access address is within the address range corresponding to the second memory, and data can be written to the corresponding address based on the data access instruction to modify the non-constant data.

[0065] In the disclosed embodiment, based on the instruction type (execute a read operation or execute a write operation) and the access address (the address range corresponding to the first memory or the address range corresponding to the second memory) of the data access instruction issued by the Wasm application, the constant data of the Wasm application is ensured not to be modified while supporting the customization of the non-constant data of the Wasm application.

[0066] It is understandable that the data access instruction issued by the Wasm application can be used to instruct the execution of a write operation as well as a read operation. The following embodiments of the present disclosure further illustrate the above data access method.

[0067] Figure 6 FIG. 1 is a flow chart of a data access method according to an exemplary embodiment. Figure 6 As shown, the method includes step S601 and step S602.

[0068] In step S601, a data access instruction issued by a low-level bytecode format Wasm application is obtained and parsed.

[0069] In step S602, in response to a data access instruction for instructing to perform a data read operation, data in a memory address corresponding to the data read instruction is read.

[0070] In the disclosed embodiment, the constant data stored in the first memory is read-only data, supports normal reading, and reading the constant data in the first memory has no effect on the normal operation of the Wasm application, and the non-constant data stored in the second memory is readable and writable data. Therefore, the data in the application memory of the Wasm application are all readable data, and when a data access instruction is received and it is determined that the data access instruction is used to perform a data read operation, the data in the corresponding address is read.

[0071] In an exemplary embodiment of the present disclosure, the data access instruction is received and executed in the following manner: when the Wasm module is running, the data access instruction issued by the Wasm application is received and parsed, and it is determined that the data access instruction is used to perform a data read operation, and the accessed address is determined to be within the range of the first memory (for example, the access address is within the interval [_srodata_start, _srodata_end], _srodata_start is the data byte corresponding to the start address of the read-only memory, and _srodata_end is the data byte corresponding to the end address of the read-only memory), then the data is directly read from the constant memory. If it is determined that the data access instruction is used to perform a data read operation, and it is determined that the accessed address is within the range of the second memory, the data is read from the second memory.

[0072] In the disclosed embodiment, a first memory for storing constant data of Wasm applications and a second memory for storing constant data of Wasm applications are pre-set: after the Wasm module is compiled, the data bytes corresponding to the starting address and the data bytes corresponding to the ending address of the read-only data in the Wasm module are exported, the first memory is set according to the starting address and the ending address of the read-only data, and the constant data is stored in the first memory. The memory capacity of the first memory is determined by the difference between the data bytes corresponding to the starting address and the data bytes corresponding to the ending address of the read-only data, the memory capacity of the second memory is determined according to the difference between the overall memory capacity of the Wasm application and the memory capacity of the first memory, and the second memory is set, and the non-constant data is stored in the second memory. During the operation of the Wasm application, after the Wasm module receives the data access instruction issued by the Wasm application, it parses the data access instruction, determines the data access operation and access address to be executed, and reports an error in response to the data access instruction for indicating the execution of a data write operation, and the access address is within the address range corresponding to the first memory, prompting that the data access process is abnormal; in response to the data access instruction for indicating the execution of a data write operation, and the access address is within the address range corresponding to the second memory, writes data in the address corresponding to the data write instruction; in response to the data access instruction for indicating the execution of a data read operation, reads the data in the memory address corresponding to the data read instruction. Through the present disclosure, when a data access instruction for indicating the execution of a data write operation is received, and its access address is the address corresponding to the above-mentioned read-only memory, an error is reported, prompting that the data access process is abnormal, ensuring that the application cannot modify constant data, improving the security of the application, reducing the security risk of the application, and reducing the consumption of application memory.

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

[0074] 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.

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

[0076] The parsing unit 101 is used to obtain and parse data access instructions issued by the low-level bytecode format Wasm application.

[0077] The processing unit 102 is used to report an error in response to a data access instruction for instructing to execute a data write operation, and the access address is within the address range corresponding to the first memory, indicating that an abnormality occurs in the data access process.

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

[0079] In one implementation, the address range corresponding to the first memory is determined by the processing unit 102 in the following manner: in response to completing the compilation of Wasm, the start address and the end address of the read-only data are derived, the start address is determined as the zero address, and the memory corresponding to the start address and the end address is determined as the first memory.

[0080] In one embodiment, the memory of the low-level bytecode format Wasm application includes a first memory and a second memory, the second memory is a readable and writable memory, and the second memory is determined by the processing unit 102 in the following manner: determining the memory capacity of the first memory, and determining the memory capacity of the low-level bytecode format Wasm application memory. The difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory is determined as the memory capacity of the second memory, and the second memory is set according to the memory capacity of the second memory.

[0081] In one implementation, the memory capacity of the first memory is determined by the processing unit 102 in the following manner: a first data byte corresponding to the start address of the first memory is determined, and a second data byte corresponding to the end address of the first memory is determined, and the difference between the second data byte and the first data byte is determined as the memory capacity of the first memory.

[0082] In one implementation, the processing unit 102 is further configured to: in response to a data access instruction for instructing to execute a data write operation, and the access address is within an address range corresponding to the second memory, write data into an address corresponding to the data write instruction.

[0083] 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.

[0084] Figure 8 2 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.

[0085] Reference Figure 8 , 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 .

[0086] 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.

[0087] 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.

[0088] 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.

[0089] 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.

[0090] 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.

[0091] 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.

[0092] 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.

[0093] 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.

[0094] 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.

[0095] 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.

[0096] 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.

[0097] 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.

[0098] 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.

[0099] 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.

[0100] 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.

[0101] 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.

[0102] 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: Obtain and parse data access instructions issued by low-level bytecode format Wasm applications; In response to the data access instruction being used to instruct the execution of a data write operation, and the access address being within the address range corresponding to the first memory, an error is reported, indicating that an abnormality occurs in the data access process, The first memory is a read-only memory, used to store constant data of the low-level bytecode format Wasm application.

2. The method according to claim 1, characterized in that The address range corresponding to the first memory is determined in the following manner: In response to completing the compilation of Wasm, exporting the start address and the end address of the read-only data; The starting address is determined as a zero address, and a memory corresponding to the starting address and the ending address is determined as the first memory.

3. The method according to claim 1, characterized in that The memory of the low-level bytecode format Wasm application includes the first memory and the second memory, the second memory is a readable and writable memory, and the second memory is determined in the following manner: Determine the memory capacity of the first memory, and determine the memory capacity of the low-level bytecode format Wasm application memory; The difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory is determined as the memory capacity of the second memory, and the second memory is set according to the memory capacity of the second memory.

4. The method according to claim 1, characterized in that: The memory capacity of the first memory is determined in the following manner: Determine a first data byte corresponding to a start address of the first memory, and determine a second data byte corresponding to an end address of the first memory; The memory capacity of the first memory is determined by taking the difference between the second data byte and the first data byte.

5. The method according to claim 1, characterized in that The method further comprises: In response to the data access instruction being used to instruct execution of a data write operation, and the access address being within an address range corresponding to the second memory, data is written into an address corresponding to the data write instruction.

6. The method according to claim 1, characterized in that The method further comprises: In response to the data access instruction being used to instruct execution of a data read operation, data in a memory address corresponding to the data read instruction is read.

7. A data access device, characterized in that: include: A parsing unit that obtains and parses data access instructions issued by a low-level bytecode format Wasm application; The processing unit reports an error in response to the data access instruction for instructing to execute a data write operation, and the access address is within the address range corresponding to the first memory, indicating that an abnormality occurs in the data access process. The first memory is a read-only memory, used to store constant data of the low-level bytecode format Wasm application.

8. The device according to claim 7, characterized in that The address range corresponding to the first memory is determined by the processing unit in the following manner: In response to completing the compilation of Wasm, exporting the start address and the end address of the read-only data; The starting address is determined as a zero address, and a memory corresponding to the starting address and the ending address is determined as the first memory.

9. The device according to claim 8, characterized in that The memory of the low-level bytecode format Wasm application includes the first memory and the second memory, the second memory is a readable and writable memory, and the second memory is determined by the processing unit in the following manner: Determine the memory capacity of the first memory, and determine the memory capacity of the low-level bytecode format Wasm application memory; The difference between the memory capacity of the low-level bytecode format Wasm application and the memory capacity of the first memory is determined as the memory capacity of the second memory, and the second memory is set according to the memory capacity of the second memory.

10. The device according to claim 8, characterized in that The memory capacity of the first memory is determined by the processing unit in the following manner: Determine a first data byte corresponding to a start address of the first memory, and determine a second data byte corresponding to an end address of the first memory; The memory capacity of the first memory is determined by taking the difference between the second data byte and the first data byte.

11. The device according to claim 8, characterized in that The processing unit is also used for: In response to the data access instruction being used to instruct execution of a data write operation, and the access address being within an address range corresponding to the second memory, data is written into an address corresponding to the data write instruction.

12. The device according to claim 8, characterized in that The processing unit is also used for: In response to the data access instruction being used to instruct execution of a data read operation, data in a memory address corresponding to the data read instruction is read.

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.