Real-time access control method and computer device based on Linux application layer
By realizing real-time access control at the Linux application layer, by traversing the system to obtain controlled threads and creating corresponding control threads and monitoring processes, the problems of incomplete monitoring and poor adaptability in the existing technology are solved, and comprehensive monitoring of the system is achieved. and fine-grained control, reducing maintenance difficulty and resource occupation, ensuring the security and stability of the system.
Patent Information
- Application Number
- CN202410789724.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-19
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-19
AI Technical Summary
In the existing technology, the access control of processes in the operating system has incomplete monitoring, poor system adaptability, and high maintenance difficulty, especially between different kernel versions and system architectures, resulting in a heavy workload of adaptation, high maintenance difficulty, and ptrace coordination PTRACE_ATTACH will affect the SIGSTOP signal, causing the status of the tracked process to be chaotic.
Adopt a real-time access control method based on the Linux application layer, obtain controlled threads by traversing the target system, create a one-to-one correspondence between the control thread and the monitoring process, obtain the event thread ID and determine the source of the event, and control event access based on different access control policies to ensure Each user thread has corresponding monitoring and control, achieving comprehensive monitoring and fine-grained control of the system.
It achieves comprehensive monitoring of the system, reduces system resource occupancy, improves efficiency and response speed, has a large adaptation range, and is easy to maintain, ensuring minimal intervention and security in the tracked process.
Smart Images

