← Documents Documentation/security/IMA-templates.rst GitHub 원문 ↗

Linux 6.18.37 · Security

IMA 템플릿 관리 메커니즘

IMA template descriptor와 field 구조, 지원 필드·기본 형식·커널 명령줄 선택 방법을 설명합니다.

Source pathDocumentation/security/IMA-templates.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

IMA-templates.rst:1-111

IMA template descriptor와 field 구조, 지원 필드·기본 형식·커널 명령줄 선택 방법을 설명합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =================================
2 IMA Template Management Mechanism
3 =================================
4
5
6 Introduction
7 ============
8
9 The original ``ima`` template is fixed length, containing the filedata hash
10 and pathname. The filedata hash is limited to 20 bytes (md5/sha1).
11 The pathname is a null terminated string, limited to 255 characters.
12 To overcome these limitations and to add additional file metadata, it is
13 necessary to extend the current version of IMA by defining additional
14 templates. For example, information that could be possibly reported are
15 the inode UID/GID or the LSM labels either of the inode and of the process
16 that is accessing it.
17
18 However, the main problem to introduce this feature is that, each time
19 a new template is defined, the functions that generate and display
20 the measurements list would include the code for handling a new format
21 and, thus, would significantly grow over the time.
22
23 The proposed solution solves this problem by separating the template
24 management from the remaining IMA code. The core of this solution is the
25 definition of two new data structures: a template descriptor, to determine
26 which information should be included in the measurement list; a template
27 field, to generate and display data of a given type.
28
29 Managing templates with these structures is very simple. To support
30 a new data type, developers define the field identifier and implement
31 two functions, init() and show(), respectively to generate and display
32 measurement entries. Defining a new template descriptor requires
33 specifying the template format (a string of field identifiers separated
34 by the ``|`` character) through the ``ima_template_fmt`` kernel command line
35 parameter. At boot time, IMA initializes the chosen template descriptor
36 by translating the format into an array of template fields structures taken
37 from the set of the supported ones.
38
39 After the initialization step, IMA will call ``ima_alloc_init_template()``
40 (new function defined within the patches for the new template management
41 mechanism) to generate a new measurement entry by using the template
42 descriptor chosen through the kernel configuration or through the newly
43 introduced ``ima_template`` and ``ima_template_fmt`` kernel command line parameters.
44 It is during this phase that the advantages of the new architecture are
45 clearly shown: the latter function will not contain specific code to handle
46 a given template but, instead, it simply calls the ``init()`` method of the template
47 fields associated to the chosen template descriptor and store the result
48 (pointer to allocated data and data length) in the measurement entry structure.
49
50 The same mechanism is employed to display measurements entries.
51 The functions ``ima[_ascii]_measurements_show()`` retrieve, for each entry,
52 the template descriptor used to produce that entry and call the show()
53 method for each item of the array of template fields structures.
54
55
56
57 Supported Template Fields and Descriptors
58 =========================================
59
60 In the following, there is the list of supported template fields
61 ``('<identifier>': description)``, that can be used to define new template
62 descriptors by adding their identifier to the format string
63 (support for more data types will be added later):
64
65 - 'd': the digest of the event (i.e. the digest of a measured file),
66 calculated with the SHA1 or MD5 hash algorithm;
67 - 'n': the name of the event (i.e. the file name), with size up to 255 bytes;
68 - 'd-ng': the digest of the event, calculated with an arbitrary hash
69 algorithm (field format: <hash algo>:digest);
70 - 'd-ngv2': same as d-ng, but prefixed with the "ima" or "verity" digest type
71 (field format: <digest type>:<hash algo>:digest);
72 - 'd-modsig': the digest of the event without the appended modsig;
73 - 'n-ng': the name of the event, without size limitations;
74 - 'sig': the file signature, based on either the file's/fsverity's digest[1],
75 or the EVM portable signature, if 'security.ima' contains a file hash.
76 - 'modsig' the appended file signature;
77 - 'buf': the buffer data that was used to generate the hash without size limitations;
78 - 'evmsig': the EVM portable signature;
79 - 'iuid': the inode UID;
80 - 'igid': the inode GID;
81 - 'imode': the inode mode;
82 - 'xattrnames': a list of xattr names (separated by ``|``), only if the xattr is
83 present;
84 - 'xattrlengths': a list of xattr lengths (u32), only if the xattr is present;
85 - 'xattrvalues': a list of xattr values;
86
87
88 Below, there is the list of defined template descriptors:
89
90 - "ima": its format is ``d|n``;
91 - "ima-ng" (default): its format is ``d-ng|n-ng``;
92 - "ima-ngv2": its format is ``d-ngv2|n-ng``;
93 - "ima-sig": its format is ``d-ng|n-ng|sig``;
94 - "ima-sigv2": its format is ``d-ngv2|n-ng|sig``;
95 - "ima-buf": its format is ``d-ng|n-ng|buf``;
96 - "ima-modsig": its format is ``d-ng|n-ng|sig|d-modsig|modsig``;
97 - "evm-sig": its format is ``d-ng|n-ng|evmsig|xattrnames|xattrlengths|xattrvalues|iuid|igid|imode``;
98
99
100 Use
101 ===
102
103 To specify the template descriptor to be used to generate measurement entries,
104 currently the following methods are supported:
105
106 - select a template descriptor among those supported in the kernel
107 configuration (``ima-ng`` is the default choice);
108 - specify a template descriptor name from the kernel command line through
109 the ``ima_template=`` parameter;
110 - register a new template descriptor with custom format through the kernel
111 command line parameter ``ima_template_fmt=``.
112

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

