Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/secvar: Expose secvars relevant to the key management mode

The PLPKS enabled PowerVM LPAR sysfs exposes all of the secure boot
secvars irrespective of the key management mode.

The PowerVM LPAR supports static and dynamic key management for secure
boot. The key management option can be updated in the management
console. The secvars PK, trustedcadb, and moduledb can be consumed both
in the static and dynamic key management modes for the loading of signed
third-party kernel modules. However, other secvars i.e. KEK, grubdb,
grubdbx, sbat, db and dbx, which are used to verify the grub and kernel
images, are consumed only in the dynamic key management mode.

Expose only PK, trustedcadb, and moduledb in the static key management
mode.

Co-developed-by: Souradeep <soura@imap.linux.ibm.com>
Signed-off-by: Souradeep <soura@imap.linux.ibm.com>
Signed-off-by: Srish Srinivasan <ssrish@linux.ibm.com>
Tested-by: R Nageswara Sastry <rnsastry@linux.ibm.com>
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Nayna Jain <nayna@linux.ibm.com>
Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250610211907.101384-3-ssrish@linux.ibm.com

authored by

Srish Srinivasan and committed by
Madhavan Srinivasan
c1d96cd9 fbf355f3

+32 -5
+7
Documentation/ABI/testing/sysfs-secvar
··· 38 38 representation. The data and size can be determined by reading 39 39 their respective attribute files. 40 40 41 + Only secvars relevant to the key management mode are exposed. 42 + Only in the dynamic key management mode should the user have 43 + access (read and write) to the secure boot secvars db, dbx, 44 + grubdb, grubdbx, and sbat. These secvars are not consumed in the 45 + static key management mode. PK, trustedcadb and moduledb are the 46 + secvars common to both static and dynamic key management modes. 47 + 41 48 What: /sys/firmware/secvar/vars/<variable_name>/size 42 49 Date: August 2019 43 50 Contact: Nayna Jain <nayna@linux.ibm.com>
+25 -5
arch/powerpc/platforms/pseries/plpks-secvar.c
··· 59 59 return PLPKS_SIGNEDUPDATE; 60 60 } 61 61 62 - static const char * const plpks_var_names[] = { 62 + static const char * const plpks_var_names_static[] = { 63 + "PK", 64 + "moduledb", 65 + "trustedcadb", 66 + NULL, 67 + }; 68 + 69 + static const char * const plpks_var_names_dynamic[] = { 63 70 "PK", 64 71 "KEK", 65 72 "db", ··· 220 213 return 0; 221 214 } 222 215 223 - 224 - static const struct secvar_operations plpks_secvar_ops = { 216 + static const struct secvar_operations plpks_secvar_ops_static = { 225 217 .get = plpks_get_variable, 226 218 .set = plpks_set_variable, 227 219 .format = plpks_secvar_format, 228 220 .max_size = plpks_max_size, 229 221 .config_attrs = config_attrs, 230 - .var_names = plpks_var_names, 222 + .var_names = plpks_var_names_static, 223 + }; 224 + 225 + static const struct secvar_operations plpks_secvar_ops_dynamic = { 226 + .get = plpks_get_variable, 227 + .set = plpks_set_variable, 228 + .format = plpks_secvar_format, 229 + .max_size = plpks_max_size, 230 + .config_attrs = config_attrs, 231 + .var_names = plpks_var_names_dynamic, 231 232 }; 232 233 233 234 static int plpks_secvar_init(void) 234 235 { 236 + u8 mode; 237 + 235 238 if (!plpks_is_available()) 236 239 return -ENODEV; 237 240 238 - return set_secvar_ops(&plpks_secvar_ops); 241 + mode = plpks_get_sb_keymgmt_mode(); 242 + if (mode) 243 + return set_secvar_ops(&plpks_secvar_ops_dynamic); 244 + return set_secvar_ops(&plpks_secvar_ops_static); 239 245 } 240 246 machine_device_initcall(pseries, plpks_secvar_init);