Skip to content

add new ima hook ima_kexec_cmdline to measure kexec boot cmdline args

Prakhar Srivastava linux-integrity linux-security-module lkml 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest3 patches 2 repliesIn review
  2. v63 patches 8 repliesSuperseded
  3. v5 posting 2/23 patches 9 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v5 posting 1/23 patches0 repliesSuperseded
v45 patches4 repliesSuperseded
v34 patches5 repliesSuperseded

Changes in v7 from the cover letter

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Add a new ima hook ima_kexec_cmdline to measure cmdline argsDocumentation/ABI/testing/ima_policy include/linux/ima.h security/integrity/ima/ima.h +3 more+91 -00 replies
2/3add a new ima template field bufDocumentation/security/IMA-templates.rst security/integrity/ima/ima.h security/integrity/ima/ima_api.c +5 more+35 -50 replies
3/3call ima_kexec_cmdline to measure the cmdline argskernel/kexec_file.c+5 -30 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchRoberto Sassu
1/3
2/3R-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 0/3] add new ima hook ima_kexec_cmdline to measure kexec boot cmdline args

The motive behind the patch series is to measure the boot cmdline args used for soft reboot/kexec case.

For secure boot attestation, it is necessary to measure the kernel command line and the kernel version. For cold boot, the boot loader can be enhanced to measure these parameters.
(https://mjg59.dreamwidth.org/48897.html)
However, for attestation across soft reboot boundary, these values also need to be measured during kexec_file_load.

Currently for Kexec(kexec_file_load)/soft reboot scenario the boot cmdline args for the next kernel are not measured. For
normal case of boot/hardreboot the cmdline args are measured into the TPM. The hash of boot command line is calculated and added to the current running kernel's measurement list.
On a soft reboot like kexec, no cmdline arguments measurement takes place.

To achive the above the patch series does the following
-adds a new ima hook: ima_kexec_cmdline which measures the cmdline args
into the ima log, behind a new ima policy entry KEXEC_CMDLINE.
-since the cmldine args cannot be appraised, a new template field(buf) is
added. The template field contains the buffer passed(cmldine args), which can be used to appraise/attest at a later stage.
-call the ima_kexec_cmdline(...) hook from kexec_file_load call.

The ima logs need to be carried over to the next kernel, which will be followed up by other patchsets for x86_64 and arm64.

The kexec cmdline hash can be verified using
sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements |
grep kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum

Changelog:
V7:
- rebased to next-queued-testing
https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git/log/?h=next-queued-testing

V6:
-add a new ima hook and policy to measure the cmdline
args(ima_kexec_cmdline)
-add a new template field buf to contain the buffer measured. [suggested by Mimi Zohar]
add new fields to ima_event_data to store/read buffer data.
[suggested by Roberto]
-call ima_kexec_cmdline from kexec_file_load path

v5:
-add a new ima hook and policy to measure the cmdline
args(ima_kexec_cmdline)
-add a new template field buf to contain the buffer measured.
[suggested by Mimi Zohar]
-call ima_kexec_cmdline from kexec_file_load path

v4:
- per feedback from LSM community, removed the LSM hook and renamed the IMA policy to KEXEC_CMDLINE

v3: (rebase changes to next-general)
- Add policy checks for buffer[suggested by Mimi Zohar]
- use the IMA_XATTR to add buffer
- Add kexec_cmdline used for kexec file load
- Add an LSM hook to allow usage by other LSM.[suggestd by Mimi Zohar]

v2:
- Add policy checks for buffer[suggested by Mimi Zohar]
- Add an LSM hook to allow usage by other LSM.[suggestd by Mimi Zohar]
- use the IMA_XATTR to add buffer instead of sig template

v1:
-Add kconfigs to control the ima_buffer_check -measure the cmdline args suffixed with the kernel file name -add the buffer to the template sig field.

Prakhar Srivastava (3):
Add a new ima hook ima_kexec_cmdline to measure cmdline args add a new ima template field buf
call ima_kexec_cmdline to measure the cmdline args

 Documentation/ABI/testing/ima_policy      |  1 +
 Documentation/security/IMA-templates.rst  |  2 +-
 include/linux/ima.h                       |  2 +
 kernel/kexec_file.c                       |  8 ++-
 security/integrity/ima/ima.h              |  3 +
 security/integrity/ima/ima_api.c          |  5 +-
 security/integrity/ima/ima_init.c         |  2 +-
 security/integrity/ima/ima_main.c         | 80 +++++++++++++++++++++++
 security/integrity/ima/ima_policy.c       |  9 +++
 security/integrity/ima/ima_template.c     |  2 +
 security/integrity/ima/ima_template_lib.c | 20 ++++++
 security/integrity/ima/ima_template_lib.h |  4 ++
 12 files changed, 131 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1