Skip to contentSkip to conversation

KEYS: check the certfile for ASN1 encoding before inserting

PATCH New Clay Chang 1 participant 1 message Jan 29, 2020 Keys/keyrings

lore
Share & tools
lore

Clay Chang

author
#0 lore raw

PATCH 1/1 KEYS: check the certfile for ASN1 encoding before inserting

The certfile to be inserted into the kernel must be in ASN1 encoding. This patch implements a guard against invalid certfile.

---
 scripts/insert-sys-cert.c | 5 +++++
 1 file changed, 5 insertions(+)
scripts/insert-sys-cert.c +5 -0
index 8902836c2342..2d9139887ba0 100644
@@ -311,6 +311,11 @@ int main(int argc, char **argv)
 	if (!cert)
 		exit(EXIT_FAILURE);
 
+	if (cert[0] != 0x30 && cert[1] != 0x82) {
+		err("Invalid certfile.\n");
+		exit(EXIT_FAILURE);
+	}
+
 	hdr = map_file(vmlinux_file, &vmlinux_size);
 	if (!hdr)
 		exit(EXIT_FAILURE);
Signature · 1 line
2.16.6