Operating system permission control methods and electronic devices

By binding hardware access permissions with target constraints and security handles, the identity and runtime environment of third-party applications are dynamically verified, solving the problem that traditional SELinux policies cannot distinguish between legitimate and malicious operations, thus improving the security and stability of the operating system.

CN123069338APending Publication Date: 2026-11-10GREAT WALL MOTOR CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611405568.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-10
Publication Date
2026-11-10

AI Technical Summary

Technical Problem

Traditional SELinux policies have limitations due to their static and coarse-grained nature. Once a third-party application gains access, it can perform any operation on the hardware throughout its lifecycle, making it impossible to effectively distinguish between legitimate reads and malicious tampering, thus leading to security risks.

Method used

By restricting the permissions of third-party applications through target constraints, querying the current operating system environment, dynamically determining access policies, binding hardware access permissions to the kernel mapping table using security handles, and verifying the identity of third-party applications and access requests in real time.

Benefits of technology

It effectively prevents destructive operations by third-party applications after hijacking, improves the security and stability of the operating system, and enhances the strictness and reliability of hardware access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123069338A_ABST
    Figure CN123069338A_ABST
Patent Text Reader

Abstract

This application provides a method for controlling operating system permissions and an electronic device. The method, applied in the field of intelligent connected vehicles, includes: responding to an access request from a third-party application; querying target constraints based on the access request; and obtaining the current operating environment associated with the target constraints in the operating system. The target constraints characterize the licensed environment that allows the execution of the access request from the third-party application, where the access request is for accessing the driver path of the target hardware operated by the third-party application; determining a target policy based on the target constraints and the current operating environment; and executing the target policy for the access request. This method restricts the usage permissions of third-party applications through target constraints to prevent third-party applications from being unrestrained by the operating system's operating environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intelligent connected vehicles, specifically to a method for controlling operating system permissions and an electronic device. Background Technology

[0002] Security-Enhanced Linux (SELinux) is a security subsystem module in the Linux operating system kernel. SELinux is an implementation of Mandatory Access Control (MAC), which uses security policies to enforce the access permissions allowed by the system. Under this access control framework, processes can only access resources necessary for their tasks, and operations outside the permitted scope will be blocked by the system.

[0003] However, traditional SELinux policies are typically limited by their static and coarse-grained (process-level / file-level) nature. Once a third-party application is granted control over a node, it can perform any operation on that node for its entire lifecycle, unrestricted by the SELinux runtime environment. This mechanism cannot effectively distinguish between legitimate read operations and malicious tampering. If a third-party application is hijacked, attackers can use the acquired SELinux privileges to perform destructive writes to the hardware, posing unpredictable security risks to electronic devices. Summary of the Invention

[0004] This application provides a method and electronic device for controlling operating system permissions. This method can restrict the usage permissions of third-party applications through target constraints to prevent third-party applications from being unrestrained by the operating system's operating environment.

[0005] Firstly, a method for controlling operating system permissions is provided, the method comprising: In response to an access request from a third-party application, the target constraints are queried based on the access request from the third-party application, and the current operating environment associated with the target constraints in the operating system is obtained. The target constraints are used to characterize the licensed environment that allows the execution of the access request from the third-party application, and the access request is used to access the driver path of the target hardware operated by the third-party application. Determine the target strategy based on the target constraints and the current operating environment; Execute the target policy for this access request.

[0006] By responding to access requests from third-party applications, querying the target constraints corresponding to the third-party applications, and obtaining the current operating system environment, dynamic permission control of third-party applications based on the current operating system environment is achieved. This scheme binds the access permissions of hardware driver paths to the current permission environment of the operating system, ensuring that third-party applications can only execute target policies under preset security conditions. This not only effectively prevents destructive operations by third-party applications after hijacking but also significantly improves the security protection capabilities and stability of the operating system.

[0007] In conjunction with the first aspect, in some possible implementations, the target constraints for the access request query based on the third-party application include: Obtain the security handle carried in the access request, which is the query index for querying the target constraint; Based on the security handle, the target constraint corresponding to the security handle is queried from the kernel mapping table, which stores the mapping relationship between the security handle and the target constraint.

[0008] By using the above method and leveraging the security handle as a query index, the corresponding target constraints are quickly retrieved from the kernel mapping table. This avoids directly exposing the file path of the target hardware, allowing the operating system to perform real-time, dynamic constraint verification on access requests based on the current runtime environment. This not only effectively prevents third-party applications from bypassing security checks to perform illegal operations on the hardware but also significantly enhances the overall security of the operating system.

[0009] In conjunction with the first aspect, in some possible implementations, obtaining the security handle carried in the access request includes: Based on the access request from the third-party application, execute the application identity verification process for the third-party application; If the application identity verification process passes, an idle query index is allocated to the reference kernel mapping table, which stores the mapping relationship between the target constraint and the file descriptor of the target hardware. The query index is identified as the safe handle.

[0010] Using the above method, after the third-party application's identity verification is successful, an idle query index is dynamically allocated to the reference kernel mapping table. This query index is then used as a security handle, establishing a secure association between the application and the reference kernel mapping table. This scheme ensures that only authenticated applications can obtain a valid security handle, and that the security handle corresponds to the target constraints and file descriptors in the reference kernel mapping table. This avoids directly exposing the target hardware's file descriptors through the security handle, further enhancing the tightness and reliability of controlling third-party application access.

[0011] In conjunction with the first aspect, in some possible implementations, the application identity verification process for the third-party application, based on the access request from the third-party application, includes: Extract the identity information of the third-party application from the access request; Verify the identity information in the access request; If the identity information matches the preset identity information, the application's identity verification process is deemed successful. If the identity information does not match the preset identity information, the application's identity verification process is deemed to have failed.

[0012] The above method extracts and verifies the identity information of third-party applications during the access request processing, and verifies the identity of the third-party applications based on this identity information. The verification process only passes when the identity information matches the preset identity information, effectively blocking access requests from illegal or fake applications, preventing malicious applications from masquerading as legitimate applications to obtain operating system privileges, and significantly improving the overall defense capabilities of the operating system.

[0013] In conjunction with the first aspect, in some possible implementations, before allocating a free query index for the reference kernel mapping table after the application identity verification process has passed, the method further includes: Based on the access request, obtain the file descriptor of the target hardware. This file descriptor is used to indicate the driver path of the target hardware corresponding to the third-party application. The target constraint is generated based on the operating system's preset operating environment and the access request from the third-party application. Establish a mapping relationship between the file descriptor and the target constraint, and store it in the reference kernel mapping table; Establish a mapping relationship between the reference kernel mapping table and the security handle, and store it in the kernel mapping table.

[0014] The above method associates the target hardware's file descriptors with target constraints in a reference kernel mapping table, and then associates this table with a security handle in the kernel mapping table. This scheme achieves deep binding between hardware resources, the runtime environment, and access permissions, ensuring that third-party applications can only access the target hardware through security handles under specific target constraints. This not only effectively isolates the actual hardware path, preventing unauthorized access and illegal operations by third-party applications, but also enhances the overall security capabilities of the operating system.

[0015] In conjunction with the first aspect, in some possible implementations, the preset operating environment includes the vehicle's driving status and the user's facial image; the access request includes the access request frequency and the call type; and the target constraint conditions generated based on the preset operating environment of the operating system and the access request of the third-party application include: The first constraint condition is generated based on the vehicle's driving status and the call type; A second constraint is generated based on the user's facial image; A third constraint is generated based on the frequency of this access request. The target constraint is generated based on the first constraint, the second constraint, and the third constraint.

[0016] Using the above method, constraints are generated by comprehensively considering three dimensions: vehicle driving status, user facial image, and access request frequency, and then merged into target constraints. In other words, this solution deeply binds hardware access permissions to vehicle security status, user identity legitimacy, and the rationality of invocation behavior, ensuring that third-party applications only perform operations in a secure and compliant environment. This effectively prevents third-party applications from attacking the operating system without verification, significantly improving the security protection capabilities of the in-vehicle system and the granularity of third-party application permission control.

