Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@humaidq-tii
Copy link
Member

@humaidq-tii humaidq-tii commented Mar 18, 2025

Description of changes

This pull request builds upon #1005.

This pull request adds a new partitioning scheme in a new lenovo-x1-gen11-hardening target, where it would use the new image-based disk partitioning scheme. All other targets aren't yet updated, as this partitioning scheme is still experimental and to eventually be used for the release targets. For testing we enable it for the extras debug target too, as the release variant might not be functional. The goal of this target is also to be a testing ground for newer hardening techniques.

The new partitioning scheme is similar to what is introduced in #1005, but it uses EROFS for the verity tree and root partitions. This is a read-only file system that will make the nix-store completely immutable, allowing us to verify that the system image hasn't been tampered with. EROFS is a modern and fast read-only filesystem, which would also help avoid unintentional tampering of the system.

Some refactoring has been done to allow multiple partitioning schemes without them affecting each other.

  • Enables dm-verity.
    • Set default to kernel panic on any corrupted block.
  • Added new image-based partitioning scheme.
    • Image generated by systemd-repart with dm-verity roothash included.
    • Uses EROFS for the verity tree and root (nix-store) partition.
  • Added preliminary boilerplate for systemd-sysupdate (OTA system updates).
    • The code will require more work in order for it to work especially with the boot loader.
  • Importing disko module now assumes that it must be enabled.
    • You cannot import disko partitioning scheme without using it, same with the new image-based partitioning scheme.
    • This is as certain options that are imported/inherited from disko (upstream) conflicts with repart NixOS module.
  • Made some code generic (such as the laptop-configuration-builder.nix and the ghaf installer script).
  • No disk encryption yet, also images aren't signed with secure boot keys.
  • Enable QR code for kernel panics for all x86_64, this allows us to to see when dm-verity fails.
  • Remove disk hardware definition as it isn't used for both dm-verity (repart) and debug (disko) builds.

Checklist for things done

  • Summary of the proposed changes in the PR description
  • More detailed description in the commit message(s)
  • Commits are squashed into relevant entities - avoid a lot of minimal dev time commits in the PR
  • Contribution guidelines followed
  • Ghaf documentation updated with the commit - https://tiiuae.github.io/ghaf/
  • PR linked to architecture documentation and requirement(s) (ticket id)
  • Test procedure described (or includes tests). Select one or more:
    • Tested on Lenovo X1 x86_64
    • Tested on Jetson Orin NX or AGX aarch64
    • Tested on Polarfire riscv64
  • Author has run make-checks and it passes
  • All automatic Github Action checks pass - see actions
  • Author has added reviewers and removed PR draft status
  • Change requires full re-installation
  • Change can be updated with nixos-rebuild ... switch: NO

Instructions for Testing

  • List all targets that this applies to:
    • AGX
    • NX
    • x86_64: lenovo-x1-gen11-hardening only
  • Is this a new feature: Yes, as it adds integrity checking which is also a security feature
    • List the test steps to verify:
      • Build .#lenovo-x1-gen11-hardening-debug-installer (do not test release).
      • Installer works properly.
      • Run sudo veritysetup status root on ghaf-host, should show status verified.
      • Open file manager, the Shares folder should be around 940GB or larger, indicating that the data partition expanded to fill disk after boot.
      • Build a normal debug build (not the extras). Should work as normal (specifically the installer script and boot).
  • If it is an improvement how does it impact existing functionality?
    • Yes, nixos-rebuild will no longer work on the extras targets.

@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow March 18, 2025 09:01 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow March 20, 2025 06:04 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii mentioned this pull request Mar 20, 2025
22 tasks
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 14, 2025 08:28 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 14, 2025 08:28 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 06:35 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 06:35 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 06:44 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 06:44 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 07:21 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 07:21 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 07:24 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 17, 2025 07:24 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 18, 2025 13:07 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 18, 2025 13:07 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii requested review from brianmcgillion and mbssrc and removed request for mbssrc April 18, 2025 13:08
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 21, 2025 08:39 — with GitHub Actions Inactive
@humaidq-tii humaidq-tii temporarily deployed to internal-build-workflow April 21, 2025 08:39 — with GitHub Actions Inactive
@brianmcgillion brianmcgillion added Needs Testing CI Team to pre-verify and removed bug on Lenovo X1 Carbon Issues found on Lenovo X1 Carbon while checking this PR labels May 13, 2025
@msaarine
Copy link

Testing

  1. (.#lenovo-x1-gen11-hardening-debug-installer)
    Built, installed & tested those things mentioned in PR (sudo veritysetup status root, & shares folder size) & run automated bat tests(35) for the image
  • Building & Installation worked fine.
  • The system seemed to work as expected, the given command was supported and status was 'verified'.
  • File manager, the Shares folder showd to be around 940GB
  • Automated bat tests passed.
  1. (.#lenovo-x1-carbon-gen11-debug-installer)
    Built, Installed & tested a normal build and & run automated bat tests(35) for the image
  • Building worked fine ( .#lenovo-x1-carbon-gen11-debug-installer)
  • Installation (Please Check Note below!)
  • The system seemed to work as expected, Automated bat tests passed.

Note:
The only thing that I want to mention here is the installation after the 'hardening' image was used.

When I tried to install 'a normal build 'lenovo-x1-carbon-gen11-debug-installer' I faced some problems I have not seen before.
When installation was done, there is a step where it is advised like :">>Please remove installation media and re-boot"

Usually in my installations, I have always removed the SSD device and then executed 'sudo reboot' in that installation step.
Now when I unplugged the SSD, I got error like:
I/O error, dev loop0, sector 3117570 op 0x0:(READ) flags 0x800 phys_seg 84 prio class 0
... (picture attached)

and 'sudo reboot' after that 'did nothing'

That was surpise for me. I was told that this is ok and happens sometimes. I have been working with these issues only a short period of time so maybe I just haven't faced this before this.
To avoid that situation, I used a bit different process (instead of just removing the SDD):

  • sudo shutdown now
  • Removed the media after shutdown
  • Powered the PC
    -->I ended up to normal situation to set username/passwd etc and the SW worked just fine

So if that functionality is known issue, I did not capture regression/non-working implementation during my testing.
PR1074-old-iso-installer-after-

@msaarine msaarine added Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon and removed Needs Testing CI Team to pre-verify labels May 16, 2025
Disko is able to generate the correct images without having the device
path. And this is also not used in the repart image with dm-verity.

Signed-off-by: Humaid Alqasimi <[email protected]>
@brianmcgillion brianmcgillion merged commit 3f25f73 into tiiuae:main May 16, 2025
25 of 26 checks passed
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Jun 11, 2025
The vm test for the installer was broken by
tiiuae#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Jun 11, 2025
The vm test for the installer was broken by
tiiuae#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Jun 15, 2025
The vm test for the installer was broken by
tiiuae#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Jun 15, 2025
The vm test for the installer was broken by
tiiuae#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
brianmcgillion added a commit to brianmcgillion/ghaf that referenced this pull request Jun 15, 2025
The vm test for the installer was broken by
tiiuae#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
brianmcgillion added a commit that referenced this pull request Jun 16, 2025
The vm test for the installer was broken by
#1074 and was not seen then. This
change just fixes the path to the image that is to be flashed.

Signed-off-by: Brian McGillion <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Tested on Lenovo X1 Carbon This PR has been tested on Lenovo X1 Carbon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants