A method, system and computer readable storage medium

By associating exception handlers and user programs in the operating system, it ensures that protected partition data can only be processed in the kernel space, which solves the problem of insufficient security of low-cost devices, realizes data security protection, and is suitable for low-cost IoT devices.

CN112541166BActive Publication Date: 2024-09-06C SKY MICROSYST CO LTD
View PDF 17 Cites 0 Cited by

Patent Information

Application Number
CN201910890559.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-09-20
Publication Date
2024-09-06
Estimated Expiration
2039-09-20

AI Technical Summary

Technical Problem

In the pursuit of cost-effectiveness, low-cost devices ignore security, resulting in private data leakage and insufficient identity security, and can easily be exploited to copy devices or use cloud services for free.

Method used

By associating specified exceptions with exception handlers in the operating system, user programs are restricted to be executed only by users with ordinary privileges, and protected partitions can only be read by users with the highest privileges. The exception handler is used to process data in the kernel space to ensure Data security.

Benefits of technology

It effectively protects the data security of protected partitions, prevents data leakage and identity attacks, and is suitable for low-cost, low-power IoT devices with almost no increase in manufacturing costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112541166B
    Figure CN112541166B
Patent Text Reader

Abstract

A method, system and computer-readable storage medium are disclosed. The method includes: in an operating system, associating a specified exception with an exception handler; limiting a user program to be executable only by ordinary privileged users; specifying a protected partition and limiting the protected partition to be readable only by the highest privileged user, wherein when the user program is executed in the user space corresponding to the ordinary privileged user, a specified exception is generated, the specified exception triggers the execution of the exception handler in the kernel space, the exception handler reads data from the protected partition, and passes the processed data to the user program. The technical solution of the present invention utilizes the permission setting and exception handling mechanism of the existing operating system, limits the user program to read data in the protected partition only through the exception handler, and further limits the exception handler to output the processed data, thereby ensuring the data security of the protected partition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip manufacturing, and more specifically, to a method, a system and a computer-readable storage medium. Background Art

[0002] In the fragmented application field of the Internet of Things, there is a type of device that has the characteristics of low cost, low power consumption, and few resources. It is large in number and widely used, mainly in the fields of sensors, industrial control, consumer electronics, IoT (Internet of Things) products, etc. Due to the large number and extremely stringent cost requirements, the final product does not have basic security functions. This directly leads to the manufacturer's private data or product function authentication information being easily leaked during the secondary development process of the product or during the production process. The profit thief can directly read the valuable data information through the debugging interface, or directly read this type of data information through the user code developed by himself, analyze it, and then extract valuable or sensitive information. Using this valuable or sensitive information, the profit thief can quickly copy the same type of device with the same function. Some devices use this information to communicate directly with the cloud server, conceal their identity, and use cloud services for free. Some devices have the function of automatic networking. Considering the real-time and ease of use, the networking protocol has low security for identity recognition, and some even have no identity recognition function. This results in any device with networking information being able to freely join the networking local network, and further use the devices on other network nodes to obtain more valuable information, and even cause dangerous time.

[0003] The root cause is that such devices sacrifice safety requirements while pursuing low costs. However, due to cost pressure, improving the safety of such devices is still a technical challenge for technicians in this field. Summary of the invention

[0004] In view of this, this solution proposes a low-cost security solution to solve the above problems.

[0005] To achieve this object, in a first aspect, the present invention provides a method comprising:

[0006] In the operating system, a specified exception is associated with an exception handler;

[0007] Limit user programs to be executable only by users with normal permissions;

[0008] Designate a protected partition and limit the protected partition to be readable only by the highest-privileged user, wherein the user program is executed in the user space corresponding to the ordinary-privileged user and generates a specified exception, the specified exception triggers the exception handler to be executed in the kernel space, the exception handler reads data from the protected partition and passes the processed data to the user program.

[0009] In some embodiments, the user program generates the specified exception by calling a system service program.

[0010] In some embodiments, the specified exception is generated when the system service program performs a write operation on a read-only storage area.

[0011] In some embodiments, the system service program generates the specified exception when reading a read-only storage area that can only be read by the highest-authority user.

[0012] In some embodiments, the read-only storage area is the protected partition.

[0013] In some embodiments, when the operating system is started, the exception handler is copied to a corresponding position of an exception interrupt vector of the operating system.

[0014] In some embodiments, triggering the exception handler to execute in kernel space includes:

[0015] In the kernel space, the operating system responds to the specified exception, calculates a return address after handling the exception and saves status information, and then executes the exception handling program according to the specified exception.

[0016] In some embodiments, the method further includes: returning to the user program according to the return address after handling the exception.

[0017] In some embodiments, the exception handling program writes the processed data into a data file and grants the normal permission user read permission.

[0018] In some embodiments, it also includes:

[0019] Receive debugging commands;

[0020] comparing the debug address specified by the debug command with the protected access address; and

[0021] If they are the same, the debugging command is filtered out.

