Skip to content

Commit c1d96cd

Browse files
ssrish17maddy-kerneldev
authored andcommitted
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 <[email protected]> Signed-off-by: Souradeep <[email protected]> Signed-off-by: Srish Srinivasan <[email protected]> Tested-by: R Nageswara Sastry <[email protected]> Reviewed-by: Mimi Zohar <[email protected]> Reviewed-by: Stefan Berger <[email protected]> Reviewed-by: Nayna Jain <[email protected]> Reviewed-by: Andrew Donnellan <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent fbf355f commit c1d96cd

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

Documentation/ABI/testing/sysfs-secvar

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ Description: Each secure variable is represented as a directory named as
3838
representation. The data and size can be determined by reading
3939
their respective attribute files.
4040

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+
4148
What: /sys/firmware/secvar/vars/<variable_name>/size
4249
Date: August 2019
4350
Contact: Nayna Jain <[email protected]>

arch/powerpc/platforms/pseries/plpks-secvar.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ static u32 get_policy(const char *name)
5959
return PLPKS_SIGNEDUPDATE;
6060
}
6161

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[] = {
6370
"PK",
6471
"KEK",
6572
"db",
@@ -213,21 +220,34 @@ static int plpks_max_size(u64 *max_size)
213220
return 0;
214221
}
215222

223+
static const struct secvar_operations plpks_secvar_ops_static = {
224+
.get = plpks_get_variable,
225+
.set = plpks_set_variable,
226+
.format = plpks_secvar_format,
227+
.max_size = plpks_max_size,
228+
.config_attrs = config_attrs,
229+
.var_names = plpks_var_names_static,
230+
};
216231

217-
static const struct secvar_operations plpks_secvar_ops = {
232+
static const struct secvar_operations plpks_secvar_ops_dynamic = {
218233
.get = plpks_get_variable,
219234
.set = plpks_set_variable,
220235
.format = plpks_secvar_format,
221236
.max_size = plpks_max_size,
222237
.config_attrs = config_attrs,
223-
.var_names = plpks_var_names,
238+
.var_names = plpks_var_names_dynamic,
224239
};
225240

226241
static int plpks_secvar_init(void)
227242
{
243+
u8 mode;
244+
228245
if (!plpks_is_available())
229246
return -ENODEV;
230247

231-
return set_secvar_ops(&plpks_secvar_ops);
248+
mode = plpks_get_sb_keymgmt_mode();
249+
if (mode)
250+
return set_secvar_ops(&plpks_secvar_ops_dynamic);
251+
return set_secvar_ops(&plpks_secvar_ops_static);
232252
}
233253
machine_device_initcall(pseries, plpks_secvar_init);

0 commit comments

Comments
 (0)