The present application is based on, and claims priority from JP Application Serial Number 2023-218788, filed Dec. 26, 2023, the disclosure of which is hereby incorporated by reference herein in its entirety.
The present disclosure relates to a setting method of a root file system of a computer and a computer program.
The root file system is the file system that stores the root directory and is the file system at the top of all other file systems that are mounted when the system boots. The root file system contains a number of startup files that are used when the computer starts up. Although the root file system is written in the ROM of the computer, there is a case where it is desired to update the root file system to a new root file system by using an external storage device such as an SD card in order to upgrade a part of the root file system.
In recent years, in order to improve security, it has been required to verify that firmware has not been tampered with. In order to secure boot a computer, it is necessary to verify the authenticity of the files contained in the root file system, but since the root file system on the SD card contains a large number of files, it takes time to verify the signature of files one by one.
JP-A-2021-177593 discloses a method for verifying the authenticity of a plurality of files. In this method, the system startup storage in the information processing device is divided into a partition 1 for storing files to be verified and a partition 2 for storing files not to be verified. Then, a plurality of files are compressed to create a compressed file, authentication data thereof is generated, and both are stored in the partition 1. When the compressed file is used, the signature of the compressed data is verified by using the authentication data, and when the authentication is successful, the plurality of files are expanded in the partition 2.
However, in JP-A-2021-177593, there is a problem that the authenticity of the entire root file system cannot be guaranteed because the system startup file in the root file system has already been started before the signature verification of the compressed file. Therefore, a technique that can guarantee the authenticity of the entire root file system is desired.
According to a first aspect of this disclosure, a setting method of a root file system of a computer, includes (a) a step of reading a compressed file obtained by compressing the entire partition of the root file system and an electronic signature of the compressed file from an external storage device and loading the compressed file and the electronic signature into a work area of a RAM of the computer, (b) a step of executing verification of the electronic signature for the compressed file loaded in the work area, and (c) a step of, when the verification is successful, setting the root file system by expanding the compressed file in the external storage device.
According to a second aspect of this disclosure, A non-transitory computer-readable storage medium storing a computer program for executing a process of setting up a root file system of a computer, the computer program causing the computer to execute: (a) a process of reading a compressed file obtained by compressing the entire partition of the root file system and an electronic signature of the compressed file from an external storage device and loading the compressed file and the electronic signature into a work area of a RAM of the computer, (b) a process of executing verification of the electronic signature for the compressed file loaded in the work area, and (c) a process of, when the verification is successful, setting the root file system by expanding the compressed file in the external storage device.
The controller 100 has a CPU 110 as a processor, a RAM 130, a ROM 120, and an external memory card 140. The ROM 120 is formed of, for example, a flash ROM. The external memory card 140 is, for example, an SD card, and is inserted into a memory card slot of the controller 100. The memory card slot may be connected to the controller 100 via a USB interface. The external memory card 140 stores a compressed file CFa including the entire root file system.
The present disclosure is applicable not only to the controller 100 for a robot, but also to other types of computers. In addition, as the external storage device for storing the compressed file CFa, other types of external storage devices other than SD cards can be used.
The ROM 120 includes a first boot loader area 121, a second boot loader area 122, a first ROM area 123, and a second ROM area 124. In the first boot loader area 121 stores a primary boot loader. In the second boot loader area 122 stores an initial program loader (IPL) as a secondary boot loader. As the IPL, for example, U-boot is used. The first ROM area 123 stores a plurality of programs including an expanding program DPM for expanding a file and authenticating an electronic signature. In the second ROM area 124 stores a startup file SF1 used when starting the controller 100 and a root file system. The startup file SF1 includes an OS kernel.
In the following description, the first ROM area 123 is referred to as a “ROM area 1” and the second ROM area 124 is referred to as a “ROM area 2”. In this embodiment, Linux® is used as an operating system (OS). However, the contents of the present disclosure can be applied to other operating systems other than Linux®.
The RAM 130 includes a kernel area 131 and a work area 132. In the first embodiment, a part of the RAM 130 is used as the RAM disk 133.
The external memory card 140 stores a compressed file CFa including the entire root file system. This compressed file CFa is stored in a normal file system that is not the root file system. This normal file system is, for example, FAT32. In the present embodiment, since the compressed file CFa is compressed in the zip format, a name “FAT32.zip” is given in
The compressed file Cobb obtained by compressing the entire partition of the root file system is a file in a squashfs format, which is a compressed file format for Linux®, and is named rootfs.squashfs in
The compressed file Cafe is created by further compressing the compressed file CFb obtained by compressing the entire partition of the root file system in another compressed file format. In the following description, the compressed file CFa is also referred to as an “upper compressed file CFa”, and the compressed file CFb is also referred to as a “lower compressed file CFb”. The reason why two stage compression is performed is that, in addition to the lower compressed file CFb, the startup file SF2 for starting the system with the external memory card 140 as the root file system and other data are compressed to create the upper compressed file CFa, and an electronic signature is attached to the upper compressed file CFa, so that these files can be collectively verified as a whole. However, the startup process of the present disclosure may be executed by using a compressed file obtained by compressing the entire partition of the root file system by one stage compression without performing such two stage compression.
When signature verification of the upper compressed file CFa is successful in a procedure to be described later, a root directory is set in the external memory card 140, and a root file system is expanded from the lower compressed file CFb. The root file system includes, for example, the following various programs and data.
These programs and data are stored in respective directories provided under the root directory. The lower compressed file CFb is created by compressing an image file of the root file system expanded into a format that can be written to the external memory card 140. An “image file” is data in which data recorded in a storage device is saved while maintaining a file or folder structure.
The process of
In step S02, the primary boot loader determines whether the IPL verification was successful. In the case where the verification of the IPL fails, the system is stopped and the processes of
In step S04, the IPL verifies the electronic signature DS2 in area 1. This verification is preferably the verification of the entire ROM area 1, but may also be the verification of the expanding program DPM stored in the ROM area 1. For this verification, the public key PK2 stored in advance in the second boot loader area 122 is used.
In step S05, the IPL determines whether or not the verification of the ROM area 1 is successful. In the case where the verification of the ROM area 1 fails, the system is stopped and the processes of
In step S07, the expanding program DPM of the ROM area 1 verifies the electronic signature DS3 of the ROM area 2. This verification is preferably verification of the entire ROM area 2, but may be verification of the startup file SF1 and the root file system stored in the ROM area 2. For this verification, the public key PK3 previously stored in the ROM area 1 is used.
In step S08, the expanding program DPM determines whether or not the verification of the ROM area 2 is successful. In the case where the verification of the ROM area 2 fails, the system is stopped and the processes of
In step S10 of
In step S11, the expanding program DPM determines whether or not the verification of the upper compressed file CFa has succeeded. In the case where the verification of the upper compressed file CFa failed, the process proceeds to step S18, where ROM 120 is specified as the root file system, and the OS kernel expanded in the kernel area 131 is started up in step S09. After the OS kernel is started, the application program for the update mode contained in the root file system is started. The “update mode” is a process mode in which the upper compressed file CFa stored in the external memory card 140 is overwritten with another upper compressed file that is considered to be authentic. Another upper compressed file with an electronic signature is transferred from an external device such as the information processing device 200. After step S18, it is preferable to rewrite the upper compressed file CFa stored in the external memory card 140 in the update mode.
In the case where the verification of the upper compressed file CFa is successful, the process proceeds to step S12, where the expanding program DPM reads the upper compressed file CFa from the external memory card 140 and expands the startup file SF2 included in the upper compressed file CFa into RAM 130. The startup file SF2 is a file for starting the system using the external memory card 140 as a root file system. This startup file SF2 is referred to as a “second startup file SF2.” The second startup file SF2 includes an OS kernel, and is overwritten with the first startup file SF1 expanded in the RAM 130 in the above-described step S09. If the second startup file SF2 is overwritten in the first startup file SF1, the OS kernel can be started using the authentic second startup file SF2 that was included in the upper compressed file CFa in which the verification of the electronic signature was successful.
The first startup file SF1 and the second startup file SF2 may have different functions. For example, the first startup file SF1 may have the function of the update mode and may not have the function as the controller of the robot. On the other hand, it is preferable that the second startup file SF2 has a function as a robot controller. The first startup file SF1 is preferably smaller in data amount than the second startup file SF2.
In step S13, the expanding program DPM starts the OS kernel with ROM 120 specified as the root file system. At this time, it is preferable to set a device-tree for ROM startup using the init=/root command. At this point, since the root file system is specified in the ROM 120, the external memory card 140 is not used as the root file system.
In step S14, the OS kernel creates the RAM disk 133 and mounts the partition of the root file system of the external memory card 140 as a normal file system. The reason why the partition of the root file system is mounted as a normal file system is that the ROM 120 is specified as the root file system in the above-described step S13.
In step S15, the OS kernel expands the upper compressed file CFa of the external memory card 140 and stores the lower compressed file CFb in the RAM disk 133. In step S16, the OS kernel expands the lower compressed file CFb stored in the RAM disk 133 into the external memory card 140. As a result, as shown in
When the root file system is set in step S17, the application program for the robot control mode is started. “Robot control mode” means a mode in which the controller 100 functions as a robot controller. The description of subsequent processes are omitted.
As described above, in the first embodiment, in the case where the verification of the electronic signature is successful for the compressed file CFa loaded in the work area 132 of the RAM 130, the root file system is set by expanding the compressed file CFa in the external memory card 140, so that the authenticity of the entire root file system can be guaranteed. Further, in the first embodiment, unlike the prior art for verifying individual files, since the compressed file CFa including the root file system is collectively verified, as compared with the prior art, it is possible to shorten the time required for verification. Furthermore, in the first embodiment, in the case where the verification of the compressed file CFa is unsuccessful, ROM 120 is set as the root file system, so that when the verification of the compressed file CFa is unsuccessful, the controller can be started using the authentic root file system stored in ROM 120.
The second embodiment differs from the first embodiment in the following two points, and is substantially the same as the first embodiment except for these points.
In step S21 of
The second embodiment also has substantially the same effect as the first embodiment. Further, since the RAM disk 133 is not used in the second embodiment, there is an advantage that memory resources can be saved.
The third embodiment is different from the second embodiment is only the following one point, except this is substantially the same as the second embodiment.
In step S31 of
The third embodiment also has substantially the same effects as the first embodiment and the second embodiment. However, in the first embodiment and the second embodiment, since a process such as step S31 of writing the lower compressed file CFb in the external memory card 140 is not included, the number of times of writing in the external memory card 140 can be reduced. Therefore, there is an advantage that the life of the external memory card 140 is not shortened.
The fourth embodiment is different from the second embodiment in only the following one point and, except for this is, it substantially the same as the second embodiment.
In step S41 of
The fourth embodiment also has substantially the same effect as the third embodiment described above.
The present disclosure is not limited to the embodiments described above, but can be realized in various forms without departing from the scope of the present disclosure. For example, the present disclosure can also be realized by the following aspects. The technical features in the above embodiments that correspond to the technical features in each aspect described below can be replaced or combined as appropriate to solve some or all of the issues of this disclosure or to achieve some or all of the effects of this disclosure. If a technical feature is not described as an essential feature in the present specification, the technical feature can be deleted as appropriate.
The present disclosure can be realized in various forms other than the above. For example, the disclosure can be realized in the form of a computer program for realizing the function of the controller, a non-transitory storage medium in which the computer program is recorded, or the like.
| Number | Date | Country | Kind |
|---|---|---|---|
| 2023-218788 | Dec 2023 | JP | national |