A security policy loading method and device, electronic equipment and readable storage medium

By mounting the target file system in the vehicle system and merging the target security policy file, the problem of low efficiency in selinux security policy development is solved, efficient management and updating of independent policy files are achieved, and development efficiency is improved.

CN115203704BActive Publication Date: 2025-10-17FIBOCOM AUTO INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210855021.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-19
Publication Date
2025-10-17
Estimated Expiration
2042-07-19

Smart Images

  • Figure CN115203704B_ABST
    Figure CN115203704B_ABST
Patent Text Reader

Abstract

The application discloses a security policy loading method and device, electronic equipment and a readable storage medium. The method comprises the following steps: mounting a target file system, and obtaining a target security policy file from the target file system; if the number of the target security policy files is greater than one, performing a merging processing on the target security policy files to obtain a merged security policy file; and loading the merged security policy file. Since the target security policy files are independent of each other and do not interfere with each other, the target security policy files are only merged and loaded when being used, so that even if the target security policy file of a certain manufacturer is updated, the other target security policy files are not affected, and the merging operation is not required, thereby improving the development efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a security policy loading method, a security policy loading device, an electronic device and a computer readable storage medium. BACKGROUND

[0002] SELINUX is a security subsystem of linux kernel, which determines the access relationship between processes and resources through the security context of processes and resources. The requirement for safety of vehicle-mounted products is very high, so almost all vehicle-mounted projects need to develop selinux. The development of selinux by vehicle-mounted projects involves many manufacturers, and each manufacturer independently writes the policy of selinux and obtains the corresponding security policy file. However, since the security policy of selinux is loaded only once in the init process, whenever the security policy file of a manufacturer changes, the security policy of selinux needs to be generated and burned after all the policy files of the manufacturers are combined, so as to be loaded by selinux, which makes it necessary to frequently generate and burn the security policy of selinux, and the development efficiency is low. SUMMARY

[0003] Therefore, the purpose of the present application is to provide a security policy loading method, a security policy loading device, an electronic device and a computer readable storage medium, which improve the development efficiency.

[0004] To solve the above technical problems, the present application provides a security policy loading method, comprising:

[0005] mounting a target file system and obtaining a target security policy file from the target file system;

[0006] if the number of target security policy files is greater than one, performing a merging process on the target security policy files to obtain a merged security policy file;

[0007] loading the merged security policy file.

[0008] Optionally, the target file system comprises a root file system;

[0009] the obtaining of the target security policy file from the target file system comprises:

[0010] determining whether there is a target UBI file system;

[0011] if there is the target UBI file system, obtaining corresponding target security policy files from the root file system and the target UBI file system respectively.

[0012] Optionally, if the target UBI file system does not exist, comprising:

[0013] obtaining a target security policy file from the root file system, and loading the target security policy file by using a kernel loading process.

[0014] Optionally, if the target UBI file system exists, further comprising:

[0015] if a policy file update request is detected, determining a target UBI file system to be updated, and obtaining an updated policy file;

[0016] burning the updated policy file into a storage partition corresponding to the target UBI file system to be updated.

[0017] Optionally, the merging processing of the target security policy file to obtain a merged security policy file, comprising:

[0018] determining whether there is a contradictory policy among the target security policy files;

[0019] if there is no contradictory policy, merging the target security policy file and the preset security policy file to generate the merged security policy file.

[0020] Optionally, the mounting of the target file system, comprising:

[0021] if a security policy loading event is detected to be triggered, mounting the target file system.

[0022] Optionally, the detection of the security policy loading event being triggered, comprising:

[0023] if an operating system is detected to be started, determining that the security policy loading event is triggered.

[0024] The application further provides a security policy loading device, comprising:

[0025] a policy obtaining module, configured to mount a target file system, and obtain a target security policy file from the target file system;

[0026] a merging processing module, configured to if the number of the target security policy files is greater than one, perform merging processing on the target security policy files to obtain a merged security policy file;

[0027] a merging loading module, configured to load the merged security policy file.

[0028] The application further provides an electronic device, comprising a memory and a processor, wherein:

[0029] the memory is configured to save a computer program;

[0030] The processor is configured to execute the computer program to implement the security policy loading method.

[0031] The application further provides a computer readable storage medium for storing a computer program, wherein the computer program is executed by a processor to implement the security policy loading method.