[0017] In conjunction with the first aspect, in some possible implementations, the target strategy includes a first target strategy and a second target strategy. Determining the target strategy based on the target constraints and the current operating environment includes: Determine whether the current operating environment meets the target constraint. If the current operating environment meets the target constraint, the corresponding file descriptor is parsed from the kernel mapping table based on the security handle; Based on the file descriptor, the target policy is determined to be the first target policy, which is used to execute the access request; If the current operating environment does not meet the target constraint, the target strategy is determined to be the second target strategy, which is used to capture the access request.

[0018] By employing the above method, dynamic traffic routing for access requests is achieved through real-time verification of the operating system's current runtime environment. When the current runtime environment meets the target constraints, the file descriptor is parsed based on the security handle, and the access request is executed, ensuring efficient response to legitimate operations. When the current runtime environment does not meet the target constraints, the access request is captured, effectively blocking illegal or unauthorized operations. This not only avoids the risk of third-party applications abusing their permissions but also significantly improves the operating system's security protection capabilities and operational stability.

[0019] In conjunction with the first aspect, in some possible implementations, the target constraint includes a first constraint, a second constraint, and a third constraint. Determining whether the current operating environment satisfies the target constraint includes: If the current operating environment satisfies the third constraint, then if the first or second constraint is also satisfied, the target constraint is determined to be satisfied. If the current operating environment does not meet the third constraint, then the target constraint is determined not to be met.

[0020] By employing the above method, the third constraint is set as a necessary prerequisite for the target constraint, thereby preventing malicious attacks on the operating system's security by third-party applications. That is, only when the frequency of access requests meets the limit requirements are further verified conditions such as vehicle driving status or the validity of user authorization. This effectively curbs high-frequency abnormal calls or malicious data breaches at the source, avoiding unnecessary complex verification overhead and ensuring the rigor of access control, significantly improving the system's security capabilities and operational efficiency.

[0021] In conjunction with the first aspect, in some possible implementations, if the third constraint condition is satisfied in the current operating environment, before the first or second constraint condition is satisfied, the following further steps are taken: If the vehicle is in motion and the third-party application's call type is a read operation, then the first constraint condition is satisfied. If the vehicle is parked and the user's facial image passes the identity authorization verification, calculate the time difference between the time when the identity authorization verification is passed this time and the time when the identity authorization verification is passed last time. If the time difference is less than or equal to the preset duration, it is determined that the second constraint condition is met; If the frequency of the access request is less than the preset number, the third constraint condition is determined to be satisfied.

[0022] By constructing a constraint system, the above method enables refined control over access permissions for third-party applications. The first constraint allows read operations while the vehicle is in motion, effectively preventing write operations from interfering with driving safety. The second constraint combines parking status, facial recognition authentication, and the time difference between consecutive authorizations to ensure that write operations are only permitted when the user's identity remains valid and the authorization period has not expired, preventing unauthorized write operations after authorization expires. The third constraint effectively curbs abnormally high-frequency call behavior by limiting the frequency of access requests. This solution achieves a harmonious balance between security, efficiency, and compliance, significantly improving the overall security protection capabilities of the in-vehicle system.

[0023] Secondly, an operating system permission control device is provided, the device comprising: The query and retrieval module is used to respond to the access request of a third-party application, query the target constraints based on the access request of the third-party application, and retrieve the current running environment in the operating system associated with the target constraints. The target constraints are used to characterize the licensed environment that allows the execution of the access request of the third-party application. The access request is used to access the driver path of the target hardware operated by the third-party application. The determination module is used to determine the target strategy based on the target constraints and the current operating environment; The execution module is used to execute the target policy for the access request.

[0024] Thirdly, an electronic device is provided, including a memory and a processor. The memory is used to store executable program code, and the processor is used to call and run the executable program code from the memory, causing the electronic device to execute the methods performed by the aforementioned operating system permission control method.

[0025] Fourthly, a computer program product is provided, comprising: computer program code, which, when run on a computer, causes the computer to execute the method executed by the aforementioned operating system permission control method.

[0026] Fifthly, a computer-readable storage medium is provided that stores computer program code, which, when executed on a computer, causes the computer to perform the methods described above for controlling operating system permissions. Attached Figure Description

[0027] Figure 1 This is a schematic diagram illustrating the implementation environment of an operating system permission control method provided in an embodiment of this application; Figure 2 This is a schematic flowchart illustrating an operating system permission control method provided in an embodiment of this application; Figure 3 This is a schematic flowchart illustrating another operating system permission control method provided in an embodiment of this application; Figure 4 This is a schematic flowchart illustrating a method for interaction between a third-party application and an operating system, provided in an embodiment of this application. Figure 5 This is a schematic diagram of the structure of an operating system permission control device provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0028] The technical solutions in this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. "And / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0029] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.

[0030] Before introducing the methods of the embodiments of this application, the technical terms that may be involved in the embodiments of this application will be explained first.

[0031] An operating system is the fundamental system software that manages and controls computer hardware and software resources. An operating system includes a kernel, drivers, system libraries, command-line tools, a graphical interface, and various application software. The operating systems applicable to the embodiments of this application include, but are not limited to, Linux operating systems, Unix-like operating systems, and Linux systems with integrated security enhancement modules (such as security-enhanced Linux systems).

[0032] Security-Enhanced Linux (SELinux) is a Mandatory Access Control (MAC) security subsystem provided in the Linux kernel. SELinux enforces restrictions on system access behavior based on predefined security policies: within a process, SELinux can access the resources required by its task, but any operation exceeding the authorized scope will be directly blocked by the system.

[0033] In traditional SELinux technologies, once a third-party application is granted control over a node, it can perform any operation on that node throughout its lifecycle, unrestricted by the SELinux runtime environment. This mechanism cannot effectively distinguish between legitimate read operations and malicious tampering. If a third-party application is hijacked, attackers can use the acquired SELinux privileges to perform destructive writes to the hardware, posing unpredictable security risks to the device.

[0034] To address at least one of the aforementioned technical problems, embodiments of this application provide an operating system permission control method. This method can restrict the usage permissions of third-party applications through target constraints to prevent third-party applications from being unconstrained by the operating system's runtime environment.

[0035] In the following description of the embodiments of this application, it is used as... Figure 1 Taking an example, the implementation environment of the embodiments of this application will be introduced.

[0036] For example, such as Figure 1 As shown, the implementation environment includes a third-party application 110 and an operating system 120.

[0037] Third-party applications 110 are software or services developed by non-official organizations to extend the functionality of official systems or provide alternative experiences. Third-party applications 110 include software development kits (SDKs), third-party code, components, scripts, interfaces, algorithm models, and mini-programs, which extend functionality by accessing or embedding into official systems. Third-party applications 110 are installed by users according to their own needs; their functionality is defined by the developers and is isolated and controlled through application sandboxes and permission mechanisms. In the automotive field, third-party applications 110 can be official applications provided by vehicle manufacturers or third-party tools. For example, a third-party application 110 can be a third-party diagnostic tool capable of reading data from on-board diagnostic (OBD) systems (such as vehicle speed, RPM, fuel consumption, and fault codes). In practical applications, third-party applications 110 rely on the computing, communication, and underlying hardware capabilities provided by operating system 120 to implement their functions. Operating system 120 is integrated onto the electronic device itself and serves as the foundational system software for managing and controlling computer hardware and software resources. For example, in the automotive field, the operating system 120 can be a Linux system. The Linux system manages basic hardware such as in-vehicle screens, touch screens, audio, wireless communication technology (Wireless Fidelity, Wi-Fi), and Bluetooth through its kernel drivers. Third-party applications 110 (vehicle networking applications) need to access these hardware through the Linux system.