[0022] In some embodiments, the method further includes: if one of the debug address and the access address is a virtual address and the other is a physical address, converting both of the debug address and the access address into a virtual address or a physical address according to a conversion table.

[0023] In some embodiments, the method further includes: setting a flag bit, wherein the flag bit determines whether to perform debugging control.

[0024] In some embodiments, the flag is stored in the protected partition.

[0025] In a second aspect, the present invention provides a system, comprising:

[0026] a processor for executing instructions from an operating system, a security access management module, and user programs;

[0027] A storage device coupled to the processor, wherein at least a portion of the storage space of the storage device is divided into a kernel space and a user space, wherein a plurality of instructions of the operating system and the security access management module are executed by the processor in the kernel space, and a plurality of instructions of the user program are executed by the processor in the user space;

[0028] Among them, the operating system associates the specified exception with the exception handler, the security control module specifies the protected partition and limits the protected partition to be readable only by the highest-privileged user, and limits the user program to be executable only by ordinary-privileged users. After the user program is started by the ordinary-privileged user, a specified exception is generated, and the specified exception triggers the exception handler to be executed in the kernel space. The exception handler reads data from the protected partition and passes the processed data to the user program.

[0029] In some embodiments, the user program generates the specified exception by calling a system service program.

[0030] In some embodiments, the specified exception is generated when the system service program performs a write operation on a read-only storage area.

[0031] In some embodiments, the system service program generates the specified exception when reading a read-only storage area that can only be read by the highest-authority user.

[0032] In some embodiments, the read-only storage area is the protected partition.

[0033] In some embodiments, it also includes: a debugging control management module, which is used to compare the debugging address specified by the received debugging command with the access address of the protected partition, and filter out the corresponding debugging command when the two are the same.

[0034] In some embodiments, it also includes: a marking bit setting unit, which is used to set a flag bit, and the flag bit determines whether to perform debugging control.

[0035] In some embodiments, the flag is stored in the protected partition.

[0036] In a third aspect, the present invention provides a computer-readable storage medium, comprising a plurality of instructions, wherein the plurality of instructions respectively form an operating system, a user program, and an exception handling program, and the instructions of the operating system, the user program, and the exception handling program implement the following operations when executed by a processor:

[0037] In the operating system, a specified exception is associated with an exception handler;

[0038] Limit user programs to be executable only by users with normal permissions;

[0039] Specify protected partitions and restrict them to be readable only by users with the highest permissions;

[0040] The user program is started by the ordinary authority user.

[0041] The user program is executed in the user space corresponding to the ordinary privileged user and generates a specified exception. The specified exception triggers the exception handler to execute in the kernel space. The exception handler reads data from the protected partition and passes the processed data to the user program.

[0042] The technical solution of the present invention utilizes the permission setting and exception handling mechanism of the operating system to limit the user program to read the data in the protected partition only through the exception handling program, and further limit the exception handling program to output the processed data, thereby ensuring the data security of the protected partition.

[0043] Furthermore, the implementation of this technical solution is mainly carried out at the software level, so it hardly increases the manufacturing cost of the product, and is particularly suitable for low-cost, low-power, and low-resource IoT devices. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The above and other objects, features and advantages of the present invention will become more apparent through the description of the embodiments of the present invention with reference to the following drawings, in which:

[0045] Figure 1 An application scenario diagram showing the interaction between the processing device 101 and the processing device 102 is shown;

[0046] Figure 2 A schematic diagram of the structure of an exemplary processing device 102 is shown;

[0047] Figure 3An interaction diagram of a normal user, a secure user program, an operating system, and an exception handler is shown;

[0048] Figure 4 A schematic diagram of an exemplary debugging control management module, a host computer and a processing device is shown. DETAILED DESCRIPTION

[0049] The present invention is described below based on embodiments, but the present invention is not limited to these embodiments. In the detailed description of the present invention below, some specific details are described in detail. It is possible for a person skilled in the art to fully understand the present invention without the description of these details. In order to avoid confusing the essence of the present invention, known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.

[0050] For the sake of clarity, considering the different meanings of the terms "Exception" and "Interrupt" in different CPU architectures (x86, ARM, RISC_V, PowerPC, etc.), "Exception" in this article is limited to software exceptions that occur during the program's operation, and "Interrupt" is limited to hardware-related interrupts. For the operating system, both exceptions and interrupts are processed through a unified entry: the exception interrupt vector. The exception interrupt vector includes various types of exceptions and interrupts, as well as the handler address corresponding to each exception interrupt type and the corresponding control flow. When an exception or interrupt is triggered, the processor will jump to the handler address corresponding to the type of exception or interrupt to start execution. Exceptions can be divided into recoverable and non-recoverable. Specifically, if an exception is triggered during the execution of a user program, after entering the exception handler, it can be restored to the processing scenario of the user program, that is, restored to the current instruction or the next instruction that generated the exception. In this case, the exception type is a recoverable exception, otherwise it is an non-recoverable exception. Interrupts are all non-recoverable.

[0051] In at least one embodiment below, it is mentioned that a processor component including a high-power core and a low-power core can be used to perform corresponding processing, but processing allocation based on high-power cores and low-power cores is not the focus of the present invention. Therefore, in the following embodiments, the processor component can basically be treated as a whole.

[0052] The processing device mentioned below can be various types of computer systems, including but not limited to desktops, servers, notebooks and workstations, and can also be various embedded products, including but not limited to cellular phones, Internet protocol devices, digital cameras, personal digital assistants (PDAs), handheld PCs, network computers (NetPCs), set-top boxes, network hubs, and wide area network (WAN) switches. A control system based on software and hardware is deployed on the processing device, and the control system can be partially integrated in the processing device and partially deployed to the processing device by installation. Different types of processing devices may have different names for the control system, but for the convenience of description, this article will collectively refer to it as an operating system. The operating system defaults to a multi-user management mode, including at least two users: a normal authority user and a highest authority user. The operating system in multi-user management mode will divide the addressing space of the memory into kernel space and at least one user space in software logic. For example, for the Linux operating system, the highest 1G bytes (from virtual address 0xC0000000 to 0xFFFFFFFF) are used as kernel space, and the lower 3G bytes (from virtual address 0x00000000 to 0xBFFFFFFF) are used as user space. The kernel space stores the code and data of the operating system, and the user space stores the code and data of user programs created by users. Tasks can be performed in the kernel space or in the user space. The working mode of the processor is thus divided into kernel state and user state. The processor has more permissions in kernel state than in user state. For example, the processor can access all data and instructions in kernel space and user space when working in kernel state, and can access peripheral devices such as hard disk and network card through device drivers. The processor can only access data and instructions in its own user space when executing in user state. However, when the processor is working in user space, it can switch from user space to kernel space, that is, from user state to kernel state, through system calls, exceptions, and interrupts from peripheral devices.

[0053] Figure 1 FIG. 1 shows an application scenario diagram of the interaction between the processing device 101 and the processing device 102. Figure 1 , the processing device 102 includes a protected partition 1021. The protected partition 1021 is any partition in the processing device 102, which can be specified by a physical address or a virtual address. The protected partition 1021 stores protected data, such as some important code and data information. The device information, ID, key, etc. during product production can be written into the partition. The processing device 101 includes a user program 1011. The user program 1011 reads the data in the protected partition 1021 in a controlled manner, so that the user program 1011 can only obtain the data processed by the protected data, thereby ensuring the data security in the protected partition 1021.

[0054] Processing device 101 and processing device 102, in a general sense, can be any device, including but not limited to flash memory chips, processors (CPUs), digital processors (DSPs), systems on chips, processing units manufactured for various special purposes, and various electronic products formed on this basis. When processing device 101 is, for example, a flash memory, and processing device 102 is a computer, processing device 101 and processing device 102 can be regarded as a computer system as a whole. When processing device 101 and processing device 102 are, for example, computers, processing device 101 either remotely executes user programs, or copies user programs to processing device 102 for execution. Figure 2 A schematic structural diagram of an exemplary processing device 102 is shown.

[0055] refer to Figure 2 , the processing device 102 includes a storage device 201 and a processing subsystem 300 coupled together via a bus unit 302. The processing subsystem 300 includes a storage controller 301 corresponding to the storage device 201, and the processing subsystem 300 controls the operation of the storage device 201 via the storage controller 301. For example, the processing subsystem 300 can exchange data with the storage device 201 in the form of a data block. In this example, the storage controller 301 and the storage device 201 are shown as independent devices, but in other cases, the functions of the storage controller 301 and the storage device 201 are integrated into one device.

[0056] The processing subsystem 300 executes multiple application routines 3311 to complete the execution of multiple tasks. Each application routine 3311 can be any application of multiple types, including but not limited to word processing programs, spreadsheet editors, CAD / CAM software, website browsers, audio / visual recording and / or playback software, photo editors, etc. As a management and scheduling center for various tasks, the operating system 340 is also executed by the processor component 305 as part of the processing subsystem 300. The operating system 340 can provide an operating environment to support the execution of multiple application routines 3311. For this purpose, the operating system 340 executes one or more device drivers, and the operating environment of the operating system is extended by the device driver to provide support for various types of devices. For example, the storage device driver 3402 supports the communication between the storage controller 301 and the external storage device 201, and the I / O driver 3403 supports the communication between the I / O controller 303 and the external I / O control.

[0057] In various embodiments, the processing subsystem 300 may include a processor component 305. The processor component 305 may include one or more processor cores 3051, and the multiple processor cores may include, for example, a high-power core with higher speed and higher complexity and a low-power core with lower speed and lower complexity. Some storage devices 330 that are more efficient than the storage devices in the storage subsystem 201 are divided in the processing subsystem 300 to provide the processor component 305 with intermediate storage and cache required for various processing.

