IBM Z and LinuxONE - IBM Z

IBM Z

The enterprise platform for mission-critical applications brings next-level data privacy, security, and resiliency to your hybrid multicloud.

 View Only

Root Volume LUKS Encryption Using IBM Crypto Express Card(CEX) in Openshift Container Platform.

By Madhu Pillai posted 6 hours ago

  

                           LUKS encryption using CEX in an IBM Z or IBM LinuxONE environment 

                                                                                                           Preface 

Enabling hardware-based Linux Unified Key Setup (LUKS) encryption via IBM Crypto Express (CEX) in an IBM Z or IBM LinuxONE environment for Red Hat OpenShift cluster setups. 

LUKS is a standardized way to encrypt block devices on Linux systems. The CEX based LUKS encryption is similar to the existing LUKS encryption offered by x86 architecture using a TPM device or Network Bound Disk Encryption (NBDE) using Clevis utility in Ignition. The difference is CEX enabled LUKS encryption does not require Clevis utility. The Clevis utility only manages the passphrase that is used to encrypt/decrypt a LUKS device either through TPM device or NBDE.  

CEX based LUKS encryption uses a Protected key. Protected Key is a data-encrypting key that itself is encrypted by a CPACF (Central Processor Assist for Cryptographic Function) wrapping key. The CPACF is a set of z/Architecture instructions provided by the Message Security Assist (MSA) facility and its extensions. It mainly provides symmetric ciphers and hash functions but also selected asymmetric functions (ECC) using clear keys and protected keys. The resulting encrypted key cannot be shared with another LPAR because the wrapping key is unique. In the case of Linux in a native LPAR, the wrapping key is specific to the LPAR. However, for guests of z/VM or KVM, the wrapping key is specific to the guest.  

The IBM Z platform offers cryptographic engines that provide high-speed cryptographic operations. CEX (Crypto Express Adapter) are required to generate the secure keys that are stored in the key repository. They are also required to generate protected keys from secure keys for Linux on Z data at-rest encryption. 

Crypto Express adapters are tamper-responding hardware security modules (HSM), which provide high security, high throughput cryptographic functions. The Crypto Express adapter adds a layer of protection for the storage.  

Refer the following diagram. 

Picture  

This article explains how to configure LUKS-encrypted root volume for Red Hat OpenShift clusters deployed on z/VM and KVM, with support for both FCP and DASD devices. 

Note: 

  1. All installed Crypto Express adapter must be loaded with master key before the installation. 

  1. For Linux on Z data at-rest encryption, the Crypto Express adapter must be configured as Common Cryptographic Architecture (CCA) coprocessor. 

Prerequisites: 

CCA Adapter must be >= CEX6C 

The latest Butane utility must be installed on the Linux instance that has administrative access to the OCP cluster. 

The OpenShift version must be >= 4.19 

Make sure that all the cluster nodes have at least one CEX card configured. For redundancy multiple cex cards can be configured.  

z/VM-based Installation   

In the z/VM based installation assign the crypto adapter to appropriate VM before the installation. The following screenshot explains the cards assigned to VMs. 

The assignments can be queried with the command: Refer IBM zVM-command 

#cp q crypto ap 

Picture 

KVM-based Installation. 

For configuring the crypto card in KVM on IBM Z or IBM LinuxONE, the following way we can create the vfio_ap pass through device. 

  1. The video illustrates the process of attaching a vfio_ap passthrough device and configuring it to remain persistent across reboots of the KVM host. 

 

The following video illustrates the steps you must perform on the KVM host and in a virtual server  

 

Follow the IBM documentation VFIO_AP 

 

The example script configures the mediated device for the CEX adapter which does not create a persistent mediated device and assumes the adapter is 0x00. 

Update the domain appropriate from the output of lszcrypt –V. If you need additional adapters, add the uuid:domain in the data field, as comma-separated values. Eg data="68cd2d83-3eef-4e45-b22c-534f90b16cb9:0x0035" 

 

#!/bin/bash 

echo "Setting vfio_ap and reseting the adapter"  

modprobe vfio_ap 

echo 0x0 > /sys/bus/ap/apmask  

echo 0x0 > /sys/bus/ap/aqmask 

echo "Started configure the adapter" 

 

#UUID can be generated from uuidgen command domain can be obtained from lszcrypt -V command. 