[0038] After introducing the implementation environment of the embodiments of this application, the technical solutions provided by the embodiments of this application are described below. (See also...) Figure 2 Taking the operating system as the executing entity as an example, the method includes the following steps.

[0039] Step 201: In response to the access request of a third-party application, query the target constraint based on the access request of the third-party application, and obtain the current running environment in the operating system associated with the target constraint. The target constraint is used to characterize the licensed environment that allows the execution of the access request of the third-party application. The access request is used to access the driver path of the target hardware operated by the third-party application.

[0040] In this context, "third-party applications" refers to applications whose functions are defined by the developer and which are then installed based on their own needs (such as diagnostic or music applications). Access requests initiated by such third-party applications aim to manipulate the driver path of the target hardware. For example, if the third-party application is a diagnostic application, its access request is used to access the driver path of the in-vehicle diagnostic system. If the third-party application is a music application, its access request is used to access music files in the electronic device's memory. The target constraint characterizes the permitted environment for executing the third-party application's access request. That is, the target constraint constrains the current runtime environment of the operating system. The current runtime environment is a snapshot of the environment captured in real-time from the operating system kernel. For example, the current runtime environment includes the vehicle's driving status, the user's facial image recognition, and the frequency of access requests from the third-party application. The driver path of the target hardware is the location of the driver program corresponding to the hardware that the third-party application needs to manipulate. For example, if the third-party application is a diagnostic application, then the driver path of the target hardware is the location of the driver program corresponding to the sensors of the in-vehicle diagnostic system. The current runtime environment associated with the target constraint represents the runtime environment corresponding to the runtime environment constrained by the target constraint. For example, if the target constraint requires the vehicle to be in a parked state, then the current operating environment associated with the target constraint is the vehicle's current driving state.

[0041] In practical applications, if the operating system grants third-party applications access permissions, these applications can perform any operation on the target hardware node corresponding to them throughout their lifecycle, without being restricted by the operating system's runtime environment. This mechanism poses a serious security risk. Once a third-party application is hijacked, attackers can use their gained privileges to perform destructive writes to the target hardware, causing irreversible system damage. For example, in an in-vehicle operating system, if a third-party application tampers with critical data while the vehicle is traveling at high speed, it will directly lead to driving hazards. In this situation, since the target constraint can determine the permitted environment for the third-party application's access request, it is necessary to query the target constraint based on the access request and obtain the current runtime environment of the operating system associated with that target constraint.

[0042] Step 202: Determine the target strategy based on the target constraints and the current operating environment.

[0043] The target policy is the final action instruction corresponding to the access request of the third-party application. The target policy is determined based on the target constraints and the current operating environment, indicating whether the current operating environment meets the target constraints in real time. The target policy includes a first target policy and a second target policy. The first target policy allows the execution of the third-party application's access request. The second target policy denies the execution of the third-party application's access request.

[0044] It should be understood that since the target policy is derived from the target constraints and the current operating environment, it can be modified at any time according to real-time changes in the current operating environment. In other words, through the logical AND operation between the target policy and the current operating environment, the final decision of allowing or denying is calculated in real time, ensuring that every hardware access is a secure operation that has undergone environmental verification and cannot be bypassed.

[0045] Step 203: Execute the target policy for the access request.

[0046] The execution of the target policy for the access request means that the access request initiated by the third-party application is actually processed according to the adjudicated target policy. For example, if the target policy is to read the driver path of the target hardware, then the driver path of the target hardware is accessed based on the access request, and the relevant data in the target hardware is read; if the target policy is to deny the access request, then the operating system intercepts the access request.

[0047] This application provides a method for controlling operating system permissions. This method responds to access requests from third-party applications, queries the target constraints corresponding to the third-party applications, and obtains the current operating system environment, thereby achieving dynamic permission control of third-party applications based on the current operating system environment. This scheme binds the access permissions of hardware driver paths to the current permission environment of the operating system, ensuring that third-party applications can only execute target policies under preset security conditions. This not only effectively prevents destructive operations by third-party applications after hijacking but also significantly improves the security protection capabilities and stability of the operating system.

[0048] Figure 3 This is a schematic flowchart illustrating another operating system permission control method provided in the embodiments of this application.

[0049] For example, such as Figure 3 As shown, taking the operating system as the executing entity as an example, this application describes a method for controlling operating system permissions, which includes the following steps.

[0050] Step 301: In response to the access request from the third-party application, a security handle is generated based on the access request from the third-party application, and the target constraint conditions are queried based on the security handle.

[0051] In this context, "third-party application" refers to an application whose functionality is defined by the developer and which is installed based on their own needs (such as a diagnostic application or a music application). A third-party application's access request is a hardware access request from a user-space application that is not fully trusted by the system. A third-party application's access request typically includes the access request frequency, the hardware identifier of the target hardware to be accessed, and the call type. The access request frequency represents the total number of system calls successfully initiated and received by the operating system kernel per unit time. The target hardware to be accessed refers to the physical device or sensor that the third-party application wants to operate through the operating system. For example, the target hardware could be a sensor in an automotive diagnostic system. The call type refers to the type of a set of function interfaces provided by the operating system kernel to user-space applications. The call type is used to request the kernel to perform privileged operations on behalf of the application (such as reading and writing files, creating processes, accessing hardware, etc.). A security handle is an abstract index generated and managed by the operating system kernel. The security handle is the unique credential that a third-party application can access in user space to represent its specific hardware access permissions. The security handle is used to implement subsequent system calls. The security handle is an abstract index. Target constraints are the operating system's pre-defined security rules for this access request. The target constraint is used to characterize the licensed environment that allows the execution of the access request of the third-party application.

[0052] It should be understood that if the actual path or file descriptor of the target hardware is directly exposed to a third-party application, that application, after obtaining authorization from the operating system, can bypass all subsequent security checks and thus perform unrestricted operations on the target hardware. This mechanism is highly susceptible to security attacks targeting the target hardware, thereby seriously threatening the stability and security of the operating system. In such cases, the specific implementation of the third-party application can be restricted through secure handles and target constraints.

[0053] In one possible implementation, a security handle carried by the access request is obtained, which is a query index for querying the target constraint; based on the security handle, the target constraint corresponding to the security handle is queried from the kernel mapping table, which stores the mapping relationship between the security handle and the target constraint.

[0054] Here, the security handle refers to the hardware interface provided by the operating system for third-party applications. The security handle serves as the lookup index for querying the target constraint. The target constraint is the constraint instance bound when the security handle is generated, i.e., the rulebook corresponding to this access request. When a third-party application initiates an access request, the operating system kernel extracts the security handle (e.g., 0x8F2A) passed by the third-party application from the call parameters. This security handle serves only as an index key for subsequent table lookups and does not contain any permission or resource information. The kernel mapping table is a hash table or array stored in kernel space, storing the mapping relationship between the security handle and the target constraint. The kernel mapping table also records the binding relationships between the security handle, the file descriptor of the target hardware, and the target constraint. Third-party applications cannot directly read or modify this information. Based on the security handle, querying the kernel mapping table for the target constraint corresponding to that security handle represents a memory lookup operation performed by the handle interceptor, using the security handle value as the key to retrieve the corresponding value from the kernel mapping table. The mapping relationship refers to the one-to-one binding between a security handle and a target constraint. It is established by the kernel when the security handle is generated and remains unchanged throughout the lifecycle of the security handle.

[0055] It should be understood that because the security handle is a fixed lookup index, the target constraints can be updated dynamically. Even if the target constraints change, only the target constraints in the kernel mapping table need to be updated; the security handle held by the third-party application does not need to be changed. Each time the operating system makes a call, it retrieves the target constraints by looking up the table through the security handle, so that the runtime environment of the third-party application can be constrained according to the target constraints.

[0056] In this implementation, a secure handle is used as a query index to quickly retrieve the corresponding target constraints in the kernel mapping table, avoiding the direct exposure of the target hardware's file path. This allows the operating system to perform real-time, dynamic constraint verification on access requests based on the current runtime environment. This not only effectively prevents third-party applications from bypassing security checks to perform illegal operations on the hardware but also significantly enhances the overall security of the operating system.