[0058] In various embodiments, the storage device 330 is divided into a kernel space and one or more user spaces 331 according to the address range of the storage location. In a multi-user management operating environment, one or more user spaces 331 belong to the running space of one or more user programs, and the kernel space belongs to the running space of the operating system and system programs. In the kernel space, for example, the operating system 340, page table 3322, page buffer 3321, interrupt table (IDT) 3323, translation table 3324, block cache 3326 and user permission table 3327 and other table items related to the operation of the operating system can be stored. The page table 3322 associates the virtual address of the page of the application 2011 with the physical address used for the page in the storage device 330. The block buffer 3326 is used to cache the data in the storage device 201 in the form of blocks, and can provide page data retrieved in the form of pages. The translation table 3324 is used to associate the virtual address of the page with the identifier of one or more data blocks in the storage device 201 that may include the content of the page. The user permission table 3327 is a relationship table between multiple users and permissions.

[0059] In various embodiments, the processor component 305 can be coupled to a memory protection unit (MPU) 306. The processor component 305 can access the storage device 330 via the memory protection unit 306. The memory protection unit 306 is implemented using hardware logic and uses regions to manage the storage space. A domain is an attribute associated with a storage space. The operating system can then assign more attributes to the domain, such as access rights, cache, etc. Therefore, as an optional implementation, the above-mentioned division of kernel space and user space can be implemented using a memory protection unit and an operating system.

[0060] In each of the one or more user spaces 331, an application routine 3311 and a data buffer 3331 may be stored. The application routine 3311 is a copy of at least a portion of the application 2011 stored on the storage device 201. The data buffer 3331 is a copy of at least a portion of the data 2012 stored in the storage device 202. Although in some embodiments, the storage device driver 3402 and the I / O driver 3403 may be provided by a different vendor from the vendor of the operating system 340, these drivers may be considered as components of the operating system 340 according to the way they interact, as shown in the figure. The operating system 340 may be a currently generally applicable WINDOWS TM Operating system version, one of UNIX operating system, Linux operating system, Android operating system, and RealTime OS operating system.

[0061] One or more processor cores 3051 have the same or different instruction sets, and through the instruction set, any processor core 3051 can decode and execute any instruction contained in the application routine 3311 and the operating system 340. As shown in the figure, the operating system 340 may also include a mode controller 3401. The mode controller 3401 can make decisions on the execution of multiple processor cores. For example, in some embodiments, the mode controller 3401 can monitor the level of demand for processing resources, and can dynamically place the processor component 305 in one of multiple modes according to the level. For example, when the demand for processing resources drops to a level that can be provided by the low-power core alone, the mode controller 3401 can place the processor component 3401 in a mode in which the low-power core executes instructions but the high-power core does not execute. In addition, when the demand for processing resources rises to a level close to the upper limit that the low-power core can provide, the mode controller 3401 can place the processor component 305 in a mode in which both the high-power core and the low-power core execute instructions in a collaborative manner.

[0062] The processing subsystem 300 also includes a JTAG module 304. JTAG (Joint Test Action Group) is an international standard test protocol (IEEE 1149.1 compatible), which is mainly used for circuit testing inside a chip. For the convenience of description, in this article, all the hardware and software units required to support JTAG testing included in the subsystem 300 are generally referred to as JTAG modules 304. A test signal can be sent to the JTAG module 304 to drive the execution of various internal related circuits, and the test results can be determined based on the output signals.

[0063] The storage device 330 and the storage device 201 can be implemented based on any technology of a wide range of various information storage technologies. Each of the above storage devices includes, but is not limited to, a read-only memory (ROM), a random access memory (RAM), a dynamic RAM (DRAM), a double data rate DRAM (DDRAM), a synchronous DRAM (SDRAM), a static RAM (SRAM), a programmable ROM (PROM), an erasable programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), a flash memory, a polymer memory (e.g., a ferroelectric polymer memory), a bidirectional memory, a phase change or ferroelectric memory, a silicon oxide nitride oxide silicon (SONOS) memory, a magnetic card or an optical card, one or more individual ferromagnetic disk drives or a plurality of storage devices organized into one or more arrays (e.g., a plurality of ferromagnetic disk drives organized into a redundant array of independent disks or a RAID array). It should be noted that although each of these storage devices is shown as a single storage device, it may include multiple storage components based on different storage technologies. For example, storage device 330 may represent a combination of an optical drive or flash card reader through which programs and / or data may be stored and transported on some form of machine-readable storage medium, a ferromagnetic disk drive that stores programs and / or data locally for relatively long periods of time, and one or more volatile solid-state memory devices (e.g., SRAM or DRAM) that allow relatively fast access to programs and / or data. Alternatively, each storage device may be composed of multiple storage components based on the same storage technology but maintained separately due to specialization of use (e.g., some DRAM devices used as main storage devices, while other DRAM devices used as unique frame buffers for graphics controllers).