고정 ima 템플릿의 한계와 분리 설계

1-28

기존 `ima` 템플릿은 파일 데이터 해시와 경로명을 담는 고정 길이 형식이다. 파일 데이터 해시는 MD5 또는 SHA-1에 맞춘 20바이트로 제한되고, null로 끝나는 경로명은 255자로 제한된다. inode UID/GID나 inode·접근 프로세스의 LSM 레이블 같은 추가 메타데이터를 기록하려면 새 템플릿을 정의할 수 있어야 한다.

새 형식을 추가할 때마다 측정 목록 생성·표시 함수에 형식별 코드를 넣으면 코드가 계속 커진다. 해결책은 템플릿 관리를 나머지 IMA 코드와 분리하는 것이다. 템플릿 descriptor는 측정 목록에 포함할 정보를 정하고, 템플릿 field는 특정 데이터 유형을 생성하고 표시한다.

IMA 템플릿 구조
구조역할
template descriptor측정 항목에 포함할 field와 순서 결정
template field한 데이터 유형의 생성과 표시

descriptor와 field가 형식 구성과 데이터 처리를 나눠 맡는다.

=================================
IMA Template Management Mechanism
=================================


Introduction
============

The original ``ima`` template is fixed length, containing the filedata hash
and pathname. The filedata hash is limited to 20 bytes (md5/sha1).
The pathname is a null terminated string, limited to 255 characters.
To overcome these limitations and to add additional file metadata, it is
necessary to extend the current version of IMA by defining additional
templates. For example, information that could be possibly reported are
the inode UID/GID or the LSM labels either of the inode and of the process
that is accessing it.

However, the main problem to introduce this feature is that, each time
a new template is defined, the functions that generate and display
the measurements list would include the code for handling a new format
and, thus, would significantly grow over the time.

The proposed solution solves this problem by separating the template
management from the remaining IMA code. The core of this solution is the
definition of two new data structures: a template descriptor, to determine
which information should be included in the measurement list; a template
field, to generate and display data of a given type.

필드 등록, descriptor 초기화와 표시

29-54

새 데이터 유형을 지원하려면 개발자는 field identifier를 정의하고 측정 항목을 생성하는 `init()`와 표시하는 `show()`를 구현한다. 새 descriptor 형식은 field identifier를 `|`로 구분한 문자열이며 `ima_template_fmt` 커널 명령줄 인자로 지정할 수 있다. 부팅할 때 IMA는 이 문자열을 지원되는 template field 구조체 배열로 변환해 선택한 descriptor를 초기화한다.

초기화 뒤 `ima_alloc_init_template()`는 커널 설정 또는 `ima_template`, `ima_template_fmt` 인자로 선택한 descriptor를 사용해 새 측정 항목을 만든다. 이 함수는 특정 템플릿의 형식별 코드를 갖지 않고 descriptor에 연결된 각 field의 `init()`을 호출해 할당 데이터 포인터와 길이를 측정 항목 구조체에 저장한다.

