File access method and computing device

By integrating file access functions based on the Linux security module framework in the Linux kernel, trustworthy verification of files is achieved, and the problem that the existing technology cannot effectively prevent malicious files or corrupt file access is solved, which significantly improves the security and reliability of file access.

CN119622789APending Publication Date: 2025-03-14HENAN KUNLUN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411558062.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

After the existing technology performs security verification on the file access side, it cannot effectively prevent access to malicious files or corrupt files, resulting in certain risks in file access.

Method used

By integrating file access functions based on the Linux security module framework in the Linux kernel, intercept file access requests of application processes, and obtain and compare the reference metric values ​​and actual metric values ​​of the target file to ensure the integrity and security of the file.

Benefits of technology

It effectively improves the security and reliability of file access, prevents application processes from accessing malicious or corrupt files, and protects the security and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119622789A_ABST
    Figure CN119622789A_ABST
Patent Text Reader

Abstract

The invention provides a file access method and a server, and the method comprises the steps: when an application process initiates a file access request in a user space, a kernel firstly intercepts the request, and verifies a target file through a newly added file access function. The file access function can obtain and compare a reference metric value and an actual metric value of the file, the reference metric value represents the original state data volume when the file is not tampered or damaged, and the actual metric value reflects the current data state of the file. By comparing the two metric values, the kernel can judge the integrity and security of the file. If the actual metric value is consistent with the reference metric value, the file is not maliciously tampered or damaged, and the kernel allows the application process to continue to access the file. Otherwise, the access request is rejected, so that the application process is effectively prevented from accessing malicious or damaged files, and the security and stability of the system are protected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In current file access scenarios, the access end is usually authenticated to prevent illegal access to the file system. For example, through trusted boot technology, the system can verify the integrity and authenticity of the application process, thereby preventing malware from posing a threat to the security of the file system. Trusted boot usually combines hardware and software, including the use of secure boot bootloaders, digital signature verification, and secure boot chips.

[0003] However, in this solution, only security verification is performed on the access end, but it cannot prevent the access end from accessing malicious or damaged files, which will affect the implementation of the access end function and cause certain risks in file access. Summary of the invention

[0004] In view of this, an embodiment of the present application provides a file access method and a computing device to improve the security and reliability of file access.

[0005] In a first aspect, an embodiment of the present application provides a file access method, comprising:

[0006] In the case where the application process calls the file system call interface to send a file access request to the kernel, the kernel executes a file access function to intercept the file access request; the file access request is used to request access to a target file; the application process runs in the user space; the file access function is a function added to the kernel based on the Linux security module framework for implementing file trust verification; the file access function is executed in the kernel;

[0007] The kernel executes the file access function to obtain a reference measurement value and an actual measurement value of the target file; the actual measurement value is used to describe the current data volume of the target file, and the reference measurement value is used to describe the data volume of the target file when it has not been maliciously tampered with or damaged;

[0008] In a case where the actual metric value is equal to the reference metric value, the kernel requests access to the target file through the application process.

[0009] In an embodiment of the present application, by integrating a file access function based on the Linux security module framework in the Linux kernel, a trusted verification of the file is realized, thereby effectively improving the security of file access. Specifically, when the application process initiates a file access request in the user space, the kernel first intercepts the request and verifies the target file through the newly added file access function. The file access function obtains and compares the reference measurement value and the actual measurement value of the file, wherein the reference measurement value represents the original state data volume when the file has not been tampered with or damaged, and the actual measurement value reflects the current data state of the file. By comparing these two measurement values, the kernel can judge the integrity and security of the file. If the actual measurement value is consistent with the reference measurement value, it means that the file has not been maliciously tampered with or damaged, and the kernel will allow the application process to continue to access the file. Otherwise, the access request will be rejected, thereby effectively preventing the application process from accessing malicious or damaged files and protecting the security and stability of the system.

[0010] In a possible implementation, the file access request includes an access type to the target file, and the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including:

[0011] When it is determined that the access type to the target file indicated by the file access request is a read operation, the kernel executes the file access function to call a trusted module to obtain a reference measurement value and an actual measurement value of the target file.

[0012] The method further comprises:

[0013] When it is determined that the access type to the target file indicated by the file access request is a write operation, the kernel rejects the access request to the target file by the application process.

[0014] In the embodiment of the present application, the processing of different types of access requests is further refined, and by distinguishing between read operations and write operations, and combining with the trusted module for file verification, the refined control of file access is achieved, thereby improving the security of the system. Specifically, when the application process initiates a read operation request, the kernel will call the trusted module to obtain the reference measurement value and the actual measurement value of the target file, and verify the integrity of the file by comparing the two values, and only allow access after ensuring that the file has not been tampered with or damaged. This effectively prevents the application process from reading malicious or damaged file data, thereby protecting the reliability of the data and the security of the system. At the same time, for write operation requests, the kernel directly denies the access of the application process, which prevents the file from being modified without authorization or insecurely, further enhances the protection of the file, and prevents potential malicious write operations. This technical solution can not only effectively prevent the file from being illegally tampered with, but also ensure the integrity and security of the file when reading, significantly reducing the security risk of the file system in actual applications. Through this differentiated processing of read and write operations, the system can provide flexible and secure file access control under the premise of ensuring data integrity.