[0064] Based on the location and usage of storage device 330 and storage device 201, a typical choice is: storage device 330 uses volatile storage technology that provides electrical power uninterruptedly, which may need to provide higher power, but has a relatively higher speed and faster processing, such as using one or more of random access memory (RAM), dynamic RAM (DRAM), double data rate DRAM (DDRAM), synchronous DRAM (SDRAM), and static RAM (SRAM), while storage devices 201-202 use non-volatile storage technology, such as flash memory.

[0065] In order to ensure the data security in the protected partition 1021, the protected partition 1021 can be selected to be set in a certain area in the kernel space of the storage device 330, and the storage device used to store the protected partition is required to be a non-volatile memory to ensure that the data in the segment area will not be lost after the operating system is powered off. For example, the protected partition can be set in a segment area of ​​ROM. In this case, since the data in the kernel space is basically "invisible" to the user program, the data security in the protected partition can be improved. In addition, the protected partition 1021 can also be set in the storage device 201, and in order to prevent the user program from reading data from the protected partition 1021, the protected partition can be set to be executable only by the highest authority user. However, in this case, the user program of ordinary authority can still improve the access rights through the security loophole of the system call to access the protected partition 1021 in the kernel space.

[0066] To this end, the processing device also provides a security access management module to further strengthen the access control to the protected partition 1021.

[0067] The security access management module sets the operation permissions of the protected partition and strictly manages the execution flow from the processor and the direct memory access (DMA) of the peripheral device to the partition. The security access management module 302 can be divided into three logical processing functions: 1) used to specify the location and size of the protected partition; 2) set the access permissions of the protected partition so that only the highest-authorized user can read it, and other users do not have read permissions; 3) provide an exception handler for extracting protected data from the protected partition 3021 when a specified exception occurs, and outputting the data after processing. The processing method, for example, encrypts the key and outputs it, or hides the key configuration information in the device information, and so on. The processed data no longer needs to be kept confidential, and users can use it with confidence.

[0068] In addition, the operation permissions of user programs need to be limited to only users with ordinary permissions. Generally, since the developers of user programs (here refers to the developers who carry out secondary development after the product is delivered to the customer) are limited to only ordinary user permissions and do not have the highest permissions, the user programs they develop are executed by ordinary users by default. For exceptions, user programs can be forcibly limited to only ordinary users.

[0069] Since the security management module 302 needs to set the operation permissions of the protected partition, the security access module needs to be started by the user with the highest permissions. In addition, as an interface function provided to the user program, the exception handler is generally not set to have independent permissions. In order to allow the user program to use the exception handler only in exception handling, the operation permissions of the file containing the exception handler can be limited to only the user with the highest permissions.

[0070] In addition, in order to prevent the user program developers from using system service programs to access the protected partition through system calls, all system service programs can be set to be executable only by the highest-privileged user. System service programs are a group of subroutines provided by the operating system to implement various system functions. For a general-purpose OS, system service programs may include: device management, file management, process management, and memory management.

[0071] For the above permissions, you can use the permission setting command provided by the operating system (such as chmod in Linux / Unix) to set them, or you can call the relevant interface in the program to set them. The final permissions of each subject are shown in Table 1.

[0072] Table 1

[0073]

[0074] The protected partition, the security access management module 302 and the security access management module are all located on the processing device 102, while the user program can be located on the processing device 101 or copied to the processing device 102 for running.

[0075] Based on the above permissions, any user program can only access the protected partition in a controlled manner. The specific analysis is as follows.

[0076] First, the user program cannot directly access the protected partition. This is because the user program is limited to being started by users with ordinary permissions. Therefore, after the user program is started by a user with ordinary permissions, when the user program wants to read the data in the protected partition, since the protected partition is limited to being read and written by users with the highest permissions, the processor will generate an exception at this time, causing the user program to fail to read the data in the protected partition.

[0077] Secondly, user programs cannot obtain data in protected partitions by increasing operating privileges through system calls. Since system service programs are set to be executable only by users with the highest privileges, the highest privilege user is required to execute user programs, and user programs are required to be executable only by users with ordinary privileges. Therefore, after starting a user program with ordinary user privileges, when the code that calls the system service program is executed, the processor will generate an exception.

[0078] Third, in order to enable the user program to access the data in the protected partition, it is necessary to generate a specified exception in the user program, and then execute the functional service that the user program needs to call in the exception handling corresponding to the exception. The functional service uses the exception handler of the security access management module to access the data in the protected partition and return the processed data. Since the exception handling is executed in the kernel space, it can be executed successfully. In this way, the user program can only obtain the data processed from the original data in the protected partition, thereby ensuring the data security in the protected partition.

[0079] As an alternative to the above embodiment, a special user can also be established in the operating system. This special user is not open to public use. The permissions of the protected partition are specified to be readable and accessible only by this special user. Other permission settings remain unchanged, and the processed data can still be obtained according to the above operations.