Figure CN118364495B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of system security, and in particular to a real-time access control method and a computer device based on a Linux application layer. Background Art
[0002] As the number of domestically produced systems increases, the demand for system security is also increasing. When adapting the driver for access control of processes in the operating system, it is found that different kernel versions, different kernel configurations, and different system architectures do not have universal drivers, so that the monitoring methods are different between different architectures, resulting in a large workload for adaptation, difficulty in maintenance, and difficulty in updates and iterations.
[0003] In the prior art, when using the preload form for access control, it is found that some systems will affect the use of the command line terminal, resulting in the inability to monitor the file manager of the desktop program. The manifestations are different in different systems and cannot be uniformly processed.
[0004] In the prior art, when ptrace is used in conjunction with PTRACE_ATTACH for access control, it is found that it has a great impact on the SIGSTOP signal, which will prevent the signal from taking effect on the target process being tracked, which will cause unpredictable problems in the tracked process. If the tracked process uses this signal in large quantities, it may cause significant economic losses to the customer. For example, when cpulimit is needed to limit the resource usage of the target process, the SIGSTOP signal issued by cpulimit will fail, resulting in signal loss or status confusion. Summary of the invention
[0005] In view of this, the embodiments of the present disclosure provide a real-time access control method and computer device based on the Linux application layer, which can solve the problems existing in the prior art such as incomplete monitoring, poor system adaptability, and difficult maintenance.
[0006] In a first aspect, the embodiments of the present disclosure provide a real-time access control method based on the Linux application layer, which adopts the following technical solutions:
[0007] Traversing the target system to obtain controlled threads; the controlled threads include all running user threads;
[0008] Create N control threads and N monitoring processes;
[0009] Each of the monitoring processes corresponds to each of the control threads one by one, and each of the monitoring processes corresponds to M of the user threads; N≥1, M≥1;
[0010] Acquiring events based on N monitoring processes;
[0011] Get the thread ID that returns the event;
[0012] Obtaining the source of the event based on the thread ID;
[0013] If the source is the controlled thread, controlling access to the event based on a first access control policy;
[0014] If the source is the control thread, access to the event is controlled based on a second access control policy.
[0015] Optionally, the acquiring returns the thread ID of the event, including:
[0016] Call the wait event function;
[0017] When the event occurs, the thread ID of the event is returned based on the wait event function.
[0018] Optionally, obtaining the source of the event based on the thread ID includes:
[0019] According to the monitoring process that monitors the event, determining a control thread corresponding to the monitoring process and marking it as a first thread;
[0020] Obtaining first ID information of the first thread;
[0021] Determine whether the thread ID is consistent with the first ID information, and if so, determine that the event is a control message from the first thread;
[0022] If not, determine that the source is the controlled thread and mark the corresponding controlled thread as the second thread.
[0023] Optionally, controlling access to the event based on a first access control policy includes:
[0024] Get the type of the event;
[0025] If the type is a signal type, controlling access to the event based on a first sub-strategy;
[0026] If the type is a system call type, access to the event is controlled based on a second sub-strategy.
[0027] Optionally, controlling access to the event based on the first sub-strategy includes:
[0028] Get the signal value of the event;
[0029] Determine whether the signal value is the same as the value of SIGSTOP, and if so, control the second thread to enter a paused and listening state;
[0030] If not, the second thread is not processed.
[0031] Optionally, controlling access to the event based on the second sub-strategy includes:
[0032] If the type is a system call type, obtain the overall register;
[0033] Obtaining a register offset based on the overall register;
[0034] Obtaining a system call number based on the register offset;
[0035] Determining whether the monitoring policy is hit according to the system call number, and if not, not processing the second thread;
[0036] If so, obtain the system call parameters according to the register offset, and send the system call number, system call parameters, and the first ID information to the preset target layer through the IPC communication mechanism.
[0037] Optionally, the method further comprises: establishing a data structure for each of the running user threads;
[0038] The data structure is assigned an initial value of 0.
[0039] Optionally, the second access control policy includes initializing a monitoring process, adding monitoring of a specified user thread, deleting monitoring of a specified user thread, releasing system calls to a user thread specified in a waiting queue, rejecting system calls to a user thread specified in a waiting queue, reconfiguring a global control policy, configuring a control policy separately for a specified user thread, and exiting monitoring of a user thread.
[0040] In a second aspect, the embodiment of the present disclosure also provides a real-time access control system based on the Linux application layer, which adopts the following technical solution:
[0041] A traversal module is configured to traverse the target system and obtain controlled threads; the controlled threads include all running user threads;
[0042] Create a module, create N control threads and N monitoring processes;
[0043] Each of the monitoring processes corresponds to each of the control threads one by one, and each of the monitoring processes corresponds to M of the user threads; N≥1, M≥1;
[0044] An event acquisition module, configured to acquire events based on the N monitoring processes;
[0045] An ID acquisition module, configured to acquire a thread ID of the returned event;
[0046] A source acquisition module, configured to acquire the source of the event based on the thread ID;
[0047] an execution module, configured to control access to the event based on a first access control policy if the source is the controlled thread;
[0048] If the source is the control thread, access to the event is controlled based on a second access control policy.
[0049] In a third aspect, the embodiments of the present disclosure further provide a computer device, which adopts the following technical solution:
[0050] The computer device comprises:
[0051] at least one processor; and,
[0052] a memory communicatively connected to the at least one processor; wherein,
[0053] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any of the above-mentioned real-time access control methods based on the Linux application layer.
[0054] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above-mentioned real-time access control methods based on the Linux application layer.
[0055] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, including a computer program / instruction, which implements the steps of any of the above methods when executed by a processor.
[0056] The real-time access control method based on the Linux application layer disclosed in the present application can accurately obtain the currently running user thread by traversing the target system; through the one-to-one correspondence between the created control thread and the monitoring process, it can ensure that each user thread has corresponding monitoring and control, and realize comprehensive monitoring of the system, wherein each monitoring process corresponds to multiple user threads, which can effectively improve efficiency and reduce system resource occupation; through the monitoring process, the events occurring in the system are obtained in real time and can be responded to immediately; the source of the event can be accurately determined by the thread ID; determining the source of the event is helpful for the execution of subsequent access control policies; when the source is a controlled thread, the access to the event can be controlled based on the first access control policy, which can provide fine-grained control of the user thread; when the source is a control thread, the access to the event can be controlled based on the second access control policy, and the configuration of the first access control policy and the second access control policy can cover the entire system, and is applicable to all real-time access controls based on the Linux application layer, and has a wide range of adaptation; in addition, the scheme disclosed in the present application can also adapt to different target systems, with low maintenance difficulty, and can minimize intervention in the tracked process, while also being safer.
[0057] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the following preferred embodiments are specifically cited and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0059] Figure 1 A flowchart of a real-time access control method based on the Linux application layer provided in an embodiment of the present disclosure.
[0060] Figure 2 for Figure 1 A flowchart of a method for obtaining a thread ID in .
[0061] Figure 3 for Figure 1 A flowchart of a method for obtaining the source of an event in .
[0062] Figure 4 for Figure 1 A flowchart of a method for controlling access to an event based on a first access control policy.
[0063] Figure 5 for Figure 4 A flowchart of a method for controlling access to events based on a first sub-strategy is provided.
[0064] Figure 6 for Figure 4 Schematic diagram of the method flow of controlling access to events based on the second sub-strategy.
[0065] Figure 7 A principle block diagram of a real-time access control system based on the Linux application layer provided in an embodiment of the present disclosure.
[0066] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0067] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0068] It should be clear that the following embodiments of the present disclosure are described by specific specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0069] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0070] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The drawings only show components related to the present disclosure rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0071] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0072] Reference Figure 1 The first aspect of the present application discloses a real-time access control method based on the Linux application layer, which specifically includes the following schemes:
[0073] S100, traverse the target system to obtain controlled threads; the controlled threads include all running user threads.
[0074] Specifically, all running user threads in the system can be obtained by traversing the / proc / system directory.
[0075] S200, create N control threads and N monitoring processes;
[0076] Each monitoring process corresponds to each control thread one by one, and each monitoring process corresponds to M user threads; N≥1, M≥1.
[0077] Specifically, one monitoring process monitors a corresponding control thread and corresponding M user threads; through the created N monitoring processes, real-time monitoring of the entire target system can be achieved.
[0078] Among them, the control process is used to establish an IPC communication mechanism with the upper-level application; the monitoring process monitors the control thread through the id of the control thread, and then extracts the control information to initialize itself.
[0079] S300, obtaining events based on N monitoring processes.
[0080] Specifically, N monitoring processes wait for events of threads in the entire system.
[0081] S400, obtaining the thread ID of the returned event.
[0082] Specifically, when an event occurs, the thread ID of the returned event can be obtained.
[0083] S500, obtaining the source of the event based on the thread ID.
[0084] S600, if the source is a controlled thread, control event access based on a first access control policy; if the source is a control thread, control event access based on a second access control policy.
[0085] The real-time access control method based on the Linux application layer disclosed in the present application can accurately obtain the currently running user thread by traversing the target system; through the one-to-one correspondence between the created control thread and the monitoring process, it can ensure that each user thread has corresponding monitoring and control, and realize comprehensive monitoring of the system, wherein each monitoring process corresponds to multiple user threads, which can effectively improve efficiency and reduce system resource occupation; through the monitoring process, the events occurring in the system are obtained in real time and can be responded to immediately; the source of the event can be accurately determined by the thread ID; determining the source of the event is helpful for the execution of subsequent access control policies; when the source is a controlled thread, the access to the event can be controlled based on the first access control policy, which can provide fine-grained control of the user thread; when the source is a control thread, the access to the event can be controlled based on the second access control policy, and the configuration of the first access control policy and the second access control policy can cover the entire system, and is applicable to all real-time access controls based on the Linux application layer, and has a wide range of adaptation; in addition, the scheme disclosed in the present application can also adapt to different target systems, with low maintenance difficulty, and can minimize intervention in the tracked process, while also being safer. The monitoring process in this application can obtain events occurring in the system in real time, so as to respond and execute corresponding access control in a timely manner; through different access control strategies for each user thread and control thread, fine-grained control of system resources is achieved; through parallel processing of multiple monitoring processes and control threads, the efficiency and response speed of the system are greatly improved; the use of different access control strategies can effectively ensure the security and stability of the system.
[0086] It should be noted that when the number of running user threads is large, all running user threads can be divided into N groups, each group includes multiple user threads, that is, the number of monitoring processes is consistent with the number of groups into which the user threads are divided.
[0087] Reference Figure 2 ,The method for obtaining the thread ID specifically includes the following schemes;
[0088] S510, calling the waiting event function;
[0089] S520: When an event occurs, the thread ID of the event is returned based on the wait event function.
[0090] Specifically, the waiting event function is the wait4() function; the wait4() function can be called and the address of an event state can be passed in. When an event occurs, wait4() will return the thread ID of the event.
[0091] In this embodiment, the waiting event function is usually a standard interface provided by the system. By calling such a function, the current thread can be conveniently suspended to wait for the occurrence of an event without using resource-consuming methods such as polling; when an event occurs, the returned thread ID can be obtained by waiting for the event function.
[0092] Reference Figure 3 , the method for obtaining the source of the event specifically includes the following schemes:
[0093] S610, determining a control thread corresponding to the monitoring process according to the monitoring process that monitors the event, and marking it as a first thread;
[0094] S620, obtaining first ID information of the first thread;
[0095] S630, determining whether the thread ID is consistent with the first ID information, and if so, determining that the event is a control message from the first thread;
[0096] If not, determine that the source is a controlled thread and mark the corresponding controlled thread as the second thread.
[0097] In this embodiment, by monitoring the process, the control thread related to it can be quickly located, and the ID of the control thread (i.e., the first ID information) can be quickly obtained, greatly improving the processing efficiency; by comparing the thread ID and the first ID information, the source of the event can be quickly determined. If they are consistent, the control message can be obtained. If they are inconsistent, a quick response can be made to facilitate subsequent tracking and processing. By determining the source of the event, the control thread and the controlled thread can be quickly screened out, reducing unnecessary search and analysis work, thereby improving the overall processing efficiency; accurate identification of the source of the event helps to promptly discover abnormal behavior or security threats, thereby enhancing the security and stability of the system.
[0098] Reference Figure 4 The method for controlling access to an event based on the first access control policy specifically includes the following schemes:
[0099] S710, obtaining the type of event;
[0100] S720, if the type is a signal type, control access to the event based on the first sub-strategy;
[0101] If the type is a system call type, access to the event is controlled based on the second sub-policy.
[0102] In this embodiment, by obtaining the type of event, the nature of the event can be clearly understood, thereby providing an accurate basis for the subsequent selection of access control strategies; by selecting different access control strategies according to the event type, access to system resources can be more accurately controlled, thereby improving the security and stability of the system; by adopting different control strategies for different types of events, unnecessary access authorization to irrelevant resources can be avoided, thereby reducing potential security risks; access control strategies are divided according to event types, so that the system has more flexible and configurable characteristics, which facilitates the expansion and adjustment of access control rules for different types of events according to specific needs.
[0103] Specifically, if it is a signal-type event, an access control policy designed specifically for signal-type events can be used to more accurately control event access and improve security and efficiency; if it is a system call-type event, a specific access control policy designed for this type of operation can be used to ensure the safe use of system resources.
[0104] Reference Figure 5 The method for controlling access to events based on the first sub-strategy specifically includes the following schemes:
[0105] A100, obtains the signal value of the event;
[0106] A200, determines whether the signal value is the same as the value of SIGSTOP. If so, controls the second thread to enter the pause and listening state, that is, suspends the tracked user thread; if not, does not process the second thread, that is, releases it.
[0107] In this embodiment, by obtaining the signal value of the event, the type of event can be clearly understood, providing an accurate basis for subsequent control steps; for specific signal values, such as SIGSTOP, it may indicate that the execution of a thread needs to be suspended for subsequent operations or investigations. Through this step, precise control of specific events can be achieved to ensure the security and stability of system behavior; for signal values that do not require special processing, they can be directly ignored to avoid unnecessary intervention and waste of resources.
[0108] The solution disclosed in this embodiment selects whether to suspend the second thread according to the signal value of the event, which can achieve precise control of specific events and improve the security and controllability of the system; for signal values that do not require special processing, no processing is performed directly, avoiding unnecessary intervention and resource consumption, and improving the efficiency of the system; through clear signal value judgment and processing procedures, the behavior of the system is made more predictable and maintainable, which facilitates subsequent debugging and management.
[0109] Reference Figure 6 The method for controlling event access based on the second sub-strategy specifically includes the following schemes:
[0110] B100, if the type is system call type, get the overall register;
[0111] B200, get register offset based on overall register;
[0112] B300, get the system call number based on the register offset;
[0113] B400, judging whether the monitoring strategy is hit according to the system call number, if not, the second thread is not processed;
[0114] If so, obtain the system call parameters according to the register offset, and send the system call number, system call parameters, and the first ID information to the preset target layer through the IPC communication mechanism.
[0115] In this embodiment, obtaining the overall register can obtain the current state when the system call occurs, including the value of each register, providing basic data for subsequent analysis; through the register offset, the position of the system call number can be accurately located, which is conducive to the subsequent acquisition and judgment of the system call number; the system call number is the key information to distinguish different system calls. By accurately obtaining the system call number, the specific type of the system call can be determined, providing an accurate basis for subsequent processing; system calls that do not hit the monitoring strategy can be directly ignored to avoid unnecessary intervention and processing of the system; for system calls that hit the monitoring strategy, their parameters can be further obtained, and the relevant information can be sent to the preset target layer for further analysis and processing.
[0116] In an embodiment, through a multi-step processing flow, the occurrence of system calls can be accurately monitored, and judgments and processing can be performed according to preset monitoring strategies, thereby improving the system's monitoring precision and accuracy of system calls; for system calls that hit the monitoring strategy, relevant information can be sent to the preset target layer in a timely manner for further processing and response, which helps to timely discover and resolve potential security issues; through precise monitoring and processing of system calls, it is possible to effectively prevent and respond to security risks caused by various types of system calls, thereby improving the overall security and stability of the system.
[0117] Among them, judging whether the monitoring strategy is hit according to the system call number is to judge whether the system call number concerned in the access control strategy is hit according to the system call number. The monitoring strategy in this embodiment includes several preset system call numbers.
[0118] Among them, the overall register is the register after the initialization offset.
[0119] In this embodiment, the preset target layer is preferably an upper application layer, generally system protection software.
[0120] Furthermore, the real-time access control method based on the Linux application layer disclosed in the present application also includes the following schemes:
[0121] Create a data structure for each running user thread;
[0122] The initial value assigned to the data structure is 0.
[0123] In this embodiment, the second access control strategy preferably includes any one of initializing a monitoring process, adding monitoring of a specified user thread, deleting monitoring of a specified user thread, releasing system calls to a user thread specified in a waiting queue, rejecting system calls to a user thread specified in a waiting queue, reconfiguring a global control policy, configuring a control policy separately for a specified user thread, and exiting monitoring of a user thread.
[0124] Initialization of the monitoring process is performed when the monitoring process is started, and the initialization information includes register offset information, access control policy information, and thread information in the system to be monitored by the current monitoring process.
[0125] Adding monitoring for a specified user thread is to re-establish the monitoring relationship for a thread that is not monitored or a thread whose monitoring has been canceled midway.
[0126] Deleting the monitoring of a specified user thread means canceling the monitoring of the currently monitored thread.
[0127] Releasing the system call to the user thread specified in the waiting queue means that the thread suspended in the waiting queue continues to execute and deletes it from the waiting queue.
[0128] Rejecting the system call for the user thread specified in the waiting queue means modifying the system call number so that it is not recognized by the kernel. This will no longer allow a suspended thread to continue calling the system call when it was suspended, mark it, and perform corresponding processing after the system call fails.
[0129] Reconfiguring the global control policy means dynamically updating the control policy at the initial startup. For example, the new control policy adds or cancels the monitoring of a certain system call, or needs to or no longer suspends the thread that calls a certain system call.
[0130] Configuring a control policy separately for a specified user thread means that a separate control policy can be used for a tracked thread separately.
[0131] Exiting the monitoring of user threads means canceling the tracking of all monitored threads and then ending the operation.
[0132] Furthermore, the real-time access control method based on the Linux application layer disclosed in the present application also includes: judging whether it is before or after the system call is executed according to the data structure, when the value in the data structure is 0, it is judged to be before the system call is executed, and when the value in the data structure is not 0, it is judged to be after the system call is executed.
[0133] If it is before the execution of a system call, decide whether to suspend the corresponding user thread according to the control strategy; if it needs to be suspended, save the current context information of the thread (the thread ID, system call number, and system call parameters) to the waiting queue and wait for the decision of the upper layer. Then continue to wait for the next event; if it does not need to be suspended, release the call and continue to wait for the next event.
[0134] If it is a system call, determine whether the system call is marked. If not, release the call and continue to wait for the next event. If it is marked, modify the return value in the return value register to -EPERM and then release the call and continue to wait for the next event.
[0135] After each call is executed, the value in the corresponding data structure is reset to 0 to facilitate the next call.
[0136] The real-time access control method based on the Linux application layer disclosed in the present application, compared with the driver, can be normally compiled and run in systems of different architecture types and different kernel versions (3.4 and above) with a set of codes, and has a low coupling degree with the kernel version.
[0137] Compared with the preload method, its monitoring is comprehensive and will not miss the monitoring of system calls obtained by using the dlsym series of functions.
[0138] Compared with the PTRACE_ATTACH method of the ptrace framework, when starting tracing, for a process that is already in the STOP state, it will not be released from the STOP state and automatically run. During the tracing process, the user can use the SIGSTOP signal to control the traced process normally without losing control of it. This minimizes intervention in the traced process and is also safer.
[0139] Reference Figure 7 In the second aspect, the embodiment of the present disclosure also provides a real-time access control system based on the Linux application layer, which adopts the following technical solutions:
[0140] A traversal module is configured to traverse the target system and obtain controlled threads; the controlled threads include all running user threads;
[0141] Create a module, create N control threads and N monitoring processes;
[0142] Each monitoring process corresponds to each control thread one by one, and each monitoring process corresponds to M user threads; N ≥ 1, M ≥ 1;
[0143] An event acquisition module, configured to acquire events based on N monitoring processes;
[0144] An ID acquisition module configured to obtain a thread ID of a returned event;
[0145] A source acquisition module, configured to acquire the source of an event based on a thread ID;
[0146] an execution module configured to control access to the event based on a first access control policy if the source is a controlled thread;
[0147] If the source is a control thread, access to the event is controlled based on a second access control policy.
[0148] The computer device according to the embodiment of the present disclosure includes a memory and a processor. The memory is used to store non-temporary computer-readable instructions. Specifically, the memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The non-volatile memory may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc.
[0149] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in the computer device to perform desired functions. In one embodiment of the present disclosure, the processor is used to run the computer-readable instructions stored in the memory, so that the computer device executes all or part of the steps of the real-time access control method based on the Linux application layer of each embodiment of the present disclosure.
[0150] Those skilled in the art should be able to understand that in order to solve the technical problem of how to obtain a good user experience, the present embodiment may also include well-known structures such as a communication bus and an interface, and these well-known structures should also be included in the protection scope of the present disclosure.
[0151] like Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure is shown, which is a schematic diagram of the structure of a computer device suitable for implementing the embodiment of the present disclosure. Figure 8 The computer device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0152] like Figure 8As shown, the computer device may include a processor (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) or a program loaded from a storage device into a random access memory (RAM). In the RAM, various programs and data required for the operation of the computer device are also stored. The processor, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus.
[0153] Typically, the following devices can be connected to the I / O interface: input devices such as sensors or visual information acquisition devices; output devices such as display screens; storage devices such as tapes, hard disks, etc.; and communication devices. The communication device can allow the computer device to communicate with other devices (such as edge computing devices) wirelessly or by wire to exchange data. Figure 8 A computer device having various devices is shown, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0154] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processor, all or part of the steps of the real-time access control method based on the Linux application layer of the embodiment of the present disclosure are executed.
[0155] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.
[0156] According to the computer-readable storage medium of the embodiment of the present disclosure, non-transitory computer-readable instructions are stored thereon. When the non-transitory computer-readable instructions are executed by a processor, all or part of the steps of the real-time access control method based on the Linux application layer of the aforementioned embodiments of the present disclosure are executed.
[0157] The above-mentioned computer-readable storage media include, but are not limited to: optical storage media (e.g., CD-ROM and DVD), magneto-optical storage media (e.g., MO), magnetic storage media (e.g., magnetic tape or mobile hard disk), media with built-in rewritable non-volatile memory (e.g., memory card) and media with built-in ROM (e.g., ROM box).
[0158] For detailed description of this embodiment, reference may be made to the corresponding descriptions in the aforementioned embodiments, which will not be repeated here.
[0159] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0160] In the present disclosure, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. The block diagrams of the devices, devices, equipment, and systems involved in the present disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagram. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open words, referring to "including but not limited to", and can be used interchangeably with them. The words "or" and "and" used here refer to the words "and / or" and can be used interchangeably with them, unless the context clearly indicates otherwise. The words "such as" used here refer to the phrase "such as but not limited to", and can be used interchangeably with them.
[0161] Additionally, as used herein, "or" used in a list of items beginning with "at least one" indicates a separate list, so that, for example, a list of "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not mean that the example described is preferred or better than other examples.
[0162] It should also be noted that in the system and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0163] Various changes, substitutions, and modifications of the techniques described herein may be made without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of the present disclosure is not limited to the specific aspects of the processes, machines, manufactures, compositions of events, means, methods, and actions described above. Currently existing or later to be developed processes, machines, manufactures, compositions of events, means, methods, or actions that perform substantially the same functions or achieve substantially the same results as the corresponding aspects described herein may be utilized. Thus, the appended claims include such processes, machines, manufactures, compositions of events, means, methods, or actions within their scope.
[0164] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0165] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A real-time access control method based on Linux application layer, characterized in that: include: Traverse the target system and obtain the controlled thread; The controlled threads include all running user threads; Create N control threads and N monitoring processes; Each of the monitoring processes corresponds to each of the control threads one by one, and each of the monitoring processes corresponds to M of the user threads; N≥1, M≥1; Acquiring events based on N monitoring processes; Get the thread ID that returns the event; Obtaining the source of the event based on the thread ID; If the source is the controlled thread, controlling access to the event based on a first access control policy; If the source is the control thread, controlling access to the event based on a second access control policy; The controlling the access to the event based on the first access control policy includes: obtaining the type of the event; if the type is a signal type, controlling the access to the event based on a first sub-policy; if the type is a system call type, controlling the access to the event based on a second sub-policy; The controlling the access to the event based on the first sub-strategy includes: obtaining the signal value of the event; determining whether the signal value is the same as the value of SIGSTOP, and if so, controlling the second thread to enter a paused and listening state; if not, not processing the second thread; The control of access to the event based on the second sub-strategy includes: if the type is a system call type, obtaining the overall register; obtaining the register offset based on the overall register; obtaining the system call number based on the register offset; judging whether the monitoring strategy is hit according to the system call number, and if not, not processing the second thread; if so, obtaining the system call parameters according to the register offset, and sending the system call number, the system call parameters, and the first ID information to the preset target layer through the IPC communication mechanism; The second access control strategy includes initializing a monitoring process, adding monitoring of a specified user thread, deleting monitoring of a specified user thread, releasing system calls to a user thread specified in a waiting queue, rejecting system calls to a user thread specified in a waiting queue, reconfiguring a global control strategy, configuring a control strategy separately for a specified user thread, and exiting monitoring of a user thread.
2. The real-time access control method based on Linux application layer according to claim 1 is characterized in that: The acquiring returns the thread ID of the event, including: Call the wait event function; When the event occurs, the thread ID of the event is returned based on the wait event function.
3. The real-time access control method based on Linux application layer according to claim 2 is characterized in that: The obtaining the source of the event based on the thread ID includes: According to the monitoring process that monitors the event, determining a control thread corresponding to the monitoring process and marking it as a first thread; Obtaining first ID information of the first thread; Determine whether the thread ID is consistent with the first ID information, and if so, determine that the event is a control message from the first thread; If not, determine that the source is the controlled thread and mark the corresponding controlled thread as the second thread.
4. The real-time access control method based on Linux application layer according to claim 1 is characterized in that: The method further comprises: establishing a data structure for each of the user threads being run; The data structure is assigned an initial value of 0.
5. A computer device, characterized in that: The computer device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the real-time access control method based on the Linux application layer as described in any one of claims 1-4.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the real-time access control method based on the Linux application layer as described in any one of claims 1-4.
Citation Information
Patent Citations
Comprehensive monitoring and training system and implementing method thereof
CN103823672A
Cloud storage quota management method based on Linux kernel monitoring
CN105468989A
Access control method, device and equipment and computer readable storage medium
CN112084512A
WDT monitoring method and device and medium
CN114328083A
Linux system process hiding method and device, electronic equipment and storage medium
CN117891682A