[0015] In a possible implementation, the file access request includes a file path of the target file, and before the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, the method further includes:

[0016] The kernel obtains a trusted verification list from the trusted module; the trusted verification list includes file paths of multiple files that need to be trusted before access;

[0017] The kernel queries whether the trusted verification list includes the file path of the target file;

[0018] The kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including:

[0019] In case it is determined that the trusted verification list includes the file path of the target file, the kernel obtains the reference measurement value and the actual measurement value of the target file from the trusted module.

[0020] In the embodiment of the present application, by introducing a trusted verification list, refined verification of specific important files is achieved, thereby further improving the security and efficiency of the system. Specifically, before the kernel executes the file access function, a trusted verification list containing multiple file paths to be verified is first obtained from the trusted module. The kernel will query the list to confirm whether the file path of the target file is included in the list. Only when the target file path is listed as an object to be verified, the kernel will call the trusted module to obtain the reference measurement value and actual measurement value of the target file and perform verification. This method ensures that only critical files are strictly checked for integrity, rather than all files, thereby reducing the consumption of system resources and improving overall access efficiency. At the same time, this mechanism concentrates on the protection of the most sensitive and critical files of the system, ensures the integrity and security of these files during the access process, effectively prevents malicious tampering and data corruption, and provides strong security protection for system operation. Through this refined management, the technical solution not only improves the security of file access, but also optimizes the performance of the system, achieving dual protection of security and efficiency.

[0021] In a possible implementation, the method further includes:

[0022] In the case that the file path of the target file is not found in the trusted verification list, the kernel requests access to the target file through the application process.

[0023] In an embodiment of the present application, by finely managing the trusted verification list, flexible processing of different file access requests is achieved, further improving the security and efficiency of the system. Specifically, when the kernel does not find the file path of the target file in the trusted verification list, that is, the file is not within the scope that requires strict verification, the kernel will directly access the file through the application process. This mechanism avoids unnecessary verification operations, thereby reducing the consumption of system resources and access delays, and improving the overall efficiency of file access. At the same time, this method ensures fast access to non-critical files and does not affect the user experience due to redundant security checks. Through this selective verification strategy, the technical solution not only ensures the security of important system files, but also optimizes the access efficiency of general files, achieves a dual balance between security and efficiency, and provides the system with a more flexible and efficient file access control mechanism.

[0024] In a possible implementation, the file access request includes a file path of the target file, and the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including:

[0025] The kernel calls the trusted module driver to query the metric value list in the trusted module, and determines the reference metric value corresponding to the file path of the target file from the metric value list; the metric value list includes the file path and reference metric value of the file that needs to be trusted before access;

[0026] The kernel calls the memory driver, reads the target file from the memory according to the file path of the target file, and calls the trusted module driver to send the file content of the target file to the trusted module, so as to calculate the actual measurement value of the target file using the trusted module.

[0027] In the embodiment of the present application, through the close cooperation between the kernel and the trusted module, the accurate verification of the target file is realized, and the integrity and security of the file during the access process are ensured. Specifically, the kernel will call the trusted module driver to query the metric value list containing the file path to be verified and its reference metric value, so as to obtain the reference metric value of the target file. Then, the kernel reads the content of the target file through the memory driver, and sends the file data to the trusted module, and the trusted module calculates the actual metric value. This method reduces the burden of the kernel by processing the metric calculation through the trusted module, and can use the security features of the trusted module for highly reliable metric verification. By comparing the reference metric value and the actual metric value, the kernel can accurately determine whether the file has been tampered with or damaged, thereby ensuring the integrity of the file before access, preventing malicious data from flowing into the system, and enhancing the overall security of file access. This implementation method not only improves the efficiency and reliability of the verification process, but also provides multi-level security protection for the system, ensuring the integrity of key data and the security of access.

[0028] In a possible implementation, the method further includes:

[0029] In a case where the actual metric value is greater than or less than the reference metric value, the kernel denies the application process's request to access the target file.

[0030] In the embodiment of the present application, the protection of file integrity and security is further enhanced through a strict metric comparison mechanism. Specifically, after obtaining the reference metric value and the actual metric value of the target file, the kernel will compare the two values. If the actual metric value is not equal to the reference metric value, that is, the actual metric value is greater than or less than the reference metric value, it means that the target file may have been tampered with or damaged, and the kernel will reject the application process's access request to the file. This mechanism ensures that only complete and untampered files can be accessed, thereby effectively preventing malicious software or unauthorized modifications from causing harm to the system. By performing a strict integrity check before file access, the technical solution significantly improves the security of the system, protects the reliability of data and the stability of the system. At the same time, this access denial strategy also plays a role in preventing the spread of potential security threats, providing a strong guarantee for the safe operation of the system.

[0031] In a possible implementation manner, when the actual metric value is greater than or less than the reference metric value, the method further includes:

[0032] The kernel calls the storage driver to query the backup file of the target file from the storage according to the file path of the target file;

[0033] The kernel reads the backup file, sends the file content of the backup file to the trusted module, and uses the trusted module to calculate the actual measurement value of the backup file;

[0034] When the actual measurement value of the backup file is the same as the reference measurement value of the target file, the target file is restored using the backup file.