#Generate the UUID corresponding to the available CEX domain. 

data="68cd2d83-3eef-4e45-b22c-534f90b16cb9:0x0035,ba3f873c-3022-4534-9072-eb0d4530b137:0x0036,610e4724-c8c1-45ed-a498-ccfdadc1f2ca:0x0037,5c84eefb-cb45-4519-86d3-ba23e65e8896:0x0038,60cf6ec4-2741-44e2-84d2-0746f133db16:0x0039"  

 

IFS=',' read -ra pairs <<< "$data" 

 

for pair in "${pairs[@]}"  

do  

IFS=':' read -r uuid domain <<< "$pair"  

echo "$uuid , $domain" 

echo ${uuid} > /sys/devices/vfio_ap/matrix/mdev_supported_types/vfio_ap-passthrough/create  

echo 0x00 > /sys/devices/vfio_ap/matrix/"${uuid}"/assign_adapter  

echo "${domain}" > /sys/devices/vfio_ap/matrix/"${uuid}"/assign_domain  

 

cat /sys/devices/vfio_ap/matrix/"${uuid}"/matrix  

done 

 

 

 

 

 

 

Day - 1  

To enable LUKS in OpenShift, an additional manifest must be created and included as part of the installation process. 

In OpenShift Container Platform, RHCOS images are initially configured using a feature called Ignition, which runs only during the system’s first boot. After this initial boot, RHCOS nodes are managed by the Machine Config Operator (MCO) within the OpenShift cluster. 

Ignition is the utility responsible for manipulating disks during initial setup. It performs common disk-related tasks such as partitioning, formatting, writing files, and configuring users. On first boot, Ignition reads its configuration from the installation media or another specified location and applies it to the machine. 

The following procedure describes how to create a Machine Config for preparing LUKS encryption using the Butane utility. 

The Machine Config files generated by Butane must be placed in the OCP installation directory. 

 

DASD device butane config. 

Following the butane sugar for dasd device 99-master-machineconfig.bu 

 

variant: openshift 

version: 4.19.0 

metadata: 

  name: master-luks-storage (1) 

  labels: 

    machineconfiguration.openshift.io/role: master  

openshift: 

  fips: true (2) 

  kernel_arguments: 

    - rd.luks.key=/etc/luks/cex.key (3) 

boot_device: 

  layout: s390x-eckd (4) 

  luks: 

    device: /dev/dasda (5) 

    cex: 

      enabled: true (6) 

  1. Update the name for master as well as worker 

  1. This enables FIPS from ignition. 

  1. Mandatory kargs for CEX based luks encryption. Omitting the kargs prevents system boot. 

  1. Layout specifies the architecture, e.g., x86_64, arch64, ppc64 etc.  
                     In s390x we have three device specific sugar a) s390x-eckd (For DASD) s390x-zfcp (For FCP) and s390x-virt (For zKVM) 

  1. Specify the device name as dasda or dasdb, .... 

  1. This enables the CEX based Luks encryption. 

Convert the above butane config to an ignition- compatible file. 

[root@linux ~]# butane --strict 99-master-machineconfig.bu -o 99-master-luks-machineconfig.yaml  

The following shows the converted butane config to ignition. 

  

[root@linux ~]# cat 99-master-luks-machineconfig.yaml 

# Generated by Butane; do not edit 

apiVersion: machineconfiguration.openshift.io/v1 

kind: MachineConfig 

metadata: 

  labels: 

    machineconfiguration.openshift.io/role: master 

  name: master-luks-storage 

spec: 

  config: 

    ignition: 

      version: 3.5.0 

    storage: 

      filesystems: 

        - device: /dev/mapper/root 

          format: xfs 

          label: root 

          wipeFilesystem: true 

      luks: 

        - cex: 

            enabled: true 

          device: /dev/dasda2 

          label: luks-root 

          name: root 

          options: 

            - --cipher 

            - aes-cbc-essiv:sha256 

          wipeVolume: true 

  fips: true 

  kernelArguments: 

    - rd.luks.key=/etc/luks/cex.key 

 

Copy this Ignition files to the installation directory before creating the ignition config. 

[root@linux ~]# cp 99-master-luks-machineconfig.yaml /root/ocp4_workdir/openshift 

 

FCP device butane config. 