[0032] The security policy loading method provided by the application mounts a target file system and obtains a target security policy file from the target file system; if the number of target security policy files is greater than one, the target security policy files are combined to obtain a combined security policy file; and the combined security policy file is loaded.

[0033] It can be seen that the method does not generate and burn all the combined security policy files of manufacturers in advance, but places the target security policy files of each manufacturer in the corresponding target file system. When the target file system is mounted by the operating system, the target security policy files can be obtained by scanning and querying the target file system, and the target security policy files are combined to obtain a combined security policy file when the number of target security policy files is greater than one, and the combined security policy file is loaded. Since each target security policy file is independent of each other and does not interfere with each other, the target security policy file is only combined and loaded when it is used, so even if the target security policy file of a manufacturer is updated, it will not affect other target security policy files, and the combined operation is not required, thereby improving the development efficiency.

[0034] In addition, the application further provides a security policy loading device, an electronic device and a computer readable storage medium, which also have the above beneficial effects. BRIEF DESCRIPTION OF DRAWINGS

[0035] In order to more clearly illustrate the technical solutions in the embodiments of the application or the related art, the following will briefly introduce the drawings needed to be used in the embodiment or related art description. Obviously, the drawings in the following description are only embodiments of the application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.

[0036] Figure 1 A security policy loading method flow chart provided by the embodiment of the application;

[0037] Figure 2 A specific security policy loading method flow chart provided by the embodiment of the application;

[0038] Figure 3 A structure diagram of a security policy loading device provided by the embodiment of the application;

[0039] Figure 4 A structural schematic diagram of an electronic device is provided for the embodiments of the present application. DETAILED DESCRIPTION

[0040] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0041] For reference Figure 1 , Figure 1 A security policy loading method flow chart is provided for the embodiments of the present application.

[0042] The method comprises the following steps.

[0043] S101: mounting a target file system and obtaining a target security policy file from the target file system.

[0044] It should be noted that the present application can be executed by a specified electronic device, which can run based on a Linux operating system. The specific form of the electronic device is not limited, for example, it can be a vehicle-mounted electronic device, for example, a TBOX (Telematics BOX, remote information box) device on a vehicle.

[0045] When it is necessary to load a security policy file, a target file system can be mounted, which is a file system having a security policy file itself, and its specific type is not limited. For example, since Linux itself has a security subsystem of selinux, the security subsystem has a security policy file (which can be referred to as policy0), therefore, the root file system of Linux itself can be regarded as a kind of target file system. In addition, in another embodiment, a security policy file can be added in a UBI (Unsorted Block Images, a volume management system of a flash device) file system, so as to make it another target file system. It can be understood that there can be multiple UBI file systems, for example, when multiple manufacturers develop security policies in parallel, a corresponding UBI file system can be set for each manufacturer.

[0046] It should be noted that the embodiment is not limited to the case of mounting the target file system, i.e., the triggering condition of the operation of loading the security policy is not limited. Specifically, a security policy loading event can be set, and when it is detected that the security policy loading event is triggered, the operation of mounting the target file system is performed. The embodiment is not limited to the specific content and form of the security policy loading event. For example, in one embodiment, since the electronic device needs to work based on the security policy, the security policy loading event can be determined as the event of starting the operating system, i.e., when the starting of the operating system is detected, it is determined that the security policy loading event is triggered. In another embodiment, the security policy can be updated, e.g., when a manufacturer updates the policy file in the corresponding UBI file system, in order to use the new security policy as soon as possible, the security policy can also be reloaded. That is, the update of the target file system (including the forms of increase, decrease, and content change) can be determined as a security policy loading event.

[0047] After the target file system is mounted, the mounted file system can be accessed to obtain the corresponding target security policy file. It can be determined that since the security policy is to be loaded, the original security policy in the operating system must be used, and it can be determined that the target file system should include the root file system. In addition, when the target security policy file is obtained, it can be determined whether the target UBI file system exists, i.e., the UBI file system having the security policy file, and the specific detection method is not limited. For example, in one embodiment, each UBI file system can be mounted in a different nand flash (a kind of computer storage device) partition, and by querying whether the policy file exists in each nand flash partition, it can be determined whether it is the target UBI file system. The policy file can be referred to as a policy file, and it can be identified by its format and other factors. If the target UBI file system exists, the corresponding target security policy file is obtained from the root file system and the target UBI file system, respectively. It can be understood that in this case, the obtained target security policy file must be greater than one. If the target UBI file system does not exist, the target security policy file can only be obtained from the root file system at this time. Since the target security policy file is only one, it is not necessary to be merged, and therefore the target security policy file can be directly loaded by the kernel loading process (or referred to as the Init process, which is the first process loaded after the kernel starts).