[0057] To provide a more detailed explanation of the above embodiments, the following description is divided into several parts.

[0058] The first part describes how to obtain the security handle carried in the access request, which is used to query the contents of the index for the target constraint.

[0059] In one possible implementation, based on the access request from the third-party application, an application identity verification process for the third-party application is executed; if the application identity verification process passes, an idle query index is allocated to a reference kernel mapping table, which stores the mapping relationship between the target constraint and the file descriptor of the target hardware; and the query index is determined as the security handle.

[0060] The access request from a third-party application includes the application's identity information and the target hardware's hardware identifier. The identity information includes the application's package name, public key, and signature value. The package name is the application's unique identifier; the operating system uses the package name to distinguish different third-party applications. If two third-party applications have the same package name, the operating system considers them the same application, and the subsequent installation will overwrite the previous one. Therefore, the package name is the top-level, globally unique identifier for a third-party application. The public key comes from the digital certificate used by the developer to sign the application's installation package. The operating system requires each installation package to be digitally signed with a private key, and the paired public key is included in the third-party application. The public key is usually provided as a "SHA-256 fingerprint" or a "Base64 encoded string." The public key is the public part of the signing certificate and is used to verify the authenticity of the third-party application's signature. It is used in conjunction with the private key to form the basis of asymmetric encryption. The signature value is the hash value of the entire signing certificate. The signature value is a 32-character hexadecimal string. The signature value uniquely identifies the specific certificate used to sign the third-party application. Even if the public key information contained in the certificates is the same, slight differences in the certificates themselves (such as different validity periods or issuers) will result in drastically different signature values. This hardware identifier typically exists in the form of the hardware's driver path (e.g., / dev / obd_sensor), hardware name, or a predefined hardware identity. The application identity verification process is used to verify whether the third-party application is trusted by the operating system.

[0061] In some embodiments, a third-party application initiates an access request to the target hardware through the security gateway application programming interface (API). If the operating system determines that the third-party application is a trusted application, the operating system kernel allocates a free index location (e.g., index location 0x8F2A) for the reference kernel mapping table in the current process's handle table. The kernel then maps the pointer of the reference kernel mapping table to a secure handle. That is, if the application's identity verification process passes, a free lookup index is allocated to the reference kernel mapping table, and this lookup index is identified as the secure handle.

[0062] It should be understood that after the operating system generates this security handle, since it refers to the hardware interface provided by the operating system for third-party applications, the operating system kernel returns this security handle as the return value of the application interface call to the third-party application. The third-party application receives this security handle. In this situation, the third-party application cannot determine where the corresponding reference kernel mapping table is in the kernel, nor can it see the target constraints and file descriptors of the target hardware stored therein. Thus, the security handle prevents the direct exposure of the target hardware's file descriptors to the third-party application.

[0063] In this implementation, after the third-party application's identity verification is successful, a free query index is dynamically allocated to the reference kernel mapping table. This query index is then used as a security handle, establishing a secure association between the application and the reference kernel mapping table. This scheme ensures that only authenticated applications can obtain a valid security handle, and that the security handle corresponds to the target constraints and file descriptors in the reference kernel mapping table. This avoids directly exposing the target hardware's file descriptors through the security handle, further enhancing the tightness and reliability of controlling third-party application access.

[0064] To provide a more detailed explanation of the above implementation methods, the following describes the process of performing an application identity verification procedure for the third-party application based on the access request of the third-party application.

[0065] In one possible implementation, the identity information of the third-party application is extracted from the access request; the identity information in the access request is verified; if the identity information matches the preset identity information, the application identity verification process is determined to be successful; if the identity information does not match the preset identity information, the application identity verification process is determined to be unsuccessful.

[0066] The identity information includes the package name, public key, and signature value. Verifying the package name confirms whether the current third-party application's identity identifier (Package Name / Bundle ID) is on the operating system's trusted list; verifying the public key confirms whether the third-party application's signature key has been replaced; and verifying the signature value confirms whether the third-party application's current installation package has been tampered with.

[0067] It should be understood that when a third-party application initiates an access request, the operating system first parses and extracts the identity information used to identify the application from the access request. The operating system performs multi-dimensional verification on the extracted identity information to confirm its authenticity, completeness, and consistency. If the verification result matches the system's preset trusted identity database, the operating system determines that the third-party application's identity is legitimate and allows it to proceed to the subsequent secure handle generation process; if the verification result does not match the preset identity database, the operating system determines that the third-party application's identity is illegitimate, directly rejects its hardware access request, and the process terminates at this point.

[0068] In some embodiments, it is determined whether the package name in the identity information is the same as the preset package name in the operating system; if the package name is the same as the preset package name, it is determined whether the public key in the identity information is the same as the preset public key in the operating system; if the public key is the same as the preset public key, it is determined whether the signature value in the identity information is the same as the preset signature value in the operating system; if the signature value is the same as the preset signature value, it is determined that the identity information of the third-party application matches the preset identity information.

[0069] In some embodiments, if the package name in the identity information is different from the preset package name, it is determined that the identity information of the third-party application does not match the preset identity information.

[0070] In some embodiments, if the public key in the identity information is different from the preset public key, it is determined that the identity information of the third-party application does not match the preset identity information.

[0071] In some embodiments, if the signature value in the identity information is different from the preset signature value, it is determined that the identity information of the third-party application does not match the preset identity information.

[0072] In this implementation, the identity information of the third-party application is extracted and verified during the access request processing, and the identity of the third-party application is verified based on this identity information. The verification process only passes when the identity information matches the preset identity information, effectively blocking access requests from illegal or fake applications, preventing malicious applications from masquerading as legitimate applications to obtain operating system privileges, and significantly improving the overall defense capabilities of the operating system.

[0073] It should be understood that because third-party applications may attack the operating system at any time, the operating system cannot allow third-party applications to directly access real hardware resources. In this case, the operating system assigns a secure handle to the third-party application, while hiding the real file descriptor in a mapping table accessible only to the kernel. The third-party application looks up the file descriptor in the kernel's kernel mapping table based on the secure handle, so the operating system needs to build the kernel mapping table.

[0074] To provide a more detailed explanation of the above implementation methods, the following section describes the construction of the kernel mapping table.

[0075] In one possible implementation, a file descriptor of the target hardware is obtained based on the access request. This file descriptor is used to indicate the driver path of the target hardware corresponding to the third-party application. The target constraint is generated based on the operating system's preset runtime environment and the access request of the third-party application. A mapping relationship is established between the file descriptor and the target constraint, and stored in the reference kernel mapping table. A mapping relationship is established between the reference kernel mapping table and the security handle, and stored in the kernel mapping table.

[0076] The access request includes the target hardware's hardware identifier, access request frequency, and call type. The file descriptor indicates the driver path of the target hardware corresponding to the third-party application. The driver path of the target hardware represents its actual location within the kernel. For example, the actual path of the target hardware in the Linux file system, such as / dev / obd_sensor, is indexed by the file descriptor. The operating system is the system running on the electronic device. For example, the operating system could be a Linux system or an Android system running on an in-vehicle infotainment system. The preset runtime environment characterizes the security environment defined by the operating system. This preset runtime environment includes the vehicle's driving status and the user's facial image. The target constraints represent a set of preset rules dynamically instantiated by the operating system based on the preset runtime environment and the call type of the third-party application for this access. For example, if the preset runtime environment is a parked state, and the call type is a write operation (meaning writing information to the target hardware's driver path), then the write operation must satisfy conditions such as the vehicle being parked and valid identity verification. That is, the write operation must meet conditions such as the vehicle being in park, the vehicle speed being 0 km / h, and the user's facial image being authenticated within 5 minutes. Establishing a mapping relationship means binding the security handle, file descriptor, and target constraints together. That is, associating the security handle, file descriptor, and target constraints into a triple. Storing it in the kernel mapping table means storing the above triple in a mapping table (array) that only the kernel can access; third-party applications cannot directly read or tamper with the file descriptor.