Note: There is an issue with butane sugar for `s390x-zfcp` fails on multipath enabled system. An issue is being raised to follow up. Until the issue is fixed we use the manual method to convert to ignition config described in "FCP device butane config". 

 

[root@linux ~] # cat 99-master-luks-machineconfig.bu 

variant: openshift   

version: 4.19.0   

metadata:   

  name: master-luks-storage   

  labels:   

    machineconfiguration.openshift.io/role: master  

openshift: 

  fips: true 

  kernel_arguments:   

    - rd.luks.key=/etc/luks/cex.key   

storage: 

  filesystems: 

    - device: /dev/mapper/root 

      format: xfs 

      label: root 

      wipe_filesystem: true 

  luks: 

    - cex 

        enabled: true 

      device: /dev/disk/by-label/root 

      label: luks-root 

      name: root 

      wipe_volume: true 

 

[root@linux ]# butane --strict 99-master-luks-machineconfig.bu -o 99-master-luks-machineconfig.yaml 

[root@linux ]# cat 99-master-luks-machineconfig.yaml  

# Generated by Butane; do not edit 

apiVersion: machineconfiguration.openshift.io/v1 

kind: MachineConfig 

metadata: 

  labels: 

    machineconfiguration.openshift.io/role: master 

  name: 99-master-s390x-cex-luks-config 

spec: 

  config: 

    ignition: 

      version: 3.5.0 

    storage: 

      filesystems: 

        - device: /dev/mapper/root 

          format: xfs 

          label: root 

          wipeFilesystem: true 

      luks: 

        - cex: 

            enabled: true 

          device: /dev/disk/by-label/root 

          label: luks-root 

          name: root 

          options: 

            - --cipher 

            - aes-cbc-essiv:sha256 

          wipeVolume: true 

  fips: true 

  kernelArguments: 

    - rd.luks.key=/etc/luks/cex.key 

 

Virtual device butane config. 

[root@linux ~]# cat 99-master-luks-machineconfig.bu 

variant: openshift 

version: 4.19.0 

metadata: 

  name: master-luks-storage 

  labels: 

    machineconfiguration.openshift.io/role: master  

openshift: 

  fips: true 

  kernel_arguments: 

    - rd.luks.key=/etc/luks/cex.key 

boot_device: 

  layout: s390x-virt 

  luks: 

    cex: 

      enabled: true 

 

[root@linux ~]# butane --strict 99-master-luks-machineconfig.bu -o 99-master-luks-machineconfig.yaml 

[root@linux ~]# cat 99-master-luks-machineconfig.yaml 

# Generated by Butane; do not edit 

apiVersion: machineconfiguration.openshift.io/v1 

kind: MachineConfig 

metadata: 

  labels: 

    machineconfiguration.openshift.io/role: master 

  name: master-luks-storage 

spec: 

  config: 

    ignition: 

      version: 3.5.0 

    storage: 

      filesystems: 

        - device: /dev/mapper/root 

          format: xfs 

          label: root 

          wipeFilesystem: true 

      luks: 

        - cex: 

            enabled: true 

          device: /dev/disk/by-partlabel/root 

          label: luks-root 

          name: root 

          options: 

            - --cipher 

            - aes-cbc-essiv:sha256 

          wipeVolume: true 

  fips: true 

  kernelArguments: 

    - rd.luks.key=/etc/luks/cex.key 

 

Verification  

The screenshot below shows the successful installation of OCP with a LUKS-encrypted root volume using the Crypto Express Card. Notably, the cipher used for this LUKS encryption is paes-xts-plain64, and the Tokens section confirms that the PAES verification pattern was completed. 

Verify after the installation in DASD/FCP/Virt 

Login to any nodes  

[root@linux ~] # oc debug nodes/<node_name> 

[root@linux ~] # chroot /host 

[root@linux ~] # lsblk –f        # list the devices which shows the LUKS device. 

[root@linux ~] # cryptsetup luksDump /dev/dasda2  # It shows the header information of LUKS device. 

PicturePicture 

 

Verify after the installation in FCP. 

 

Picture 

Picture 

 

This article explained how to leverage the IBM Crypto Express Card for root volume LUKS encryption in OCP. The layer of security it provides. The usage of CEX card on different storage device. 

For more information on CEX and OCP.  

https://www.ibm.com/docs/en/linux-on-systems?topic=setup-crypto 

0 comments
0 views

Permalink