162306a36Sopenharmony_ciWhat:		security/secrets/coco
262306a36Sopenharmony_ciDate:		February 2022
362306a36Sopenharmony_ciContact:	Dov Murik <dovmurik@linux.ibm.com>
462306a36Sopenharmony_ciDescription:
562306a36Sopenharmony_ci		Exposes confidential computing (coco) EFI secrets to
662306a36Sopenharmony_ci		userspace via securityfs.
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci		EFI can declare memory area used by confidential computing
962306a36Sopenharmony_ci		platforms (such as AMD SEV and SEV-ES) for secret injection by
1062306a36Sopenharmony_ci		the Guest Owner during VM's launch.  The secrets are encrypted
1162306a36Sopenharmony_ci		by the Guest Owner and decrypted inside the trusted enclave,
1262306a36Sopenharmony_ci		and therefore are not readable by the untrusted host.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci		The efi_secret module exposes the secrets to userspace.  Each
1562306a36Sopenharmony_ci		secret appears as a file under <securityfs>/secrets/coco,
1662306a36Sopenharmony_ci		where the filename is the GUID of the entry in the secrets
1762306a36Sopenharmony_ci		table.  This module is loaded automatically by the EFI driver
1862306a36Sopenharmony_ci		if the EFI secret area is populated.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci		Two operations are supported for the files: read and unlink.
2162306a36Sopenharmony_ci		Reading the file returns the content of secret entry.
2262306a36Sopenharmony_ci		Unlinking the file overwrites the secret data with zeroes and
2362306a36Sopenharmony_ci		removes the entry from the filesystem.  A secret cannot be read
2462306a36Sopenharmony_ci		after it has been unlinked.
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci		For example, listing the available secrets::
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci		  # modprobe efi_secret
2962306a36Sopenharmony_ci		  # ls -l /sys/kernel/security/secrets/coco
3062306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 736870e5-84f0-4973-92ec-06879ce3da0b
3162306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 83c83f7f-1356-4975-8b7e-d3a0b54312c6
3262306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 9553f55d-3da2-43ee-ab5d-ff17f78864d2
3362306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 e6f5a162-d67f-4750-a67c-5d065f2a9910
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci		Reading the secret data by reading a file::
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci		  # cat /sys/kernel/security/secrets/coco/e6f5a162-d67f-4750-a67c-5d065f2a9910
3862306a36Sopenharmony_ci		  the-content-of-the-secret-data
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci		Wiping a secret by unlinking a file::
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci		  # rm /sys/kernel/security/secrets/coco/e6f5a162-d67f-4750-a67c-5d065f2a9910
4362306a36Sopenharmony_ci		  # ls -l /sys/kernel/security/secrets/coco
4462306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 736870e5-84f0-4973-92ec-06879ce3da0b
4562306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 83c83f7f-1356-4975-8b7e-d3a0b54312c6
4662306a36Sopenharmony_ci		  -r--r----- 1 root root 0 Jun 28 11:54 9553f55d-3da2-43ee-ab5d-ff17f78864d2
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci		Note: The binary format of the secrets table injected by the
4962306a36Sopenharmony_ci		Guest Owner is described in
5062306a36Sopenharmony_ci		drivers/virt/coco/efi_secret/efi_secret.c under "Structure of
5162306a36Sopenharmony_ci		the EFI secret area".
52