AKSのConfidential Computingノード
Azure Kubernetes Service (AKS)上でのConfidential computingノードが先月GAとなった。
Confidential computing nodes (DCSv2) on Azure Kubernetes Service (AKS) is generally available
これにより、AKSのワーカーノードでSGX環境のVMが起動できるようになり、SGX Enclaveに対応したコンテナを扱えるようになる。
https://gyazo.com/dc4cc4deb454e786a08e8fa4db33ffc3
(ref: https://docs.microsoft.com/ja-jp/azure/confidential-computing/confidential-nodes-aks-overview )
つまり、ワーカーノードのVMとしてDCsv2シリーズを選択し、それらのノード上のコンテナでSGXドライバやAESMを認識できるようになる。
前提:SGXドライバ
Intel SGX Driverをインストールすると、アプリケーションプログラム側で /dev/sgx/enclaveや/dev/sgx/provisionなどのデバイスファイルにアクセス可能になる。(AzureのDCsv2 VMではドライバインストールは初期化時にセットアップ済み)
/dev/sgx/enclave
mmap(), ioctl()のシステムコールでEPCに割り当てられる仮想アドレス空間(ELRANGE)の確保など
Linuxカーネルへのパッチ
https://patchwork.kernel.org/project/intel-sgx/patch/20190417103938.7762-16-jarkko.sakkinen@linux.intel.com/
https://lwn.net/Articles/798748/
In the SGX driver implementation, all enclaves are backed by the same device file (/dev/sgx/enclave). This allows SGX users to use ordinary system calls (including mmap() and ioctl()) to move pages to and from the SGX-specific hardware module called the "enclave page cache" (EPC). The pages in the EPC differ from typical pages because of the hardware restrictions: they are shared by processes at the hardware level and there is one-to-one mapping between virtual and physical addresses within an enclave. The enclaves also need specific SGX read, write, and execute permissions to the EPC pages.
/dev/sgx/provision
provisioning privilegesのトークンをEnclaveが取得するために利用
Linuxカーネルへのパッチ
https://patchwork.kernel.org/project/intel-sgx/patch/20191129231326.18076-16-jarkko.sakkinen@linux.intel.com/
osuke.icon 権限レベルが/dev/sgx/enclaveより強いものが必要
前提:Application Enclave Service Manager (AESM)
Architectual EnclavesとApplication Enclavesがコミュニケーションするための仲介デーモン(Intel SGX PSWに含まれるtrusted software components)
https://github.com/intel/linux-sgx/tree/master/psw
例:Application EnclaveからRemote Attestation時に必要なデータ構造体QUOTEの生成やプラットフォーム特有の鍵によるその署名
https://gyazo.com/03532a6d604023e54ff0af65c6b7416c
(ref: Remote Attestation)
aesmdがデバイスファイルにアクセスし、それぞれのEnclaveコンテナへaesmdはドメインソケットフォワーディングすることで、それぞれのコンテナ内EnclaveでRemote Attestationができるようになる。
https://gyazo.com/9a104c334a1185f5d191752fffc468e0
(ref: https://github.com/apache/incubator-teaclave-sgx-sdk/wiki/Environment-Setup#use-docker-with-hardware-support-and-run-aesm-outside-docker-on-the-host-os )
前提:kubernetes device plugin
k8s上のコンテナ内から以下のようなデバイスファイルが見えるようにする。
kube describe daemonset ~出力結果の一部
code:a
Volumes:
kubeletsockets:
Type: HostPath (bare host directory volume)
Path: /var/lib/kubelet/device-plugins
HostPathType:
sgxdevices:
Type: HostPath (bare host directory volume)
Path: /dev/sgx
HostPathType: DirectoryOrCreate
sgx-enclave:
Type: HostPath (bare host directory volume)
Path: /dev/sgx/enclave
HostPathType: CharDevice
sgx-provision:
Type: HostPath (bare host directory volume)
Path: /dev/sgx/provision
HostPathType: CharDevice
sgxのdevice pluginはintelが提供
https://github.com/intel/intel-device-plugins-for-kubernetes
(aks)
cipepser.icon Goだ
3つの機能を提供
device plugin
kubeletにSGX deviceが扱えることを通知
admission webhook
RAに使うdeviceリソースとボリュームマウントを設定
sgx epc memory registration
node-feature-discovery (NFD) を使ってそれぞれのノードで利用可能なEPCメモリを設定
参考資料
Device Plugin開発入門
kubernetes Device Plugins
AKSのConfidential Computingノード
AKSクラスタに対して、Confidential Computingのアドオンを追加による、sgx device pluginの有効化
daemonsetにコントロールされたpodが各ノードにデプロイ
SGX quote helper deamonset
https://gyazo.com/ebe8c69e4927c4bb53fb742aaceb1aa4
ref: https://docs.microsoft.com/en-us/azure/confidential-computing/confidential-nodes-out-of-proc-attestation
アウトプロセス(コンテナ外
code:a
$ kubectl get pods -n kube-system
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-748cdb7bf4-297gr 1/1 Running 0 3h40m
kube-system coredns-748cdb7bf4-5dq4b 1/1 Running 0 3h38m
kube-system coredns-autoscaler-868b684fd4-wsppf 1/1 Running 0 3h40m
kube-system kube-proxy-6qwxq 1/1 Running 0 3h32m
kube-system kube-proxy-hpj2n 1/1 Running 0 3h38m
kube-system metrics-server-58fdc875d5-vnqbd 1/1 Running 0 3h40m
kube-system sgx-plugin-2q466 1/1 Running 0 3h32m
kube-system sgx-webhook-5cd4ddfc66-mkqz2 1/1 Running 0 3h40m
kube-system tunnelfront-8ccbb85fb-jbdkw 1/1 Running 0 3h40m