[0035] In the embodiment of the present application, by introducing a backup file recovery mechanism, the fault tolerance and security of the system are further enhanced. Specifically, when it is detected that the actual measurement value of the target file does not match the reference measurement value, the kernel will call the memory driver to query and locate the backup file of the target file. Subsequently, the kernel reads the content of the backup file and sends it to the trusted module to calculate the actual measurement value of the backup file. If the actual measurement value of the backup file is the same as the reference measurement value of the target file, it means that the backup file is complete and credible, and the kernel will use the backup file to restore the damaged or tampered target file. This mechanism can not only automatically repair the file when it is damaged or tampered, ensuring the integrity and security of the file, but also effectively prevent system abnormalities or data loss caused by file damage. Through this automated backup and recovery strategy, the technical solution significantly improves the reliability and stability of the system, provides strong support for the protection and recovery of key data, and ensures that the system can still operate normally in the face of unexpected situations.

[0036] In a possible implementation, the method further includes:

[0037] When a file is modified, the kernel updates the reference measurement value in the trusted module.

[0038] In the embodiment of the present application, by dynamically updating the reference measurement value in the trusted module, it is ensured that the system can reflect the latest status of the file in real time, thereby enhancing the maintenance of file security. Specifically, when a file is modified, the kernel will detect the change in time and update the corresponding reference measurement value in the trusted module accordingly. This measure ensures that no matter how the file content changes, the system can always use the latest reference measurement value for file security verification. In the subsequent access process, when the actual measurement value is compared with the existing reference measurement value, it can accurately reflect the current status of the file, avoiding misjudgment or rejection of legal access requests due to the use of outdated measurement values. At the same time, the dynamic update mechanism also provides continuous security protection for the system, which can effectively prevent potential security risks. This technical solution not only improves the flexibility of file management, but also enhances the system's ability to respond to file changes, ensuring an effective balance between file security and the real-time performance of members.

[0039] In a possible implementation, when a file in the memory is modified, the kernel reads the modified file and sends the file content of the modified file to the trusted module to calculate and obtain a reference metric value of the modified file;

[0040] The kernel updates the reference metric value corresponding to the file path of the modified file in the trusted module by using the reference metric value of the modified file.

[0041] In the embodiment of the present application, by updating the reference measurement value of the modified file in real time, it is ensured that the measurement value of the system is always consistent with the latest state of the file, thereby enhancing the responsiveness and security of the system. Specifically, when the file in the memory is modified, the kernel will immediately read the new content of the modified file, and send these contents to the trusted module for measurement value calculation to obtain the reference measurement value of the modified file. Subsequently, the kernel uses this new reference measurement value to update the reference measurement value of the corresponding file path in the trusted module. This mechanism ensures that the system can use the latest measurement value to make accurate judgments when performing file access verification, avoiding misjudgments or security vulnerabilities caused by using expired measurement values. Through this real-time update strategy, the system can respond quickly to changes in files, ensuring that the integrity and security of files are continuously and effectively maintained. This technical solution not only improves the accuracy and timeliness of file management, but also strengthens the system's adaptability to dynamic changes, ensuring that key data is always in a protected state.

[0042] In a second aspect, an embodiment of the present application provides a server, comprising a processor, and a memory communicatively connected to the processor;

[0043] The memory is used to store computer-executable instructions;

[0044] The processor is used to execute the computer-executable instructions stored in the memory to implement the file access method described in any embodiment of the first aspect above.

[0045] In a third aspect, an embodiment of the present application provides a computing device, wherein a computer storage medium stores code, and when the code is executed, the device executing the code implements the file access method described in any one of the first aspects above.

[0046] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 A software architecture diagram of a computing device provided in an embodiment of the present application;

[0049] Figure 2 A flowchart of a file access method provided in an embodiment of the present application;

[0050] Figure 3 A flowchart of another file access method provided in an embodiment of the present application;

[0051] Figure 4 A flowchart of another file access method provided in an embodiment of the present application;

[0052] Figure 5 A flowchart of a file access method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] It should be noted that the embodiments described in this application are only part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0054] In order to make the following embodiments clear, the technical terms involved in this application are first introduced.

[0055] Trusted Computing: A technical solution for ensuring the trustworthiness and security of computer systems. Through the combination of hardware and software, a trusted computing environment is established to protect computers and data from malware, attacks, and unauthorized access.

[0056] Trusted Measurement: is a process of evaluating the trustworthiness of a computer system by measuring and verifying system configuration, software, and firmware to determine whether the system is in the expected security state. Trusted Measurement can help detect changes in system configuration and potential malware intrusions.

[0057] Trusted Recovery: refers to restoring the integrity and availability of a system or data through trusted mechanisms and processes when the system or data is accidentally damaged or lost. Trusted recovery is one of the important means to ensure the trustworthiness of systems and data.

[0058] Measurement: refers to the result of a quantitative assessment of the state of software and firmware in a computing environment. Measurements are usually generated by calculating the hash value (such as SHA-1 or SHA-256) of specific software or hardware components, and the measurements can be used to verify the integrity and credibility of these components. In an embodiment of the present application, the measurement can also be the result of hashing the content of a file, and the measurement is used to verify the integrity and credibility of the file to ensure that the file has not been tampered with during storage or transmission.