[0048] S102: If the number of target security policy files is greater than one, the target security policy files are merged to obtain a merged security policy file.

[0049] Since the electronic device can only run based on one policy file, if the number of target security policy files is greater than one, it is necessary to merge them to obtain a merged security policy file covering all target security policy files. The merged security policy file includes the contents of all target security policy files, including common contents and non-common contents, and the specific merging manner is not limited, and existing tools can be used for merging.

[0050] In order to improve efficiency and avoid waste of computing resources, before the merging process, it can be first determined whether there are contradictory policies between the target security policy files. Contradictory policies are security policies with opposite purposes. It can be understood that if there are contradictory policies, no matter how the security policy files are merged, it is impossible to cover all the contents of all target security policy files, and forcibly merging them will only waste computing resources and time. If there are no contradictory policies, the target security policy files and the preset security policy file are used to generate a merged security policy file.

[0051] S103: Load the merged security policy file.

[0052] After the merging is completed, it is loaded, for example, a special loading tool can be set to complete the loading of the merged security policy file by using the loading tool, and the electronic device can run based on the merged security policy file.

[0053] In addition, since each target security policy file corresponds to a different target file system, updating a target security policy file does not interfere with other target security policy files. Generally, the policy file of selinux does not change, and therefore, if a target UBI file system exists, a policy file of the target UBI file system can be updated by a policy file update request. Specifically, the policy file update request is used to indicate a target UBI file system that needs to be updated, and in addition, an updated policy file can be directly or indirectly provided. Therefore, if the policy file update request is detected, the target UBI file system that needs to be updated can be determined, and the updated policy file can be obtained. For example, the unique identification information of the target UBI file system and the updated policy file or the storage location information corresponding to the policy file can be obtained from the policy file update request. The policy file update request and the updated policy file can be obtained in a wired or wireless manner, for example, can be obtained in a wired manner through a USB (Universal Serial Bus) interface or can be obtained in a wireless manner through OTA (Over-the-Air Technology). The updated policy file is overwritten and burned into the storage partition corresponding to the target UBI file system that needs to be updated, and the update of the policy file is completed. It should be noted that the updated policy file can only include the content related to the security policy, or can also include other data content that needs to be updated synchronously when updating the security policy. For example, in an embodiment, the updated policy file can be an entire UBI image file, and the target UBI file system that needs to be updated is updated by replacing the entire UBI image, and the update of the security policy is completed.

[0054] Please refer to Figure 2 , Figure 2 A specific security policy loading method flowchart is provided for the embodiments of the present application. In actual application, a scanning process can be set on an electronic device. First, the system is powered on, and after the kernel (i.e., the kernel) is initialized, the init process mounts the root file system, which includes the files required by selinux, and then loads the policy0 file. In another embodiment, the init can also not load the policy0. After the policy0 file is loaded, the initial policy of selinux is effective. Then, each nand flash partition corresponding to the ubi image (i.e., the UBI file system, mtd is a memory technology device, which is a Linux subsystem for accessing a storage device) is mounted, and after mounting all the file systems of the ubi image, the operating system queries all the policy files in each file system by using the scanning process. For example,Figure 2 As shown, in addition to policy0, there are policy1, policy2, policy3, policy4, and policy5, which correspond to the respective policies of different manufacturers and are developed and maintained by the respective manufacturers. The five policy files are combined into a combined policy by using a scanning process, and then the combined policy is loaded. If only policy0 exists in the system, there is no need to load, because policy0 is loaded by default in the init process.

[0055] Specifically, the root file system can be referred to as system.ubi, the file system corresponding to manufacturer 1 can be referred to as a.ubi, the file system corresponding to manufacturer 2 can be referred to as b.ubi, and the file system corresponding to manufacturer 3 can be referred to as c.ubi. The system.ubi is the root file system, and a default policy file exists therein. Manufacturers 1, 2, and 3 can place various policies in the respective ubis corresponding thereto, and write the corresponding ubis to the flash of the electronic device. After the operating system is started, the corresponding ubis are mounted, and the corresponding file directories have the corresponding policy files. The operating system searches for all the policies, combines the policies into a complete policy, and then loads the combined policy. Therefore, if a manufacturer needs to update a policy file, the manufacturer only needs to modify the policy file corresponding thereto, and then generate a new ubi to be written to the flash, thereby achieving the effect of mutual independence and non-interference.