[0080] For the specified exceptions generated by user programs, we will take the exception types supported by ARM architecture processors as an example to explain in detail. Other architectures, such as X86, MIPS, and PowerPC, may be slightly different, but the basic principles should be common.

[0081] Table 2 is used to represent data information of at least a portion of an abnormal interrupt vector.

[0082] Table 2

[0083]

[0084]

[0085] Generally speaking, the code of the operating system contains the exception interrupt vectors shown in Table 2. In Table 2, the entry address (corresponding to the vector address in Table 2) of the handler corresponding to each exception interrupt type (corresponding to the exception interrupt type in Table 2) is specified. The entry address is obtained by adding the offset to the base address of the exception interrupt vector. After the corresponding exception interrupt type occurs, the system will jump to the entry address and execute the instructions there, and the processor will enter the corresponding exception interrupt mode (corresponding to the exception interrupt mode in Table 2). For this purpose, the exception handler corresponding to the exception interrupt type needs to be copied or solidified to the corresponding entry address in advance.

[0086] Although in theory, user programs can generate any type of abnormal interrupt, in fact, for the present invention, user programs need to generate controllable and recoverable abnormal interrupt types. Controllable means that the necessary means can be used to generate the exception, and recoverable means that after the abnormal interrupt handler is executed, it can be restored to the processing scene before the interrupt occurs. After testing, "data access abort" can be selected as the specified exception. "Data access abort" means that the address of the instruction that the processor is preparing to access does not exist, or the address does not allow the current instruction to access.

[0087] Various system service programs that operate on memory or files can be called in user programs to generate data abort exceptions. For example, a data abort exception will be generated when a system service program that writes to memory writes to a read-only storage area. For another example, if a storage area (such as a protected partition) is only allowed to be read by the highest-privileged user, a data abort exception will also be generated when a user with ordinary privileges reads it. However, it should be pointed out that it is necessary to ensure that ordinary-privileged users have execution permissions for the corresponding system service programs, so that these system service programs can be successfully called in user programs, and data abort exceptions can be generated during the execution of these system service programs.

[0088] It is also necessary to associate the specified exception with the exception handler. That is, add the data and code associated with the specified exception and the exception handler to the exception handling vector, and copy the exception handler code to the vector address corresponding to the exception interrupt vector after the operating system is started. For embedded systems, the exception handler code can be solidified in the processor's ROM.

[0089] After the above operations, it can be achieved that when the specified exception occurs, the corresponding exception handler will be triggered. Of course, the development process is much more complicated than this, and a lot of debugging and testing are required to achieve the expected results.

[0090] Below Figure 3 The interaction diagram is used as an example to further illustrate the relationship between the various programs. Figure 3 In the figure, the secure user program refers to the user program that generates the specified exception and thereby triggers the exception handling program in the above-mentioned security management access module. Most of the control flow of the abnormal interrupt has been implemented in the operating system, so the operating system is also shown as an independent subject in the figure.

[0091] In step S1, ordinary user A starts the secure user program 400. According to the above settings, the user program 400 is limited by the security access management module to be executable only by ordinary users, so this step can be executed smoothly.

[0092] In step S2, the security application 400 generates a specified exception.

[0093] In step S3, the operating system 402 receives a specified exception.

[0094] In step S4, the operating system 402 jumps to the exception interrupt vector to perform on-site saving operations: calculating the return address after handling the exception and saving the status information. Because it is necessary to restore to the next instruction of the instruction where the exception occurred, it is necessary to save the status information when the exception occurred and the return address after handling the exception.

[0095] In step S5, the operating system 402 calls the exception handler in the kernel space.

[0096] In step S6, the exception handling program 401 reads data from the protected partition for processing.

[0097] Since the exception handling program 401 runs in the kernel space, it can successfully read data from the protected partition and return after processing.

[0098] Step S7: The exception handling program 401 returns data to the operating system 402.

[0099] Step S8: The operating system 402 returns data to the user program. Since the operating system saves the state information of the user program and the return address after handling the exception before handling the exception, the user program can be restored after handling the exception.

[0100] Step S8 is not a necessary step, that is, it is not necessary to return to the user program for execution. The purpose of returning to the user program is to pass the processed data to the user program, but the exception handling program 401 can store the processed data in a data file and grant the ordinary user with read permission, so that the processed data does not need to be passed through parameters.

[0101] Through the above steps, the data obtained by the secure user program from the protected partition are all processed data, thereby ensuring the security of the data in the protected partition.

[0102] In summary, the technical solution provided by the present invention firstly utilizes the permission setting of the operating system to limit the normal permission users from directly reading the data in the protected partition, so that the user programs under the normal permission users cannot directly read the data in the protected partition, and then utilizes the exception handling mechanism of the operating system to associate the specified exception with the exception handling program. When the user program generates the specified exception, the exception handling program is triggered to execute in the kernel space to read the data in the protected partition and output the processed data, so as to ensure the data security of the protected partition. The implementation of this technical solution is mainly carried out at the software level, so it will hardly increase the manufacturing cost of the product, and is particularly suitable for low-cost, low-power, and low-resource IoT devices.