[0059] Linux Security Modules (LSM): The LSM framework is an interface layer for enhancing the security of the Linux kernel. It provides a standardized way to enable third-party security modules to be integrated with the Linux kernel. The LSM framework allows different security policy modules to interface with the kernel through a unified interface, thereby achieving the expansion of security functions without modifying the kernel source code.

[0060] In order to improve the security of file access, an embodiment of the present application provides a file access method, which adds a file access function in the kernel based on the LSM framework. When an application process issues a file access request, the file access request is intercepted. When the file access request is used to request a read operation on a target file and the target file needs to be trusted, the actual measurement value of the target file is calculated, and the actual measurement value is compared with the reference measurement value of the target file. When the actual measurement value is the same as the reference measurement value, the application process is allowed to access the target file; when the actual measurement value is different from the reference measurement value, the application process is denied access to the target file.

[0061] The method provided in the embodiments of the present application can be applied to Figure 1 The computing device shown. Figure 1 A software architecture diagram of a computing device provided in an embodiment of the present application. Figure 1 As shown, the architecture of the computing device includes at least user space, kernel space and hardware abstraction layer.

[0062] User space and kernel space are two different memory areas of an operating system, used to run user applications and the operating system kernel respectively.

[0063] An application process runs in the user space, and the application process may be a process for an application program to access a target file in a memory of a computing device.

[0064] The kernel space runs a kernel, which includes file access functions. The file access function is used to implement a trustworthy check on the target file that the application wants to access. The kernel provides a file system call interface to the user space. When the user space runs an application process, a file access request can be sent to the kernel through the file system call interface to access the file in the memory. When the application process calls the file system call interface to send a file access request to the kernel, the file access function is executed in the kernel, the file access request is intercepted, and a trustworthy check is performed on the target file requested to be accessed by the file access request.

[0065] In the embodiment of the present application, the file access function is added to the Linux kernel as a separate security module based on the LSM framework to enhance the security and control capabilities of file access. When the application process in the user space calls the file system call interface to send a file access request to the kernel, the kernel executes the file access function in the LSM framework to implement a trusted check of the target file.

[0066] The Hardware Abstraction Layer (HAL) is used to provide memory drivers and trusted module drivers to the kernel. Through the memory driver provided by the hardware abstraction layer, files stored in the memory can be accessed; through the trusted module driver provided by the hardware abstraction layer, the accessed files can be trusted based on the reference measurement values ​​pre-stored in the trusted module.

[0067] In the embodiment of the present application, the computing device includes a memory (such as a hard disk) and a trusted module (such as a password card), and the memory can be integrated on the mainboard or installed on the mainboard through a slot. The trusted module can be installed on the mainboard of the computing device in the form of a chip, or can be plugged into the mainboard through a mainboard interface (such as a high-speed serial computer expansion bus standard slot). The trusted module includes but is not limited to a trusted platform module (trusted platform module, TPM), a trusted cryptography module (trusted cryptography module, TCM), a trusted platform control module (trusted platform control module, TPCM) and a password card, etc.

[0068] The memory is used to store multiple files for access by various application processes. In one implementation, the trusted module is used to store a measurement value list, which includes reference measurement values ​​corresponding to each of the multiple files in the memory. In another implementation, the trusted module is used to store a trusted verification list and a measurement value list, the trusted verification list includes the file name or file path that needs to be trusted before access, and the measurement value list includes the reference measurement values ​​corresponding to each file described in the trusted verification list.

[0069] If the file content has not been legally modified since the file was stored in the memory, the reference metric value is the metric value calculated based on the original file content corresponding to the file; if the file content has been legally modified since the file was stored in the memory, the reference metric value is the metric value calculated and saved based on the file content of the edited file after the last legal edit to the file.

[0070] In a possible implementation, when an application process calls a file system call interface to send a file access request to the kernel, the kernel executes a file access function to intercept the file access request. After determining the target file to be accessed indicated by the file access request, the kernel queries the target file by calling a memory driver and calculates the actual measurement value of the target file, and then the kernel calls a trusted module driver to query the reference measurement value of the target file. The kernel compares the reference measurement value with the actual measurement value. If the reference measurement value of the target file is different from the actual measurement value (such as the reference measurement value is greater than the actual measurement value, or the reference measurement value is less than the actual measurement value), it indicates that the target file may be damaged or maliciously tampered with. To avoid dangerous access to the target file by the application process, the kernel rejects the application process's access request to the target file. If the reference measurement value is the same as the actual measurement value (such as the reference measurement value is equal to the actual measurement value), it indicates that the target file has the same file content as the last time the reference measurement value was calculated, and no damage or malicious tampering has occurred. The kernel passes the application process's access request to the target file, and the kernel calls the memory driver again to return the file content of the target file to the application process, so that the application process performs tasks according to the target file.

[0071] Next, combine Figure 2 The file access method provided in the embodiment of the present application is exemplified.

[0072] like Figure 2 As shown, Figure 2 A flowchart of a file access method provided in an embodiment of the present application.

[0073] S201: The application process sends a file access request to the kernel.