[0056] The safety policy loading method provided in the embodiments of the present application does not generate and burn a combined policy file of all the safety policy files of the manufacturers in advance, but places the target safety policy files of the manufacturers in the corresponding target file systems. When the target file systems are mounted by the operating system, the target file systems can be scanned and queried to obtain the target safety policy files, and when the number of the target safety policy files is greater than one, the target safety policy files are combined to obtain a combined safety policy file, and the combined safety policy file is loaded. Because the target safety policy files are independent of each other and do not interfere with each other, and are only combined and loaded when used, even if the target safety policy file of a manufacturer is updated, the other target safety policy files are not affected, and no combining operation is needed, thereby improving the development efficiency.

[0057] The safety policy loading device provided in the embodiments of the present application is described below. The safety policy loading device described below can be correspondingly referred to the safety policy loading method described above.

[0058] Please refer to Figure 3 , Figure 3A structural schematic diagram of a security policy loading device provided by an embodiment of the present application comprises:

[0059] A policy obtaining module 110 is configured to mount a target file system and obtain target security policy files from the target file system.

[0060] A merging processing module 120 is configured to perform merging processing on the target security policy files to obtain a merged security policy file if the number of the target security policy files is greater than one.

[0061] A merging loading module 130 is configured to load the merged security policy file.

[0062] Optionally, the target file system comprises a root file system.

[0063] The policy obtaining module 110 comprises:

[0064] A judging unit is configured to judge whether a target UBI file system exists.

[0065] An extracting unit is configured to obtain corresponding target security policy files from the root file system and the target UBI file system respectively if the target UBI file system exists.

[0066] Optionally, if the target UBI file system does not exist, the device comprises:

[0067] A direct loading module is configured to obtain target security policy files from the root file system and load the target security policy files by using a kernel loading process.

[0068] Optionally, if the target UBI file system exists, the device further comprises:

[0069] An update obtaining module is configured to determine a target UBI file system to be updated and obtain updated policy files if a policy file update request is detected.

[0070] An update burning module is configured to overwrite and burn the updated policy files into a storage partition corresponding to the target UBI file system to be updated.

[0071] Optionally, the merging processing module 120 comprises:

[0072] A contradiction detecting unit is configured to judge whether there are contradictory policies among the target security policy files.

[0073] A merging unit is configured to generate the merged security policy file by merging the target security policy files and the preset security policy file if the contradictory policies do not exist.

[0074] Optionally, the mounting the target file system comprises:

[0075] a triggering unit, configured to mount the target file system if it is detected that the security policy loading event is triggered.

[0076] Optionally, the triggering unit comprises:

[0077] a starting triggering sub-unit, configured to determine that the security policy loading event is triggered if it is detected that the operating system is started.

[0078] The electronic device provided by the embodiments of the present application is described below. The electronic device described below can be referred to in conjunction with the security policy loading method described above.

[0079] Please refer to Figure 4 , Figure 4 A structural schematic diagram of an electronic device provided by the embodiments of the present application is shown in FIG. 1. The electronic device 100 can include a processor 101 and a memory 102, and can further include one or more of a multimedia component 103, an information input / output (I / O) interface 104, and a communication component 105.

[0080] The processor 101 is configured to control the overall operation of the electronic device 100 to complete all or part of the steps of the security policy loading method described above. The memory 102 is configured to store various types of data to support the operation of the electronic device 100. For example, the data can include instructions for operating any application or method on the electronic device 100, and application-related data. The memory 102 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as one or more of a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.

[0081] The multimedia component 103 can include a screen and an audio component. The screen can be, for example, a touch screen, and the audio component can be configured to output and / or input audio signals. For example, the audio component can include a microphone configured to receive external audio signals. The received audio signals can be further stored in the memory 102 or transmitted through the communication component 105. The audio component can also include at least one speaker configured to output audio signals. The I / O interface 104 provides an interface between the processor 101 and other interface modules, which can be a keyboard, a mouse, a button, and the like. The buttons can be virtual buttons or physical buttons. The communication component 105 is configured to perform wired or wireless communication between the electronic device 100 and other devices. The wireless communication can be, for example, Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of one or more of them, and thus the communication component 105 can include a Wi-Fi component, a Bluetooth component, and an NFC component.