측정 항목 표시에도 같은 메커니즘을 쓴다. `ima_measurements_show()`와 `ima_ascii_measurements_show()`는 각 항목을 생성할 때 사용한 descriptor를 찾고, template field 배열의 각 원소에 대해 `show()`를 호출한다.

IMA 측정 항목 수명 주기
ima_template_fmt 형식 선택부팅 시 field identifier 해석ima_alloc_init_template()가 init() 호출데이터 포인터와 길이 저장ima[_ascii]_measurements_show()가 show() 호출

형식 문자열이 field 배열로 바뀌고 동일한 descriptor가 생성과 표시에 쓰인다.

Managing templates with these structures is very simple. To support
a new data type, developers define the field identifier and implement
two functions, init() and show(), respectively to generate and display
measurement entries. Defining a new template descriptor requires
specifying the template format (a string of field identifiers separated
by the ``|`` character) through the ``ima_template_fmt`` kernel command line
parameter. At boot time, IMA initializes the chosen template descriptor
by translating the format into an array of template fields structures taken
from the set of the supported ones.

After the initialization step, IMA will call ``ima_alloc_init_template()``
(new function defined within the patches for the new template management
mechanism) to generate a new measurement entry by using the template
descriptor chosen through the kernel configuration or through the newly
introduced ``ima_template`` and ``ima_template_fmt`` kernel command line parameters.
It is during this phase that the advantages of the new architecture are
clearly shown: the latter function will not contain specific code to handle
a given template but, instead, it simply calls the ``init()`` method of the template
fields associated to the chosen template descriptor and store the result
(pointer to allocated data and data length) in the measurement entry structure.

The same mechanism is employed to display measurements entries.
The functions ``ima[_ascii]_measurements_show()`` retrieve, for each entry,
the template descriptor used to produce that entry and call the show()
method for each item of the array of template fields structures.

지원되는 template field

55-87

템플릿 형식 문자열에는 다음 field identifier를 조합할 수 있다. `d`는 SHA-1 또는 MD5로 계산한 event digest, `n`은 최대 255바이트 event 이름이다. `d-ng`는 임의 해시 알고리즘을 `<hash algo>:digest`로 기록하고, `d-ngv2`는 앞에 `ima` 또는 `verity` digest type을 붙여 `<digest type>:<hash algo>:digest` 형식을 쓴다. `d-modsig`는 appended modsig를 제외한 event digest이고 `n-ng`는 길이 제한 없는 event 이름이다.

`sig`는 파일 또는 fs-verity digest 기반 파일 서명을 기록하며, `security.ima`가 파일 해시를 담은 경우에는 EVM portable signature를 기록한다. `modsig`는 파일 끝에 추가된 서명, `buf`는 길이 제한 없이 해시 생성에 사용한 버퍼, `evmsig`는 EVM portable signature다.

inode 메타데이터용으로 `iuid`, `igid`, `imode`가 있다. 확장 속성용 `xattrnames`는 존재하는 xattr 이름을 `|`로 구분해 기록하고, `xattrlengths`는 존재하는 xattr 길이를 u32 목록으로, `xattrvalues`는 값을 기록한다.

IMA template field
식별자내용
d / n기존 제한형 digest / 이름
d-ng / d-ngv2임의 해시 및 digest type 포함 digest
d-modsig / modsig추가 서명 제외 digest / 추가 서명
n-ng / buf길이 제한 없는 이름 / 해시 입력 버퍼
sig / evmsig파일·fs-verity 서명 / EVM portable signature
iuid / igid / imodeinode 소유자와 mode
xattrnames / xattrlengths / xattrvalues확장 속성 이름·길이·값

지원 field의 데이터 범위를 요약한다.



Supported Template Fields and Descriptors
=========================================

