1*cbabf03cSDov MurikWhat: security/secrets/coco 2*cbabf03cSDov MurikDate: February 2022 3*cbabf03cSDov MurikContact: Dov Murik <dovmurik@linux.ibm.com> 4*cbabf03cSDov MurikDescription: 5*cbabf03cSDov Murik Exposes confidential computing (coco) EFI secrets to 6*cbabf03cSDov Murik userspace via securityfs. 7*cbabf03cSDov Murik 8*cbabf03cSDov Murik EFI can declare memory area used by confidential computing 9*cbabf03cSDov Murik platforms (such as AMD SEV and SEV-ES) for secret injection by 10*cbabf03cSDov Murik the Guest Owner during VM's launch. The secrets are encrypted 11*cbabf03cSDov Murik by the Guest Owner and decrypted inside the trusted enclave, 12*cbabf03cSDov Murik and therefore are not readable by the untrusted host. 13*cbabf03cSDov Murik 14*cbabf03cSDov Murik The efi_secret module exposes the secrets to userspace. Each 15*cbabf03cSDov Murik secret appears as a file under <securityfs>/secrets/coco, 16*cbabf03cSDov Murik where the filename is the GUID of the entry in the secrets 17*cbabf03cSDov Murik table. This module is loaded automatically by the EFI driver 18*cbabf03cSDov Murik if the EFI secret area is populated. 19*cbabf03cSDov Murik 20*cbabf03cSDov Murik Two operations are supported for the files: read and unlink. 21*cbabf03cSDov Murik Reading the file returns the content of secret entry. 22*cbabf03cSDov Murik Unlinking the file overwrites the secret data with zeroes and 23*cbabf03cSDov Murik removes the entry from the filesystem. A secret cannot be read 24*cbabf03cSDov Murik after it has been unlinked. 25*cbabf03cSDov Murik 26*cbabf03cSDov Murik For example, listing the available secrets:: 27*cbabf03cSDov Murik 28*cbabf03cSDov Murik # modprobe efi_secret 29*cbabf03cSDov Murik # ls -l /sys/kernel/security/secrets/coco 30*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 736870e5-84f0-4973-92ec-06879ce3da0b 31*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 83c83f7f-1356-4975-8b7e-d3a0b54312c6 32*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 9553f55d-3da2-43ee-ab5d-ff17f78864d2 33*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 e6f5a162-d67f-4750-a67c-5d065f2a9910 34*cbabf03cSDov Murik 35*cbabf03cSDov Murik Reading the secret data by reading a file:: 36*cbabf03cSDov Murik 37*cbabf03cSDov Murik # cat /sys/kernel/security/secrets/coco/e6f5a162-d67f-4750-a67c-5d065f2a9910 38*cbabf03cSDov Murik the-content-of-the-secret-data 39*cbabf03cSDov Murik 40*cbabf03cSDov Murik Wiping a secret by unlinking a file:: 41*cbabf03cSDov Murik 42*cbabf03cSDov Murik # rm /sys/kernel/security/secrets/coco/e6f5a162-d67f-4750-a67c-5d065f2a9910 43*cbabf03cSDov Murik # ls -l /sys/kernel/security/secrets/coco 44*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 736870e5-84f0-4973-92ec-06879ce3da0b 45*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 83c83f7f-1356-4975-8b7e-d3a0b54312c6 46*cbabf03cSDov Murik -r--r----- 1 root root 0 Jun 28 11:54 9553f55d-3da2-43ee-ab5d-ff17f78864d2 47*cbabf03cSDov Murik 48*cbabf03cSDov Murik Note: The binary format of the secrets table injected by the 49*cbabf03cSDov Murik Guest Owner is described in 50*cbabf03cSDov Murik drivers/virt/coco/efi_secret/efi_secret.c under "Structure of 51*cbabf03cSDov Murik the EFI secret area". 52