[0074] The file access request is used to request access to the target file. The file access request includes the file path of the target file. The target file is the file that the application process needs to access, and the target file is usually stored in the memory. The application process is the process created by the operating system to run the application. The application process is the basic execution unit managed by the operating system. The application process runs in the user space.

[0075] When an application process needs to access a file in the memory to perform a task, the application process generates a file access request according to the file path of the target file and the type of access required to the target file, and calls the file system call interface provided by the kernel to send the file access request to the kernel.

[0076] S202: The kernel intercepts the file access request.

[0077] When the application process calls the file system call interface, the kernel executes the file access function to intercept the file access request. The file access function is a function used for file credibility verification. In an embodiment of the present application, the file access function is used to implement credibility verification of the target file requested to be accessed by the file access request. In an embodiment of the present application, the file access function can be added to the kernel based on the LSM framework.

[0078] In the related art, after the application process sends a file access request to the kernel, the kernel provides the application process with the corresponding file content according to the file access request. In order to provide the security of file access, the kernel intercepts the file access request by executing the file access function, so as to first perform a trustworthy check on the file that the application process needs to access, and then accept or reject the access of the application process according to the check result.

[0079] S203: The kernel determines the target file according to the file access request.

[0080] After the kernel intercepts the file access request, it determines the target file that the application process needs to access according to the file path of the target file in the file access request. Specifically, the kernel can determine the target file from the memory according to the file path of the target file by calling the memory driver provided by the hardware abstraction layer.

[0081] S204: The kernel obtains the actual measurement value and the reference measurement value of the target file.

[0082] The actual metric value is the metric value calculated based on the current file content of the target file, and the reference metric value is the metric value calculated based on the file content when the target file is stored or the last time the target file is modified. The actual metric value is used to describe the current data volume of the target file, and the reference metric value is used to describe the data volume when the target file has not been maliciously tampered with or damaged.

[0083] In one implementation, the kernel calls the memory driver, reads the target file from the memory according to the file path of the target file, sends the file content of the target file to the trusted module, and uses the trusted module to calculate the actual measurement value of the target file. Specifically, after the kernel determines the target file, it sends the file content of the target file to the trusted module by calling the trusted module driver provided by the hardware abstraction layer, and uses the trusted module to calculate the actual measurement value.

[0084] The trusted module can calculate the metric value of the file by combining the file content through a hash algorithm (such as SHA-256, SHA-3 or RSA, etc.).

[0085] The file may not have been modified since it was stored in the memory, or it may have been legally modified during the storage process. If the file has not been modified, the reference metric value is calculated based on the file content when the file was stored in the memory; if the file has been legally modified, the reference metric value is calculated based on the modified file content.

[0086] The trusted module stores a metric value list, which includes metric values ​​corresponding to each file in the memory, or the metric value list includes metric values ​​corresponding to each file in the memory that needs to be trusted when accessed. In the metric value list, reference metric values ​​and file paths are stored in pairs, and the reference metric values ​​correspond to the file paths one by one. The reference metric values ​​are the metric values ​​corresponding to the files indicated by the pre-stored file paths.

[0087] The kernel can determine the reference metric value of the target file based on the file path in the file access request and the metric value list in the trusted module. Specifically, the kernel calls the trusted module driver to read the metric value list from the trusted module, and then searches for the reference metric value of the target file from the metric value list based on the file path of the target file.

[0088] S205: The kernel compares the actual measurement value with the reference measurement value.

[0089] After the kernel obtains the actual measurement value and the reference measurement value of the target file, it measures whether the target file has been maliciously tampered with or damaged by comparing the actual measurement value and the reference measurement value. If the actual measurement value and the reference measurement value are the same, step S206 is executed; if the actual measurement value and the reference measurement value are different, step S207 is executed.

[0090] S206: The kernel accepts the application process's access to the target file.

[0091] If the actual measurement value is the same as the reference measurement value, it indicates that the target file has not been maliciously tampered with or damaged, the target file has passed the trust verification, the kernel receives the application process's access to the target file, and the application process can access the target file to complete the task.

[0092] S207: The kernel denies the application process access to the target file.

[0093] If the actual measurement value is different from the reference measurement value, it indicates that the target file may be maliciously tampered with or damaged, and the target file fails the trust verification. The kernel denies the application process access to the target file, preventing the application process from accessing dangerous files and having a negative impact on the execution of the application process.

[0094] In an embodiment of the present application, before the application process accesses the target file, the target file is verified for trustworthiness in combination with the actual measurement value and the reference measurement value of the target file, thereby improving the security of file access. In addition, compared with some embodiments that require trusted verification in user space or application layer (after the kernel determines that a trusted verification is required, it switches to the user space for verification, and switches back to the kernel after the verification is completed), the embodiment of the present application can complete the trusted verification of the file in the kernel without switching to the user space for implementation, thereby reducing overhead. Moreover, verification in user space is easily affected by other processes or operations, and has poor reliability; while the embodiment of the present application completes the trusted verification in the kernel, which is isolated from the operation of the user space, thereby improving the reliability of the trusted verification.

[0095] In another possible implementation, the access type of the target file can also be verified in a trustworthy manner in conjunction with the application process. Figure 3 As shown, Figure 3 A flowchart of another file access method provided in an embodiment of the present application.

