Skip to content

Commit 0b30218

Browse files
author
Mamatha Inamdar
committed
powerpc/secvar: Expose secvars relevant to the key management mode
JIRA: https://issues.redhat.com/browse/RHEL-101962 commit c1d96cd Author: Srish Srinivasan <ssrish@linux.ibm.com> Date: Wed Jun 11 02:49:06 2025 +0530 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 Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent 26776d2 commit 0b30218

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
@@ -34,6 +34,13 @@ Description: Each secure variable is represented as a directory named as
3434
representation. The data and size can be determined by reading
3535
their respective attribute files.
3636

37+
Only secvars relevant to the key management mode are exposed.
38+
Only in the dynamic key management mode should the user have
39+
access (read and write) to the secure boot secvars db, dbx,
40+
grubdb, grubdbx, and sbat. These secvars are not consumed in the
41+
static key management mode. PK, trustedcadb and moduledb are the
42+
secvars common to both static and dynamic key management modes.
43+
3744
What: /sys/firmware/secvar/vars/<variable_name>/size
3845
Date: August 2019
3946
Contact: Nayna Jain <nayna@linux.ibm.com>

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",
@@ -197,21 +204,34 @@ static int plpks_max_size(u64 *max_size)
197204
return 0;
198205
}
199206

207+
static const struct secvar_operations plpks_secvar_ops_static = {
208+
.get = plpks_get_variable,
209+
.set = plpks_set_variable,
210+
.format = plpks_secvar_format,
211+
.max_size = plpks_max_size,
212+
.config_attrs = config_attrs,
213+
.var_names = plpks_var_names_static,
214+
};
200215

201-
static const struct secvar_operations plpks_secvar_ops = {
216+
static const struct secvar_operations plpks_secvar_ops_dynamic = {
202217
.get = plpks_get_variable,
203218
.set = plpks_set_variable,
204219
.format = plpks_secvar_format,
205220
.max_size = plpks_max_size,
206221
.config_attrs = config_attrs,
207-
.var_names = plpks_var_names,
222+
.var_names = plpks_var_names_dynamic,
208223
};
209224

210225
static int plpks_secvar_init(void)
211226
{
227+
u8 mode;
228+
212229
if (!plpks_is_available())
213230
return -ENODEV;
214231

215-
return set_secvar_ops(&plpks_secvar_ops);
232+
mode = plpks_get_sb_keymgmt_mode();
233+
if (mode)
234+
return set_secvar_ops(&plpks_secvar_ops_dynamic);
235+
return set_secvar_ops(&plpks_secvar_ops_static);
216236
}
217237
machine_device_initcall(pseries, plpks_secvar_init);

0 commit comments

Comments
 (0)