[0103] Furthermore, more levels of access control can be established for the protected partition, for example, three levels of access control can be established. For the third-level user, the above technical solution is adopted so that he can only use the user program to obtain the processed data from the protected partition. For the second-level user and the first-level user, the permission setting of the operating system is used so that the second-level user only has the read permission to part of the data in the protected partition, and the first-level user can arbitrarily read and modify the data in the protected partition. In this way, the security requirements of the processing device in different scenarios can be met.

[0104] In addition, as an extended technical solution of the present invention, the protected partition can be designated as being writable only by the highest-privileged user. When the user program is executed in the user space, a specified exception is generated, triggering the exception handler to be executed in the kernel space. The exception handler can modify part of the data in the protected partition (the protected partition can pre-set part of the data to be read-only, and part of the data to be readable and writable), so that the user can only modify the data in the protected partition in a restricted manner, thereby ensuring the write security of the protected partition.

[0105] In order to strengthen security management, in addition to the above-mentioned security access control module, the processing device also provides a debugging control management module for parsing debugging commands from the host computer, comparing the debugging address specified by the debugging command with the address of the protected partition, and filtering the commands for debugging the protected partition. Figure 4 A schematic diagram of an exemplary debugging control management module, a host computer, and a processing device is shown. Figure 4, the host computer 401 sends a debugging command to the TAP controller 402. The TAP controller 402 is responsible for arranging the debugging command into a JTAG signal and applying it to the corresponding port of the interface circuit 403. The JTAG signal includes TDI, TMI, TDO, and TCK signals. Correspondingly, the input ports through which the debugging command is transmitted are the TDI, TMI, TDO, and TCK ports, and the output port through which the debugging command is transmitted is the TDO port. Among them, the TDI port is used to input the debugging command, the TCK port is used to input the test clock signal, the TMS port is used to receive the test mode selection signal input, and the TDO port is used to output the test result data. Multiple boundary scan devices 4031 are serially interconnected. After receiving the debugging command sent from the TDI port, the execution of the boundary scan device 4031 is started, and the result data is output from the output interface TDO. The output result data is returned to the host computer 401 by the TAP controller.

[0106] In this example, the TAP controller 402 also includes a debug control management module 4021 for monitoring and filtering debug commands. When a debug command is received, the debug control management module 4021 checks whether the command is a debug command for the protected partition. If so, it is filtered out. If not, the TAP controller 402 performs subsequent processing. For example, if the GDB command x / 32xw0x40000000, that is, to debug the debug address of 0x40000000, and the secure partition is also located at 0x40000000, at this time, the debug control management module will filter out all debug commands for this address. Among them, the debug address specified by the debug command can be a virtual address of the memory (associated with the physical address through the memory management unit), or it can be a physical address of the memory. If it is known that the parameter passed in by the debug control management mode is a virtual address, but the protected partition uses a physical address to specify the access address, the virtual address can be converted into a physical address according to the conversion table, or the access address can be converted into a virtual address.

[0107] It should be noted that the TAP controller 402 can be located on the processing device like the interface circuit 403, for example, the TAP controller 402 and the interface circuit 403 are located together on a printed circuit board (if any), or can be located outside the processing device, for example, on an external test device. The TAP controller is essentially set up for circuit testing, so it may or may not be removed from the device after the product leaves the factory.

[0108] The control program of the debug control management module 4021 can be burned into the ROM. This control program can read a flag bit in the protected partition and decide whether to perform debug control according to the flag bit. Specifically, when the flag bit is not set, the control function of the debug control management module 4021 is not started. When the flag bit is set, the control function in the debug control management module 4021 is started. The setting of the flag bit can be performed by the debug control management module 4021 or by the security access management module.

[0109] The combined use of the security access management module and the debugging control module can ensure the data security of the protected partition in most cases, thereby ensuring the safe use of the processing device.

[0110] The above method can be applied to any processor architecture, and to flash memory chips, processors (CPU), digital signal processors (DSP), systems on chip, processing units manufactured for various special purposes, and various electronic products formed on this basis, such as smart phones, smart speakers, televisions, set-top boxes, players, firewalls, routers, laptops, tablets, PDAs, IoT (Internet of Things) products and other terminals that incorporate a combination of these functions.

[0111] For the present invention, the above-described processing units, processing systems, and electronic devices may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. For example, some aspects may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device, although the present invention is not limited thereto. Although various aspects of the present invention may be illustrated and described as block diagrams, flow charts, or using some other graphical representation to illustrate and describe various aspects of the present invention, it is well understood that, as non-limiting examples, the blocks, devices, systems, techniques, or methods described herein may be implemented in hardware, software, software, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof. If involved, the circuit design of the present invention may be implemented in various components such as integrated circuit modules.