In the following, there is the list of supported template fields
``('<identifier>': description)``, that can be used to define new template
descriptors by adding their identifier to the format string
(support for more data types will be added later):

 - 'd': the digest of the event (i.e. the digest of a measured file),
   calculated with the SHA1 or MD5 hash algorithm;
 - 'n': the name of the event (i.e. the file name), with size up to 255 bytes;
 - 'd-ng': the digest of the event, calculated with an arbitrary hash
   algorithm (field format: <hash algo>:digest);
 - 'd-ngv2': same as d-ng, but prefixed with the "ima" or "verity" digest type
   (field format: <digest type>:<hash algo>:digest);
 - 'd-modsig': the digest of the event without the appended modsig;
 - 'n-ng': the name of the event, without size limitations;
 - 'sig': the file signature, based on either the file's/fsverity's digest[1],
   or the EVM portable signature, if 'security.ima' contains a file hash.
 - 'modsig' the appended file signature;
 - 'buf': the buffer data that was used to generate the hash without size limitations;
 - 'evmsig': the EVM portable signature;
 - 'iuid': the inode UID;
 - 'igid': the inode GID;
 - 'imode': the inode mode;
 - 'xattrnames': a list of xattr names (separated by ``|``), only if the xattr is
    present;
 - 'xattrlengths': a list of xattr lengths (u32), only if the xattr is present;
 - 'xattrvalues': a list of xattr values;

정의된 template descriptor

88-99

정의된 descriptor는 field 조합으로 표현된다. 기존 `ima`는 `d|n`, 기본값 `ima-ng`는 `d-ng|n-ng`, `ima-ngv2`는 `d-ngv2|n-ng`다. 서명형 `ima-sig`와 `ima-sigv2`는 각 digest 형식 뒤에 `n-ng|sig`를 붙인다. `ima-buf`는 `d-ng|n-ng|buf`, `ima-modsig`는 `d-ng|n-ng|sig|d-modsig|modsig`다.

`evm-sig`는 `d-ng|n-ng|evmsig|xattrnames|xattrlengths|xattrvalues|iuid|igid|imode` 형식으로 EVM 서명, 확장 속성, inode 메타데이터를 함께 기록한다.

기본 IMA descriptor
이름형식
imad|n
ima-ngd-ng|n-ng
ima-ngv2d-ngv2|n-ng
ima-sigd-ng|n-ng|sig
ima-sigv2d-ngv2|n-ng|sig
ima-bufd-ng|n-ng|buf
ima-modsigd-ng|n-ng|sig|d-modsig|modsig
evm-sigd-ng|n-ng|evmsig|xattrnames|xattrlengths|xattrvalues|iuid|igid|imode

descriptor 이름과 정확한 field 형식을 보존한다.

Below, there is the list of defined template descriptors:

 - "ima": its format is ``d|n``;
 - "ima-ng" (default): its format is ``d-ng|n-ng``;
 - "ima-ngv2": its format is ``d-ngv2|n-ng``;
 - "ima-sig": its format is ``d-ng|n-ng|sig``;
 - "ima-sigv2": its format is ``d-ngv2|n-ng|sig``;
 - "ima-buf": its format is ``d-ng|n-ng|buf``;
 - "ima-modsig": its format is ``d-ng|n-ng|sig|d-modsig|modsig``;
 - "evm-sig": its format is ``d-ng|n-ng|evmsig|xattrnames|xattrlengths|xattrvalues|iuid|igid|imode``;

템플릿 선택과 사용자 정의

100-111

측정 항목 생성에 쓸 descriptor는 세 방법으로 지정한다. 커널 설정에서 지원 descriptor 하나를 선택하며 기본값은 `ima-ng`다. 커널 명령줄의 `ima_template=`로 descriptor 이름을 지정하거나, `ima_template_fmt=`에 사용자 정의 field 형식을 넣어 새 descriptor를 등록할 수도 있다.

IMA descriptor 선택
커널 설정의 지원 descriptor 선택또는 ima_template=이름또는 ima_template_fmt=사용자 형식선택한 descriptor로 측정 항목 생성

설정 또는 명령줄에서 하나의 측정 형식을 결정한다.

Use
===

To specify the template descriptor to be used to generate measurement entries,
currently the following methods are supported:

 - select a template descriptor among those supported in the kernel
   configuration (``ima-ng`` is the default choice);
 - specify a template descriptor name from the kernel command line through
   the ``ima_template=`` parameter;
 - register a new template descriptor with custom format through the kernel
   command line parameter ``ima_template_fmt=``.