[0077] In this implementation, the target hardware's file descriptor is associated with and stored in a reference kernel mapping table, and this table is associated with and stored in a kernel mapping table using a security handle. This scheme achieves deep binding between hardware resources, the runtime environment, and access permissions, ensuring that third-party applications can only access the target hardware through the security handle under specific target constraints. This not only effectively isolates the actual hardware path, preventing unauthorized access and illegal operations by third-party applications, but also enhances the overall security protection capabilities of the operating system.

[0078] To provide a more detailed explanation of the above embodiments, the following description is divided into several parts.

[0079] The first part describes the contents of the file descriptor of the target hardware obtained based on the access request.

[0080] In some embodiments, based on the hardware identifier in the access request, the kernel's open function is invoked to open the actual hardware device file and obtain an actual file descriptor (FD) from the hardware device file.

[0081] For example, the operating system can open the device by calling the kernel's open() function based on the target hardware specified in the access request from a third-party application, thereby obtaining a real file descriptor.

[0082] The second part explains the content of generating the target constraint conditions based on the preset operating environment of the operating system and the access request of the third-party application.

[0083] It should be understood that in the context of connected vehicles, third-party applications can only access the driver path of the target hardware when the vehicle is in a safe state in order to ensure the driving safety of the vehicle. Therefore, it is necessary to determine the target constraints by considering the vehicle's driving status, the user's facial image, the call type, and the frequency of access requests.

[0084] In one possible implementation, a first constraint is generated based on the vehicle's driving state and the call type; a second constraint is generated based on the user's facial image; a third constraint is generated based on the access request frequency; and the target constraint is generated based on the first constraint, the second constraint, and the third constraint.

[0085] The vehicle's driving status is used to indicate whether the vehicle is in motion. This is determined by the vehicle's speed and gear information; if the vehicle speed is greater than 0 km / h or the gear is in drive, the vehicle is in motion; if the vehicle speed is less than or equal to 0 km / h and the gear is in park, the vehicle is parked. The call type is used to request the kernel to perform privileged operations on behalf of the application (such as reading / writing files, creating processes, accessing hardware, etc.). User facial recognition is used to determine if the user is an authorized operator. The access request frequency indicates how frequently the operating system calls the target hardware.

[0086] It should be understood that the operating system needs to ensure driving safety. However, if a third-party application's call type is a write operation, the application may tamper with the actual data in the vehicle. If the vehicle is traveling at high speed, the write operation may cause an accident due to the application's misoperation. For example, a diagnostic application might tamper with the vehicle's fault codes. In this case, the first constraint needs to be determined based on the vehicle's driving status and the call type. In practical applications, it is also necessary to verify the user's facial image to determine if the current operator is authorized, thereby preventing the third-party application from being hijacked or used without authorization. For example, if a child obtains the phone after facial image verification and maliciously operates a third-party application, unpredictable consequences may occur. Therefore, the validity of the user's facial image needs to be verified within a preset time period. In this case, if the vehicle is parked and the user's facial image passes the authentication verification, it is necessary to determine whether the time difference between the current authentication verification time and the previous authentication verification time is less than a preset time period; that is, the second constraint is determined based on the user's facial image. In practical applications, every time the operating system requests privileged operations from an application in the kernel, it switches between user mode and kernel mode, incurring overhead such as parameter verification, data copying, and driver execution. If this frequency is not limited, it can lead to resource exhaustion or bus congestion. Resource exhaustion means that a third-party application can launch hundreds of thousands of malicious access requests in a short period, causing the operating system to continuously switch between user mode and kernel mode, consuming a significant amount of kernel scheduling time. This prevents other critical processes (such as the vehicle stability system) from obtaining sufficient computing resources, ultimately causing the operating system to freeze or even time out and restart. Bus congestion means that every access to the target hardware by a third-party application ultimately translates into message transmission and reception on the Controller Area Network (Controller Area Network) bus. The Controller Area Network bus is a shared communication medium for all electronic control units within the vehicle, and its bandwidth is typically limited. If a third-party application reads sensor data at an extremely high frequency, it will directly consume bus bandwidth, causing delays or loss in the transmission of critical safety messages such as braking and steering, thus posing a direct security threat.

[0087] In some embodiments, the first constraint stipulates that when the vehicle is in motion, the allowed call type for third-party applications is a read operation. The second constraint stipulates that when the vehicle is parked and the user's facial image passes identity authorization verification, if the time difference between the current successful identity authorization verification and the previous successful identity authorization verification is less than a preset duration, the allowed call type for third-party applications is a write operation, a read operation, or a control operation; when the vehicle is parked and the user's facial image passes identity authorization verification, if the time difference between the current successful identity authorization verification and the previous successful identity authorization verification is greater than or equal to a preset duration, the allowed call type for third-party applications is a read operation. The third constraint stipulates that when the access request frequency is less than a preset number, it is determined that the third-party application is allowed to make the call.

[0088] For example, when the vehicle is in drive or the speed is greater than 0 km / h, the operating system allows third-party applications to perform read operations but does not allow them to perform write or control operations. When the vehicle is in park, the operating system determines whether the time difference between the driver's facial recognition authentication and the last successful authentication is less than or equal to 5 minutes. Third-party applications must not make more than 20 access requests per second.

[0089] In this implementation, constraints are generated by comprehensively considering three dimensions: vehicle driving status, user facial image, and access request frequency, and then merged into target constraints. In other words, this solution deeply binds hardware access permissions to vehicle security status, user identity legitimacy, and the rationality of the invocation behavior, ensuring that third-party applications only perform operations in a secure and compliant environment. This effectively prevents third-party applications from attacking the operating system without verification, significantly improving the security protection capabilities of the in-vehicle system and the granularity of third-party application permission control.

[0090] The third part describes how to establish a mapping relationship between the file descriptor and the target constraint and store it in the reference kernel mapping table; and how to establish a mapping relationship between the reference kernel mapping table and the security handle and store it in the kernel mapping table.

[0091] In some embodiments, the operating system kernel creates a first security object (i.e., a kernel object) in its memory. This first security object is a data structure in which the operating system kernel establishes a mapping relationship between the file descriptor and the target constraint, and encapsulates it to obtain a reference kernel mapping table. The operating system kernel also creates a second security object in its memory. In this second security object, the operating system kernel establishes a mapping relationship between the reference kernel mapping table and the security handle, and encapsulates it to obtain a reference kernel mapping table.

[0092] Step 302: Obtain the current operating environment of the operating system.

[0093] It should be understood that since the operating environment in an operating system is constantly changing, it is necessary to obtain the current operating environment of the operating system in real time and adjust the target constraints of third-party businesses in real time as the current operating environment changes; otherwise, security vulnerabilities or misjudgments may occur.

[0094] In some embodiments, the runtime environment context of the current operating system is obtained in real time in a zero-copy manner through a kernel probe and written into a kernel-global environment context ring buffer; the handle interceptor reads the current runtime environment directly from this environment context ring buffer.

[0095] Kernel probes are the performance engine and security sensors within the operating system. Kernel probes include eBPF and Kprobes. For example, if the operating system is a vehicle operating system, eBPF probes are attached to the `update_vehicle_state()` function to capture information such as vehicle speed and gear changes in real time. eBPF probes are also attached to authentication state change points to obtain authentication results and timestamps in real time. If the operating system uses a call counter, the eBPF Map maintains the call count for each security handle, atomically incrementing and checking the time window with each system call to obtain the access frequency of third-party applications. Handle interceptors are registered in the operating system's Binder communication layer.

[0096] Step 303: Determine the target strategy based on the target constraints and the current operating environment.

[0097] The target constraints include a first constraint, a second constraint, and a third constraint. The target strategy includes a first target strategy and a second target strategy. The first target strategy is used to execute the access request. The second target strategy is used to capture the access request.

[0098] In one possible implementation, it is determined whether the current operating environment meets the target constraint; if the current operating environment meets the target constraint, the corresponding file descriptor is parsed from the kernel mapping table based on the security handle; based on the file descriptor, the target policy is determined to be a first target policy, which is used to execute the access request; if the current operating environment does not meet the target constraint, the target policy is determined to be a second target policy, which is used to capture the access request.

[0099] The current runtime environment is a snapshot of the operating system state captured in real time by kernel probes. This environment includes dynamic data such as vehicle speed, gear position, facial image information, and the access frequency of third-party applications. To determine if the current runtime environment meets the target constraints, the handle interceptor performs a matching operation, comparing the current runtime environment with each target constraint. Meeting the target constraints means that the first, second, and third constraints completely match the current runtime environment. The secure handle is a query index carried by the third-party application. The kernel mapping table stores the mapping relationship between secure handles, file descriptors, and target constraints. The file descriptor is the driver entry point for the target hardware. The first target policy is a allow policy, meaning it uses a real file descriptor to proxy the third-party application's request. Executing this access request means the handle interceptor calls a native kernel function to complete the actual hardware operation. Not meeting the target constraints means that at least one dimension of the condition check failed. In this case, the operating system determines the target policy to be the second target policy and makes a rejection decision, deciding to block the operation. The second target policy is an intercept policy, meaning it captures and terminates the system call without performing any hardware operations. The capture of this access request indicates that the handle interceptor returned an error code directly at the virtual file layer, and the driver of the target hardware did not receive any instructions at all.

[0100] It should be understood that the handle interceptor compares the real-time environment data obtained by the kernel probe with the target constraints to determine whether the current runtime environment meets all target constraints. If all environment checks pass, the handle interceptor uses the secure handle as an index to find the corresponding real file descriptor in the kernel mapping table. If the operating system determines that the current runtime environment meets the target constraints, it chooses a allow policy and uses the parsed file descriptor to complete the actual access to the hardware. If the operating system determines that the current runtime environment does not meet the target constraints, it chooses an intercept policy and directly terminates the call at the virtual file layer, thus completely blocking the operation.

[0101] In this implementation, dynamic traffic routing of access requests is achieved by real-time verification of the operating system's current runtime environment. When the current runtime environment meets the target constraints, the file descriptor is parsed based on the security handle and the access request is executed, ensuring efficient response to legitimate operations. When the current runtime environment does not meet the target constraints, the access request is captured, effectively blocking illegal or unauthorized operations. This not only avoids the risk of third-party application privilege abuse but also significantly improves the operating system's security protection capabilities and operational stability.

[0102] To provide a more detailed explanation of the above implementation methods, the following section explains how to determine whether the current operating environment meets the target constraint.

[0103] In one possible implementation, if the current operating environment satisfies the third constraint, and if the first or second constraint is also satisfied, the target constraint is determined to be satisfied; if the current operating environment does not satisfy the third constraint, the target constraint is determined not to be satisfied.

[0104] The first constraint stipulates that when the vehicle is in motion, the allowed call type for third-party applications is read operation. The second constraint stipulates that within a preset time period, if the vehicle is parked and the user's facial image passes identity authorization verification, the allowed call type for third-party applications is write operation and / or read operation; if within the preset time period, the vehicle is parked but the user's facial image fails identity authorization verification, the allowed call type for third-party applications is read operation. The third constraint stipulates that when the frequency of access requests is less than a preset number, it is determined that the third-party application is allowed to make calls.

[0105] It should be understood that if the system is overwhelmed by high-frequency calls from third-party applications or bus congestion occurs, it is necessary to first determine whether the access frequency of third-party applications exceeds the preset number. If the access request frequency is less than the preset number, it is determined that the operating system will not be congested. Then, the current operating environment can be further determined to meet the target constraints by using the vehicle's driving status and the user's facial image.

[0106] In this implementation, the third constraint is set as a necessary prerequisite for the target constraint to prevent malicious attacks on the operating system's security by third-party applications. That is, only when the frequency of access requests meets the limit requirements are further verified conditions such as vehicle driving status or the validity of user authorization. This effectively curbs high-frequency abnormal calls or malicious data breaches at the source, avoiding unnecessary complex verification overhead and ensuring strict access control, significantly improving the system's security capabilities and operational efficiency.

[0107] The following explains how to determine whether the current operating environment meets the first, second, or third constraint conditions.

[0108] In one possible implementation, if the vehicle is in motion and the third-party application's call type is a read operation, the first constraint condition is determined to be satisfied; if the vehicle is parked and the user's facial image passes the identity authorization verification, the time difference between the current identity authorization verification time and the previous identity authorization verification time is calculated; if the time difference is less than or equal to a preset duration, the second constraint condition is determined to be satisfied; if the access request frequency is less than a preset number, the third constraint condition is determined to be satisfied.

[0109] The preset duration and preset number of times are automatically determined by the operating system, and this application embodiment does not limit these. For example, the preset duration is 5 minutes, and the preset number of times can be 20.

[0110] It should be understood that in the automotive field, if the operating system grants all permissions to third-party applications while the vehicle is in motion, it could easily lead to these applications tampering with the vehicle's driving data, posing a significant driving risk. In this case, while the vehicle is in motion, the call type of third-party applications is restricted to read operations. That is, if a third-party application requests a write or control operation while the vehicle is in motion, such an operation is prohibited, thus preventing the application from tampering with the vehicle's driving data. In practical applications, if the operating system does not perform continuous verification after the operator's authentication is valid, it could easily allow unauthorized operators to arbitrarily control the target hardware information based on the permissions of third-party applications. Therefore, a 5-minute validity period is set to ensure that the current operator is still the initially authenticated driver, preventing unauthorized users from manipulating the target hardware information based on the authentication permissions after the user has passed the authentication verification. Since high-frequency calls from third-party applications can cause system crashes or bus congestion, it is necessary to first determine whether the access frequency of third-party applications exceeds a preset number. If the access request frequency is less than the preset number, it is determined that the operating system will not be congested, thus satisfying the third constraint condition.

[0111] In some embodiments, if the vehicle is in motion and the third-party application's call type is a read operation, the first constraint condition is determined to be met; if the vehicle is parked and the user's facial image passes identity authorization verification, and the time difference between the current successful identity authorization verification time and the previous successful identity authorization verification time is less than or equal to a preset duration, the second constraint condition is determined to be met; if the vehicle is parked and the user's facial image passes identity authorization verification, and the time difference between the current successful identity authorization verification time and the previous successful identity authorization verification time is greater than or equal to a preset duration, the second constraint condition is determined not to be met; if the access request frequency is less than a preset number, the third constraint condition is determined to be met; if the access request frequency is less than a preset number, the third constraint condition is determined to be met; if the access request frequency is greater than or equal to a preset number, the third constraint condition is determined not to be met, i.e., the third-party application is not allowed to call.

[0112] For example, the operating system reads from the kernel circular buffer that the vehicle is in motion (speed 80 km / h, gear in drive). A third-party application needs to read the vehicle's current driving log. The third-party application initiates a call through a secure handle; this call enters the kernel virtual file system layer and is intercepted by the handle interceptor in the operating system. The handle interceptor queries the kernel mapping table based on the secure handle. The query's target constraint is that the vehicle is in motion and the third-party application's call type is a read operation. Therefore, the handle interceptor determines that the third-party application's access request can be executed. Using the secure handle as the query index, it queries the kernel mapping table and, based on the correspondence between the file descriptor and the target constraint, extracts the log's file descriptor to retrieve the current driving log from the log storage.