[0096] S301: The application process sends a file access request to the kernel.

[0097] In the embodiment of the present application, the file access request also includes an access type (such as a write operation or a read operation) for the target file.

[0098] The specific implementation of step S301 can refer to the description of step S201, which will not be repeated here.

[0099] S302: The kernel intercepts the file access request.

[0100] The specific implementation of step S302 can refer to the description of step S202, which will not be repeated here.

[0101] S303: The kernel determines the access type according to the file access request.

[0102] If the access type is a read operation, step S304 is executed; if the access type is a write operation, other subsequent steps are continued to be executed according to the settings of the technician.

[0103] As an example, if the access type is a write operation, step S308 can be executed to prevent the application process from maliciously tampering with the target file; as another example, if the access type is a write operation, the kernel can directly allow the application process to write to the target file so that the application process accesses the target file to perform tasks.

[0104] In an embodiment of the present application, for a file access request whose access type is a read operation, the kernel can directly perform a trustworthy check on the target file.

[0105] S304: The kernel determines the target file according to the file access request.

[0106] The specific implementation of step S304 can refer to the description of step S203, which will not be repeated here.

[0107] S305: The kernel obtains the actual measurement value and the reference measurement value of the target file.

[0108] The specific implementation of step S305 can refer to the description of step S204, which will not be repeated here.

[0109] S306: The kernel compares the actual measurement value with the reference measurement value.

[0110] If the actual measurement value and the reference measurement value are the same, step S307 is executed; if the actual measurement value and the reference measurement value are different, step S308 is executed.

[0111] The specific implementation of step S306 can refer to the description of step S205, which will not be repeated here.

[0112] S307: The kernel accepts the application process's access to the target file.

[0113] S308: The kernel denies the application process access to the target file.

[0114] The specific implementation of steps S307-S308 can refer to the description of steps S206-S207, which will not be repeated here.

[0115] In the embodiment of the present application, by distinguishing between read operations and write operations, different security policies can be adopted for different access types. For write operations, stricter checks can be performed to prevent malicious tampering with file contents, while for read operations, trustworthy checks can be performed to ensure that the read data is reliable.

[0116] In another possible implementation, trustworthiness verification can also be performed on different files. Figure 4 As shown, Figure 4 A flowchart of another file access method provided in an embodiment of the present application is as follows.

[0117] S401: The application process sends a file access request to the kernel.

[0118] The specific implementation of step S401 can refer to the description of step S201, which will not be repeated here.

[0119] S402: The kernel intercepts the file access request.

[0120] The specific implementation of step S402 can refer to the description of step S202, which will not be repeated here.

[0121] S403: The kernel determines the target file according to the file access request.

[0122] The specific implementation of step S403 can refer to the description of step S203, which will not be repeated here.

[0123] S404: The kernel determines whether the target file needs to be verified for credibility.

[0124] The trusted module also includes a trusted verification list. The trusted verification list includes the file paths of multiple files that need to be trusted before access. When accessing files in the trusted verification list, the kernel needs to first perform a trusted verification on the file. Only after the verification passes can the application process access the file; when the application process requests to access files outside the trusted verification list, no trusted verification is required and it can be accessed directly.

[0125] The files in the trusted verification list can be flexibly configured according to the importance of the files and the usage scenarios. For example, commonly used temporary files, cache files, etc. can be excluded from the trusted verification, while important configuration files and key files can be protected. This makes it convenient for technicians to perform customized management according to business needs. As an example, the files in the trusted verification list are sensitive files.

[0126] After determining the target file, the kernel calls the trusted module driver to query the trusted verification list in the trusted module. If the trusted verification list includes the file path of the target file, it indicates that the target file needs to be trusted, and then step S405 is executed; if the trusted verification list does not include the file path of the target file, it indicates that the target file does not need to be trusted, and then step S407 is executed.

[0127] S405: The kernel obtains the actual measurement value and the reference measurement value of the target file.

[0128] S406: The kernel compares the actual measurement value with the reference measurement value.

[0129] If the actual measurement value and the reference measurement value are the same, step S407 is executed; if the actual measurement value and the reference measurement value are different, step S408 is executed.

[0130] S407: The kernel accepts the application process's access to the target file.

[0131] S408: The kernel denies the application process access to the target file.

[0132] The specific implementation of steps S405-S408 can refer to the description of steps S204-S207, which will not be repeated here.

[0133] In the embodiment of the present application, by performing a trustworthy check on the files in the trustworthy check list, the system can reduce unnecessary resource consumption. Directly accessing files that do not require a trustworthy check can reduce system overhead and improve the overall speed and response time of file access.

[0134] In another possible implementation, the access type and different files can be combined to perform trust verification. Figure 5 As shown, Figure 5 A flowchart of a file access method provided in an embodiment of the present application is as follows.

[0135] S501: The application process sends a file access request to the kernel.

[0136] S502: The kernel intercepts the file access request.

[0137] S503: The kernel determines the target file according to the file access request.

[0138] The specific implementation of steps S501-S503 can refer to the description of steps S201-S203, which will not be repeated here.

[0139] S504: The kernel determines whether the target file needs to be verified for credibility.

[0140] If the target file needs to be verified for credibility, execute step S505; if the target file does not need to be verified for credibility, execute step S508.