[0082] The electronic device 100 can 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 elements for performing the security policy loading method according to the above-described embodiments.

[0083] The computer-readable storage medium according to the embodiments of the present application is described below. The computer-readable storage medium described below can be referred to in conjunction with the security policy loading method described above.

[0084] The present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the security policy loading method described above are implemented.

[0085] The computer-readable storage medium can include a U disk, a mobile hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0086] The various embodiments described in this specification are presented by way of example, and each embodiment is not necessarily composed of all features described. Each embodiment described in this specification focuses on differentiating aspects from other embodiments, and each embodiment can be combined with any other embodiment described in this specification. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts are described in the method part.

[0087] Those skilled in the art will further appreciate that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, various aspects of each example have been described in general terms above by focusing on the functions implemented by each example. Whether such functions are implemented as hardware or software depends on the particular application and design constraints imposed on the overall system. Those skilled in the art can implement the described functions in varying ways for each particular application, but such implementation should not be interpreted to be beyond the scope of the present application.

[0088] The steps of the methods or algorithms described in connection with the embodiments disclosed herein can be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software module can be stored in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0089] Finally, it should be noted that the terms such as first and second, etc., are used herein merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between such entities or operations. Moreover, the term including, comprising, or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or apparatus including a series of elements includes not only those elements, but also other elements not explicitly listed, or other elements inherent in such a process, method, article, or apparatus.

[0090] The principles and implementation modes of the present application are described using specific examples in this specification, and the above description of the examples is only to help understand the method and core idea of the present application; for those skilled in the art, according to the idea of the present application, the specific implementation mode and application range can be changed, and the above description of the specification should not be understood as limiting the present application.

Claims

1. A security policy loading method, characterized in that: include: Mounting the target file system and obtaining the target security policy file from the target file system; If the number of the target security policy files is greater than one, merging the target security policy files to obtain a merged security policy file; Loading the merged security policy file; The target file system includes a root file system; Obtaining a target security policy file from the target file system includes: Determine whether the target UBI file system exists; If the target UBI file system exists, obtaining corresponding target security policy files from the root file system and the target UBI file system respectively; If the target UBI file system exists, the method further includes: If a policy file update request is detected, the target UBI file system to be updated is determined, and the updated policy file is obtained; Burn the updated policy file into the storage partition corresponding to the target UBI file system to be updated; The mounting target file system includes: If it is detected that the security policy loading event is triggered, the target file system is mounted.

2. The security policy loading method according to claim 1, characterized in that: If the target UBI file system does not exist, including: A target security policy file is obtained from the root file system, and the target security policy file is loaded using a kernel loading process.

3. The security policy loading method according to claim 1, characterized in that: The merging of the target security policy files to obtain a merged security policy file includes: Determine whether there are conflicting policies between the target security policy files; If the conflicting policies do not exist, the target security policy files are merged to generate the merged security policy file.

4. The security policy loading method according to claim 1, characterized in that: The detecting that a security policy loading event is triggered includes: If it is detected that the operating system is started, it is determined that the security policy loading event is triggered.

5. A security policy loading device, characterized in that: include: A policy acquisition module, configured to mount a target file system and obtain a target security policy file from the target file system; a merging processing module, configured to merge the target security policy files to obtain a merged security policy file if the number of the target security policy files is greater than one; A merge loading module, used for loading the merged security policy file; The target file system includes a root file system; The strategy acquisition module includes: A judgment unit, used to judge whether a target UBI file system exists; an extraction unit, configured to obtain corresponding target security policy files from the root file system and the target UBI file system respectively if the target UBI file system exists; If the target UBI file system exists, the method further includes: The update acquisition module is used to determine the target UBI file system to be updated and obtain the updated policy file if a policy file update request is detected; An update burning module, configured to burn the updated policy file into the storage partition corresponding to the target UBI file system to be updated; The policy acquisition module is specifically configured to mount the target file system and obtain a target security policy file from the target file system if it is detected that a security policy loading event is triggered.

6. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store computer programs; The processor is configured to execute the computer program to implement the security policy loading method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that Used to store a computer program, wherein when the computer program is executed by a processor, the security policy loading method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Updating monitoring systems using merged data policies

    US20180330107A1

  • Policy aggregation

    US20190373021A1