[0113] For example, if the operating system reads from the kernel circular buffer that the vehicle is in motion (speed 80 km / h, gear in drive), and if the time difference between the current successful authentication and the previous successful authentication is 15 minutes, then the second constraint is not met; if the access frequency of the request is determined to be 2 times / second, then the third constraint is met. The handle interceptor queries the kernel mapping table based on the secure handle. If the target constraint is that the vehicle is in motion and the third-party application's call type is a read operation, then the handle interceptor determines that the third-party application's access request can be executed. Using the secure handle as the query index, it queries the kernel mapping table and, based on the correspondence between the file descriptor and the target constraint, extracts the file descriptor of the on-board diagnostic system to allow the read operation carried by the access request to enter the hardware driver path of the on-board diagnostic system.

[0114] This implementation achieves refined control over third-party application access permissions by constructing a constraint system. The first constraint allows read operations while the vehicle is in motion, effectively preventing write operations from interfering with driving safety. The second constraint combines parking status, facial recognition authentication, and continuous authorization time differences to ensure that write operations are only permitted when the user's identity remains valid and the authorization period has not expired, preventing unauthorized write operations after authorization expires. The third constraint effectively curbs abnormally high-frequency call behavior by limiting the frequency of access requests. This solution achieves a harmonious balance between security, efficiency, and compliance, significantly improving the overall security protection capabilities of the in-vehicle system.

[0115] Step 304: Execute the target policy for the access request.

[0116] The target strategy includes a first target strategy and a second target strategy.

[0117] It should be understood that third-party applications run in user space and cannot directly manipulate hardware drivers. Even if the target policy allows it, the third-party application cannot execute it. Therefore, it is necessary to use an interceptor running in kernel space to execute the target policy for this access request.

[0118] In some embodiments, if the target policy is to allow the execution of the access request, the handle interceptor extracts the file descriptor of the target hardware from the kernel mapping table and executes it using a modified file descriptor proxy based on the call type; if the target policy is to deny the execution of the access request, the handle interceptor returns an error code and triggers a rate limiting or circuit breaker mechanism.

[0119] In this mechanism, to prevent congestion caused by access requests exceeding a preset frequency, the number of requests allowed to pass through per unit time is limited. This is achieved by the handle interceptor checking the call count in the eBPFMap in kernel mode. When the access frequency exceeds the preset frequency, the operating system returns an error code and rejects the request. If the current runtime environment repeatedly fails to meet the target constraints, the operating system proactively cuts off subsequent requests from third-party applications; this is the circuit breaker mechanism.

[0120] For example, suppose the third-party application is faulty or hijacked, and while the vehicle is still traveling at 80 km / h, it attempts to send a command to the onboard diagnostic system to clear fault codes. The third-party application initiates an access request, which is intercepted by a handle interceptor. The handle interceptor reads the current operating environment as the vehicle being in motion and determines that the constraint condition is that the vehicle is in motion, thus prohibiting the third-party application from performing write operations. The handle interceptor directly terminates the access request and returns an error code to the third-party application. In this case, the underlying hardware driver never receives the write request, and vehicle driving safety is guaranteed.

[0121] For example, if the vehicle is parked and the target constraint allows a write operation, and a third-party application initiates a write operation, the handle interceptor reads that the current operating environment is that the vehicle is parked. The handle interceptor reads that the time difference between the last face authentication pass time and the current face authentication pass time is 15 minutes. Since the time difference between the face authentication pass time and the current face authentication pass time is greater than the preset time, the current operating environment does not meet the second constraint, and the handle interceptor returns an error code.

[0122] In some embodiments, after the handle interceptor returns an error code, a message is triggered for that error code.

[0123] For example, after the security gateway application interface captures this error code, it sends a prompt message to the third-party application, which could be "Write operation requires recent biometric authentication, please re-verify your face".

[0124] This application provides a method for controlling operating system permissions. This method generates a security handle based on access requests from third-party applications and queries target constraints accordingly. It dynamically matches the access request with the current operating system environment, achieving dynamic permission control of third-party applications based on the current operating system environment. By determining the target policy corresponding to the access request based on the filtering of target constraints, this not only ensures that third-party applications can only access target hardware resources under specific security permission conditions, effectively preventing permission abuse and unauthorized access, but also significantly improves the operating system's security control capabilities and overall operational stability for third-party applications through the security handle.

[0125] Figure 4 This is a schematic flowchart illustrating an interaction method between a third-party application and an operating system, provided in an embodiment of this application. For example, as shown... Figure 4 As shown, the communication process between a third-party application and the operating system is explained. The method includes the following steps.

[0126] Step 401: The third-party application sends an access request to the operating system.

[0127] Third-party applications initiate access requests through the security gateway application programming interface provided by the operating system. This access request includes the third-party application's identity information (such as package name and signing certificate for authentication) and the hardware identifier of the target hardware accessed by the third-party application.

[0128] Step 402: The operating system generates a security handle based on the access request.

[0129] It is understood that the specific implementation of step 402 can be found in the relevant description of step 301 above, and will not be repeated here.

[0130] Step 403: The operating system issues a security handle to the third-party application.

[0131] The operating system returns a security handle to a third-party application through the return value of the security gateway application interface.

[0132] Step 404: Based on the access request, the third-party application initiates a call to the operating system, and the access request carries the security handle.

[0133] It is understood that the specific implementation of step 404 can be found in the relevant descriptions of steps 301-302 above, and will not be repeated here.

[0134] Step 405: The operating system queries the target constraints and obtains the current operating environment based on the security handle of the call.

[0135] It is understood that the specific implementation of step 405 can be found in the relevant descriptions of steps 301-302 above, and will not be repeated here.

[0136] Step 406: The operating system determines whether the target constraints match the current operating environment.

[0137] It is understood that the specific implementation of step 406 can be found in the relevant description of step 303 above, and will not be repeated here.

[0138] Step 407: If the target constraints match the current operating environment, execute the access request of the third-party application.

[0139] It is understood that the specific implementation of step 407 can be found in the relevant descriptions of steps 303-304 above, and will not be repeated here.

[0140] Step 408: If the target constraints do not match the current operating environment, the access request from the third-party application is rejected.

[0141] It is understood that the specific implementation of step 408 can be found in the relevant descriptions of steps 303-304 above, and will not be repeated here.

[0142] This application provides a method for interaction between a third-party application and an operating system. The method begins by the operating system generating and issuing a security handle, which the third-party application carries in subsequent requests. This security handle prevents the third-party application from directly accessing the hardware resources of the target hardware. Subsequently, the operating system queries the target constraints based on the request carrying the security handle and performs real-time matching between the operating system's current runtime environment and the target constraints. Access is only executed if a match is found; otherwise, it is directly rejected. This effectively prevents the third-party application from being stolen or maliciously invoked in an unauthorized environment, significantly improving the operating system's security control capabilities and overall operational stability.

[0143] Figure 5 This is a schematic diagram of the structure of an operating system permission control device provided in an embodiment of this application.

[0144] For example, the device 500 includes: The query and retrieval module 501 is used to respond to the access request of a third-party application, query the target constraint based on the access request of the third-party application, and obtain the current running environment in the operating system associated with the target constraint. The target constraint is used to characterize the licensed environment that allows the execution of the access request of the third-party application. The access request is used to access the driver path of the target hardware operated by the third-party application. The determination module 502 is used to determine the target strategy based on the target constraints and the current operating environment; Execution module 503 is used to execute the target policy for the access request.

[0145] In one possible implementation, the query and retrieval module 501 is specifically used to: retrieve the security handle carried by the access request, the security handle being a query index for querying the target constraint; and, based on the security handle, query the target constraint corresponding to the security handle from the kernel mapping table, the kernel mapping table storing the mapping relationship between the security handle and the target constraint.

[0146] In one possible implementation, the query and retrieval module 501 is specifically used for: executing an application identity verification process for the third-party application based on the access request of the third-party application; if the application identity verification process passes, allocating an idle query index to a reference kernel mapping table, which stores the mapping relationship between the target constraint and the file descriptor of the target hardware; and determining the query index as the security handle.