[0141] The specific implementation of step S504 can refer to the description of step S404, which will not be repeated here.

[0142] S505: The kernel determines the access type according to the file access request.

[0143] If the access type is a read operation, step S506 is executed; if the access type is a write operation, other subsequent steps are continued to be executed according to the settings of the technician.

[0144] As an example, if the access type is a write operation, step S509 can be executed to prevent the application process from maliciously tampering with the target file; as another example, if the access type is a write operation, the application process can be directly allowed to write to the target file so that the application process can access the target file to perform tasks.

[0145] The specific implementation of step S505 can refer to the description of step S303, which will not be repeated here.

[0146] S506: The kernel obtains the actual measurement value and the reference measurement value of the target file.

[0147] S507: The kernel compares the actual measurement value with the reference measurement value.

[0148] If the actual measurement value and the reference measurement value are the same, step S508 is executed; if the actual measurement value and the reference measurement value are different, step S509 is executed.

[0149] S508: The kernel accepts the application process's access to the target file.

[0150] S509: The kernel denies the application process access to the target file.

[0151] The specific implementation of steps S506-S509 can refer to the description of steps S204-S207, which will not be repeated here.

[0152] The above embodiments respectively introduce the implementation process of the file access method. Based on the above embodiments, the present application further provides other embodiments, which are introduced one by one below.

[0153] In a possible implementation, when the kernel determines that the actual measurement value of the target file is different from the reference measurement value, the kernel may perform file recovery on the target file in the memory.

[0154] If the actual measurement value of the target file is different from the reference measurement value, it means that the target file has been maliciously tampered with or damaged. The kernel can restore the target file to the state before the tampering or damage.

[0155] Specifically, the kernel queries the memory for the backup file of the target file. For example, the kernel calls the memory driver to determine the backup file in the memory according to the backup path of the target file. The file content of the backup file is the file content when the file is stored in the memory, or the file content after the file is legally modified. If the file has not been legally modified since it was stored in the memory, the file content of the backup file is the same as the file content of the file when it was just stored in the memory; if the file has been legally modified during the storage process, the file content of the backup file is the same as the file content after the most recent legal modification of the file. In short, the backup file refers to the image file of the target file that has not been maliciously modified or damaged. The kernel can use the backup file of the target file to restore the target file that has been maliciously tampered with or damaged.

[0156] In an embodiment of the present application, by using backup files for automatic recovery when the target file is maliciously tampered with or damaged, the reliability and security of the file system and file access are enhanced, the loss and unauthorized changes of critical data are prevented, and the recovery cost and operational complexity are reduced.

[0157] Furthermore, after determining the backup file of the target file, the kernel may first perform a credibility check on the backup file, and then use the backup file to restore the target file after the check passes, thereby ensuring the integrity and consistency of the file content.

[0158] Specifically, the kernel calls the storage driver to read the file content of the backup file, and calls the trusted module driver to send the file content of the backup file to the trusted module. The trusted module calculates the actual measurement value of the backup file based on the file content of the backup file. After the kernel finds the reference measurement value of the target file from the measurement value list in the trusted module according to the file path of the target file, it compares the reference measurement value of the target file with the actual measurement value of the backup file. If the reference measurement value of the target file is the same as the actual measurement value of the backup file, it indicates that the backup file has not been maliciously tampered with or damaged, and the backup file is used to restore the target file; if the reference measurement value of the target file is different from the actual measurement value of the backup file, it indicates that the backup file has also been maliciously tampered with or damaged, and the recovery of the target file is stopped.

[0159] In another possible implementation, if the access type of the file access request is a write operation, and the kernel allows the application process to write to the target file, then after the application process completes the write operation to the target file, the kernel updates the reference measurement value of the target file in the trusted module. Specifically, the kernel reads the file content of the modified target file, calls the trusted module driver to send the modified file content to the trusted module. The trusted module calculates the reference measurement value of the modified target file based on the modified file content, and updates the reference measurement value of the target file in the measurement value list to the reference measurement value of the modified target file.

[0160] In the embodiment of the present application, the kernel promptly updates the reference metric value after the file is legally modified, ensuring that the reference to the target file in the system is always consistent with the actual content, avoiding security risks caused by asynchronous metric values. In addition, it can promptly identify and respond to legal modifications to the file, while preventing unauthorized modifications from affecting the system, thereby improving overall security.

[0161] In another possible implementation, when a new file is added to the memory, a reference measurement value of the new file is synchronously added to the trusted module.

[0162] Specifically, when a new file is stored in the memory, the kernel calls the storage interface to read the file content of the new file and sends the file content of the new file to the trusted module. The trusted module calculates the metric value of the new file, stores the file path of the new file in the metric value list, and stores the metric value of the new file as a reference metric value.

[0163] In addition, if the memory includes a trusted verification list, and the newly added file is a file that needs to be trusted before access, the file path of the newly added file is synchronously added to the trusted verification list.

[0164] In the embodiment of the present application, when a new file is added to the memory, the reference measurement value in the trusted module is automatically and synchronously updated to ensure the integrity and credibility of the new file. When the kernel creates a file, it stores the measurement value calculated from its content in the trusted module, thereby achieving real-time monitoring and management of new files. Improving the system's security protection capabilities for new files helps to quickly identify potential malicious file modifications and corruption behaviors, thereby enhancing data security and reliability.

