Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Latest commit

 

History

History
83 lines (62 loc) · 8.97 KB

guest_kernel_changes.md

File metadata and controls

83 lines (62 loc) · 8.97 KB

Patch Target Kernel for Fuzzing

Patching and code modification can be required when fuzzing a non-default guest kernel. This guide describes the related and recommended commits to make the target fuzzable.

The Default Guest Kernel

You can check the ansible playbook script for the source and the branch of the guest kernel used by default, e.g.,

guest_url: https://github.com/IntelLabs/kafl.linux
guest_revision: kafl/fuzz-6.0-2

All the patches we describe with commit IDs can be found in the above branch. A target guest kernel wants to apply multiple sets of patches from the below:

  1. The CCC suite patches, implementing fuzzing hooks for KAFL, etc.
  2. The TDX guest patches enable fuzzing functionalities
  3. TDX functionality patches are recommended for fuzzing features
  4. General TDX functionality patches

To ensure the correct order of backporting, apply patch sets 4 and 3 first, followed by patch set 2, and finally, apply patch set 1.

While patch set 3 is not strictly needed, it's highly recommended for the fuzzing campaign to become effeceint. Multiple patches from patch set 4 can also be required depending on different needs for fuzzing.

Patch Set 1:

The commits in this set are needed as they construct the kAFL fuzzing facility (kafl-agent.c) on top of the below TDX fuzzing API. These commits also insert kAFL events to the kernel source for pre-defined fuzzing harnesses, implement debugging interfaces, etc.

The commits below start from the most recent:

Patch Set 2:

The following commits in this set are required as they enable the basic fuzzing functionalities for TDX, such as the input injection interface. The commits below start from the most recent:

The commits below start from the most recent:

Patch Set 3:

The commits in this set are strongly recommended because these patches implement device filter support and add audited drivers into the allow list. TDX guests only require a small number of drivers. Confining fuzzing coverage only on the targeted threat surface increases the fuzzing effectiveness.

Without device filtering, all devices will be enabled in the guest per kernel config, and all probe functions of devices will be running and consuming fuzzing input.

Several commits below start from the most recent:

For the full list of device filter commits and the latest updates, you may refer to the remote-tracking branch guest-filter and the branch guest-hardening-filter for additional changes related to TDX guest hardening.

Patch Set 4:

General tdx patches for different guest functionalities are maintained and tested in the branch guest-next from the Intel public TDX repository. This branch is actively developed for updates and fixes and merged from multiple remote-tracking branches that separately works on TDX guest for different subjects. For instance, some needed changes come from the remote-tracking branch guest-debug in the tracepoint for tracing TDX guest virtual exceptions.

You may cherry-pick patches and perform backporting when different functionalities are required or targeted. Note that these remote tracking branches are constantly updated, and most of the content of this branch is planned to be upstreamed.

A Few Steps After Backporting

  1. Link the new guest kernel to the CCC repository environmental variable $LINUX_GUEST, e.g., export LINUX_GUEST=/new/guest-kernel. You may also modify the environment setup script env.sh under the CCC root for a permanent change.
  2. Follow this step to reproduce the Smatch cross-function database and audit lists. This can also be done by re-run the step that prepares all global baseline assets.