[0112] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method comprising: In the operating system, a specified exception is associated with an exception handler; Limiting user programs to be executable only by users with normal permissions, wherein the user programs contain instructions that generate specified exceptions; Designate a protected partition and limit the protected partition to be readable only by the highest-privileged user; wherein, when the user program is executed in the user space corresponding to the ordinary-privileged user, the designated exception is generated, the designated exception triggers the exception handler to be executed in the kernel space, the exception handler reads the protected data from the protected partition, and passes the processed data to the user program, the processed data being data obtained by processing the protected data read from the protected partition.

2. The method according to claim 1, wherein: The user program generates the specified exception by calling the system service program.

3. The method according to claim 2, wherein: The specified exception is generated when the system service program performs a write operation on a read-only storage area.

4. The method according to claim 3, wherein: The specified exception is generated when the system service program reads a read-only storage area that can only be read by the highest-authority user.

5. The method according to claim 3 or 4, wherein: The read-only storage area is the protected partition.

6. The method according to claim 1, wherein: In the operating system, associating the specified exception with the exception handler includes: When the operating system is started, the exception handling program is copied to the exception interrupt vector of the operating system.

7. The method according to claim 6, wherein: The triggering of the exception handling program to be executed in the kernel space comprises: In the kernel space, the operating system responds to the specified exception, calculates a return address after handling the exception and saves status information, and then executes the exception handling program according to the specified exception.

8. The method according to claim 7, further comprising: Return to the user program according to the return address after handling the exception.

9. The method according to claim 1, wherein: The exception handling program writes the processed data into a data file and grants the ordinary permission user the read permission.

10. The method according to claim 1, wherein: Also includes: Receive debugging commands; Compare the debug address specified by the debug command with the protected access address; as well as If they are the same, the debugging command is filtered out.

11. The method according to claim 10, wherein: Also includes: If one of the debug address and the access address is a virtual address and the other is a physical address, both are converted into a virtual address or a physical address according to a conversion table.

12. The method according to claim 9, wherein: Also includes: A flag bit is set, and the flag bit determines whether to perform debugging control.

13. The method according to claim 12, wherein: The flag bit is stored in the protected partition.

14. A system comprising: a processor for executing instructions from an operating system, a security access management module, an exception handler, and a user program, wherein the user program includes instructions for generating a specified exception; A storage device coupled to the processor, wherein at least a portion of the storage space of the storage device is divided into a kernel space and a user space, wherein a plurality of instructions of the operating system and the security access management module are executed by the processor in the kernel space, and a plurality of instructions of the user program are executed by the processor in the user space; Among them, the operating system associates the specified exception with the exception handler, the security access management module specifies the protected partition and limits the protected partition to be readable only by the highest-privileged user, and limits the user program to be executable only by ordinary-privileged users. When the user program is executed in the user space corresponding to the ordinary-privileged user, a specified exception is generated. The specified exception triggers the exception handler to be executed in the kernel space. The exception handler reads the protected data from the protected partition and passes it to the user program after processing.

15. The system of claim 14, wherein: The user program generates the specified exception by calling the system service program.

16. The system of claim 15, wherein: The specified exception is generated when the system service program performs a write operation on a read-only storage area.

17. The system of claim 15, wherein: The specified exception is generated when the system service program reads a read-only storage area that can only be read by the highest-authority user.

18. The system according to claim 16 or 17, wherein: The read-only storage area is the protected partition.

19. The system of claim 13, wherein: Also includes: The debugging control management module is used to compare the debugging address specified by the received debugging command with the access address of the protected partition, and filter out the corresponding debugging command when the two are the same.

20. The system of claim 19, wherein: It also includes: a mark bit setting unit, which is used to set a flag bit, and the flag bit determines whether to perform debugging control.

21. The system of claim 20, wherein: The flag bit is stored in the protected partition.

22. A computer-readable storage medium, comprising a plurality of instructions, wherein the plurality of instructions respectively form an operating system, a user program, and an exception handling program, wherein the instructions of the operating system, the user program, and the exception handling program implement the following operations when executed by a processor: In the operating system, a specified exception is associated with an exception handler; Limiting user programs to be executable only by users with normal permissions, wherein the user programs contain instructions that generate specified exceptions; Specify protected partitions and restrict them to be readable only by the highest-privileged user. in, When the user program is executed in the user space corresponding to the ordinary privileged user, a specified exception is generated. The specified exception triggers the exception handler to be executed in the kernel space. The exception handler reads data from the protected partition and passes the processed data to the user program. The processed data is data obtained by processing the protected data read from the protected partition.

Citation Information

Patent Citations

  • Method for designing safety core of operation system based on protection mode and virtualization mechanism

    CN102184373A

  • Method and device for accessing coprocessor register

    CN102486758A

  • Storage protecting controller and method for improving safety of SOC (system on chip)

    CN102592083A

  • An in-process data isolation and protection method and system

    CN109840410A

  • Computer, kernel protection method, and computer software

    JP2009009232A