[0147] In one possible implementation, the query and retrieval module 501 is specifically used to: extract the identity information of the third-party application from the access request; verify the identity information in the access request; determine that the application identity verification process is successful if the identity information matches the preset identity information; and determine that the application identity verification process fails if the identity information does not match the preset identity information.

[0148] In one possible implementation, the query and retrieval module 501 is specifically configured to: retrieve a file descriptor of the target hardware based on the access request, the file descriptor indicating the driver path of the target hardware corresponding to the third-party application; generate the target constraints based on the operating system's preset operating environment and the access request of the third-party application; establish a mapping relationship between the file descriptor and the target constraints and store it in the reference kernel mapping table; and establish a mapping relationship between the reference kernel mapping table and the security handle and store it in the kernel mapping table.

[0149] In one possible implementation, the query and retrieval module 501 is specifically used to: generate a first constraint based on the vehicle's driving status and the call type; generate a second constraint based on the user's facial image; generate a third constraint based on the access request frequency; and generate the target constraint based on the first constraint, the second constraint, and the third constraint.

[0150] In one possible implementation, the determining module 502 is specifically configured to: determine whether the current operating environment meets the target constraint; if the current operating environment meets the target constraint, parse the corresponding file descriptor from the kernel mapping table based on the security handle; determine the target policy as a first target policy based on the file descriptor, the first target policy being used to execute the access request; if the current operating environment does not meet the target constraint, determine the target policy as a second target policy, the second target policy being used to capture the access request.

[0151] In one possible implementation, the determining module 502 is specifically configured to: if the current operating environment satisfies the third constraint condition, determine that the target constraint condition is satisfied if the first constraint condition or the second constraint condition is satisfied; and if the current operating environment does not satisfy the third constraint condition, determine that the target constraint condition is not satisfied.

[0152] In one possible implementation, the determining module 502 is specifically configured to: determine that the first constraint condition is met when the vehicle is in motion and the third-party application's call type is a read operation; calculate the time difference between the time of passing the current identity authorization verification and the time of passing the previous identity authorization verification when the vehicle is parked and the user's face image passes the identity authorization verification; determine that the second constraint condition is met when the time difference is less than or equal to a preset duration; and determine that the third constraint condition is met when the access request frequency is less than a preset number of times.

[0153] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0154] For example, such as Figure 6 As shown, the electronic device 600 includes a memory 601 and a processor 602. The memory 601 stores executable program code 603, and the processor 602 is used to call and execute the executable program code 603 to perform an operating system permission control method.

[0155] Furthermore, embodiments of this application also protect an apparatus that may include a memory and a processor, wherein the memory stores executable program code, and the processor is used to call and execute the executable program code to perform an operating system permission control method provided in embodiments of this application.

[0156] This embodiment can divide the device into functional modules based on the above method example. For example, each module can correspond to a separate function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0157] It should be understood that the device provided in this embodiment is used to execute the above-described operating system permission control method, and therefore can achieve the same effect as the above-described implementation method.

[0158] When using integrated units, the device may include a processing module and a storage module. When applied to an electronic device, the processing module can be used to control and manage the operation of the electronic device. The storage module can be used to support the execution of relevant program code by the electronic device.

[0159] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits shown in conjunction with the disclosure of this application. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and microprocessors, etc., and the storage module may be a memory.

[0160] In addition, the device provided in the embodiments of this application may specifically be a chip, component or module. The chip may include a connected processor and a memory. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can execute a vehicle operating system permission control method provided in the above embodiments.

[0161] This embodiment also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, it causes the computer to execute the aforementioned related method steps to implement the operating system permission control method provided in the above embodiment.

[0162] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the operating system permission control method provided in the above embodiment.

[0163] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0164] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0165] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0166] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for controlling operating system permissions, characterized in that, Applied to an operating system, the method includes: In response to an access request from a third-party application, the system queries the target constraints based on the access request and obtains the current operating environment associated with the target constraints in the operating system. The target constraints are used to characterize the licensed environment that allows the execution of the access request from the third-party application. The access request is used to access the driver path of the target hardware operated by the third-party application. Determine the target strategy based on the target constraints and the current operating environment; Execute the target policy for the access request.

2. The method according to claim 1, characterized in that, The target constraints for querying access requests based on the third-party application include: Obtain the security handle carried in the access request, wherein the security handle is the query index for querying the target constraint; Based on the security handle, the target constraint corresponding to the security handle is queried from the kernel mapping table, which stores the mapping relationship between the security handle and the target constraint.

3. The method according to claim 2, characterized in that, Obtaining the security handle carried in the access request includes: Based on the access request from the third-party application, execute the application identity verification process for the third-party application; If the application identity verification process passes, an idle query index is allocated to the reference kernel mapping table, which stores the mapping relationship between the target constraints and the file descriptors of the target hardware. The query index is identified as the security handle.

4. The method according to claim 3, characterized in that, The process of performing an application identity verification for the third-party application based on the access request from the third-party application includes: Extract the identity information of the third-party application from the access request; Verify the identity information in the access request; If the identity information matches the preset identity information, the application identity verification process is deemed to have passed. If the identity information does not match the preset identity information, the application identity verification process is determined to have failed.

5. The method according to claim 3, characterized in that, Before allocating a free query index to the reference kernel mapping table after the application identity verification process has passed, the process further includes: The file descriptor of the target hardware is obtained based on the access request. The file descriptor is used to indicate the driver path of the target hardware corresponding to the third-party application. The target constraints are generated based on the operating system's preset operating environment and the access requests from the third-party applications. A mapping relationship is established between the file descriptor and the target constraint, and stored in the reference kernel mapping table; A mapping relationship is established between the reference kernel mapping table and the security handle, and the mapping relationship is stored in the kernel mapping table.

6. The method according to claim 5, characterized in that, The preset operating environment includes the vehicle's driving status and the user's facial image; the access request includes the access request frequency and call type; the generation of the target constraints based on the preset operating environment of the operating system and the access requests of the third-party application includes: A first constraint condition is generated based on the vehicle's driving state and the call type; A second constraint is generated based on the user's facial image; A third constraint is generated based on the frequency of the access requests. Based on the first constraint and the second constraint, the third constraint generates the target constraint.

7. The method according to claim 5, characterized in that, The target strategy includes a first target strategy and a second target strategy. Determining the target strategy based on the target constraints and the current operating environment includes: Determine whether the current operating environment meets the target constraints; If the current operating environment meets the target constraints, the corresponding file descriptor is parsed from the kernel mapping table based on the security handle; Based on the file descriptor, the target policy is determined to be a first target policy, and the first target policy is used to execute the access request; If the current operating environment does not meet the target constraints, the target strategy is determined to be a second target strategy, which is used to capture the access request.

8. The method according to claim 7, characterized in that, The target constraints include a first constraint, a second constraint, and a third constraint. Determining whether the current operating environment satisfies the target constraints includes: If the current operating environment satisfies the third constraint condition, and the first or second constraint condition is also satisfied, then the target constraint condition is determined to be satisfied. If the current operating environment does not meet the third constraint condition, then the target constraint condition is determined not to be met.

9. The method according to claim 8, characterized in that, If the third constraint condition is met in the current operating environment, but before the first or second constraint condition is met, the following further includes: If the vehicle is in motion and the third-party application's call type is a read operation, then the first constraint condition is satisfied. When the vehicle is parked and the user's facial image passes the identity authorization verification, calculate the time difference between the time of passing the identity authorization verification this time and the time of passing the identity authorization verification last time; If the time difference is less than or equal to the preset duration, it is determined that the second constraint condition is met; If the frequency of access requests is less than a preset number, the third constraint condition is determined to be satisfied.

10. An electronic device, characterized in that, The electronic device includes: Memory, used to store executable program code; A processor for calling and running the executable program code from the memory, causing the electronic device to perform the method as described in any one of claims 1 to 9.