[0165] In another possible implementation, when a file is deleted from the memory, the reference measurement value of the file is deleted in the trusted module synchronously. If the memory includes a trusted verification list, and the file is a file that needs to be trusted before access, the file path of the file is deleted synchronously in the trusted verification list.

[0166] In the embodiment of the present application, when a file is deleted in the memory, the corresponding reference measurement value and file path are deleted in the trusted module and the trusted verification list synchronously to ensure the consistency and integrity of the file status in the system. This effectively cleans up the file information that is no longer needed, avoids redundant data and potential safety hazards, simplifies management and maintenance work, and improves the security and efficiency of the system.

[0167] The above are some specific implementation methods of the file access method provided in the embodiments of the present application. Based on this, the embodiments of the present application also provide corresponding computing devices (such as servers) and computer storage media for implementing the solutions provided in the embodiments of the present application.

[0168] The computing device includes a processor and a memory communicatively connected to the processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes so that the device executes the file access method described in any embodiment of the present application.

[0169] The computer storage medium stores codes, and when the codes are executed, the device executing the codes implements the file access method described in any embodiment of the present application.

[0170] The "first" and "second" in the names such as "first" and "second" (if any) mentioned in the embodiments of the present application are only used as name identifiers and do not represent the first or second in order.

[0171] Through the description of the above implementation methods, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment method can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment of the present application or some parts of the embodiments.

[0172] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0173] The above description is merely an exemplary embodiment of the present application and is not intended to limit the protection scope of the present application.

Claims

1. A file access method, characterized in that: include: In the case where the application process calls the file system call interface to send a file access request to the kernel, the kernel executes a file access function to intercept the file access request; The file access request is used to request access to a target file; The application process runs in the user space; the file access function is a function added to the kernel based on the Linux security module framework for implementing file trust verification; the file access function is executed in the kernel; The kernel executes the file access function to obtain a reference measurement value and an actual measurement value of the target file; the actual measurement value is used to describe the current data volume of the target file, and the reference measurement value is used to describe the data volume of the target file when it has not been maliciously tampered with or damaged; In a case where the actual metric value is equal to the reference metric value, the kernel requests access to the target file through the application process.

2. The method according to claim 1, characterized in that: The file access request includes an access type to the target file, and the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including: When it is determined that the access type to the target file indicated by the file access request is a read operation, the kernel executes the file access function to call a trusted module to obtain a reference measurement value and an actual measurement value of the target file. The method further comprises: When it is determined that the access type to the target file indicated by the file access request is a write operation, the kernel rejects the access request to the target file by the application process.

3. The method according to claim 1 or 2, characterized in that: The file access request includes a file path of the target file, and before the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, the method further includes: The kernel obtains a trusted verification list from the trusted module; the trusted verification list includes file paths of multiple files that need to be trusted before access; The kernel queries whether the trusted verification list includes the file path of the target file; The kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including: In case it is determined that the trusted verification list includes the file path of the target file, the kernel obtains the reference measurement value and the actual measurement value of the target file from the trusted module.

4. The method according to claim 3, characterized in that The method further comprises: In the case that the file path of the target file is not found in the trusted verification list, the kernel requests access to the target file through the application process.

5. The method according to claim 1, characterized in that The file access request includes a file path of the target file, and the kernel executes the file access function to obtain a reference metric value and an actual metric value of the target file, including: The kernel calls the trusted module driver to query the metric value list in the trusted module, and determines the reference metric value corresponding to the file path of the target file from the metric value list; the metric value list includes the file path and reference metric value of the file that needs to be trusted before access; The kernel calls the memory driver, reads the target file from the memory according to the file path of the target file, and calls the trusted module driver to send the file content of the target file to the trusted module, so as to calculate the actual measurement value of the target file using the trusted module.

6. The method according to claim 1, characterized in that The method further comprises: In a case where the actual metric value is greater than or less than the reference metric value, the kernel denies the application process's request to access the target file.

7. The method according to claim 6, characterized in that In the case where the actual measurement value is greater than or less than the reference measurement value, the method further includes: The kernel calls the storage driver to query the backup file of the target file from the storage according to the file path of the target file; The kernel reads the backup file, sends the file content of the backup file to the trusted module, and uses the trusted module to calculate the actual measurement value of the backup file; When the actual measurement value of the backup file is the same as the reference measurement value of the target file, the target file is restored using the backup file.

8. The method according to claim 1, characterized in that The method further comprises: When a file is modified, the kernel updates the reference measurement value in the trusted module.

9. The method according to claim 8, characterized in that The updating of the reference measurement value in the trusted module includes: When a file in the memory is modified, the kernel reads the modified file and sends the file content of the modified file to the trusted module to calculate and obtain a reference metric value of the modified file; The kernel updates the reference metric value corresponding to the file path of the modified file in the trusted module by using the reference metric value of the modified file.

10. A server, characterized in that: comprising a processor, and a memory communicatively connected to the processor; The memory is used to store computer-executable instructions; The processor is used to execute the computer-executable instructions stored in the memory to implement the file access method described in any one of claims 1-9.