Skip to content

Commit 8cf57d7

Browse files
Anastasia Eskovahcahca
authored andcommitted
s390: add support for user-defined certificates
Enable receiving the user-defined certificates from the s390x hypervisor via new diagnose 0x320 calls, and make them available to the Linux root user as 'cert_store_key' type keys in a so-called 'cert_store' keyring. New user-space interfaces: /sys/firmware/cert_store/refresh Writing to this attribute re-fetches certificates via DIAG 0x320 /sys/firmware/cert_store/cs_status Reading from this attribute returns either of: "uninitialized" If no certificate has been retrieved yet "ok" If certificates have been successfully retrieved "failed (<number>)" If certificate retrieval failed with reason code <number> New debug trace areas: /sys/kernel/debug/s390dbf/cert_store_msg /sys/kernel/debug/s390dbf/cert_store_hexdump Usage example: To initiate request for certificates available to the system as root: $ echo 1 > /sys/firmware/cert_store/refresh Upon success the '/sys/firmware/cert_store/cs_status' contains the value 'ok'. $ cat /sys/firmware/cert_store/cs_status ok Get the ID of the keyring 'cert_store': $ keyctl search @us keyring cert_store OR $ keyctl link @us @s; keyctl request keyring cert_store Obtain list of IDs of certificates: $ keyctl rlist <cert_store keyring ID> Display certificate content as hex-dump: $ keyctl read <certificate ID> Read certificate contents as binary data: $ keyctl pipe <certificate ID> >cert_data Display certificate description: $ keyctl describe <certificate ID> The certificate description has the following format: <64 bytes certificate name in EBCDIC> ':' <certificate index as obtained from hypervisor> ':' <certificate store token obtained from hypervisor> The certificate description in /proc/keys has certificate name represented in ASCII. Users can read but cannot update the content of the certificate. Signed-off-by: Anastasia Eskova <[email protected]> Reviewed-by: Peter Oberparleiter <[email protected]> Acked-by: Heiko Carstens <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 6eaae19 commit 8cf57d7

File tree

7 files changed

+825
-1
lines changed

7 files changed

+825
-1
lines changed

arch/s390/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,16 @@ config KEXEC_SIG
512512
verification for the corresponding kernel image type being
513513
loaded in order for this to work.
514514

515+
config CERT_STORE
516+
bool "Get user certificates via DIAG320"
517+
depends on KEYS
518+
help
519+
Enable this option if you want to access user-provided secure boot
520+
certificates via DIAG 0x320.
521+
522+
These certificates will be made available via the keyring named
523+
'cert_store'.
524+
515525
config KERNEL_NOBP
516526
def_bool n
517527
prompt "Enable modified branch prediction for the kernel by default"

arch/s390/include/asm/diag.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum diag_stat_enum {
3636
DIAG_STAT_X304,
3737
DIAG_STAT_X308,
3838
DIAG_STAT_X318,
39+
DIAG_STAT_X320,
3940
DIAG_STAT_X500,
4041
NR_DIAG_STAT
4142
};

arch/s390/include/asm/sclp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct sclp_info {
8686
unsigned char has_kss : 1;
8787
unsigned char has_gisaf : 1;
8888
unsigned char has_diag318 : 1;
89+
unsigned char has_diag320 : 1;
8990
unsigned char has_sipl : 1;
9091
unsigned char has_sipl_eckd : 1;
9192
unsigned char has_dirq : 1;

arch/s390/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ obj-$(CONFIG_JUMP_LABEL) += jump_label.o
6868

6969
obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file.o kexec_image.o
7070
obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o
71-
71+
obj-$(CONFIG_CERT_STORE) += cert_store.o
7272
obj-$(CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT) += ima_arch.o
7373

7474
obj-$(CONFIG_PERF_EVENTS) += perf_event.o

0 commit comments

Comments
 (0)