pc-bios/s390-ccw: Add signed component address overlap checks
Add address range tracking and overlap checks to ensure that no component overlaps with a signed component during secure IPL. Signed-off-by: Zhuoying Cai <zycai@linux.ibm.com> Reviewed-by: Jared Rossi <jrossi@linux.ibm.com> Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com> Reviewed-by: Collin Walling <walling@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260730214624.2328883-25-zycai@linux.ibm.com Signed-off-by: Eric Farman <farman@linux.ibm.com>
Zhuoying Cai committed
Jul 30, 2026 at 17:46 UTC
c04688deae81056545fdca4f59de18fe9ac2fce2
2 files changed
+29
pc-bios/s390-ccw/secure-ipl.c
+19
@@ -193,6 +193,23 @@ static void init_lists(IplDeviceComponentList *comp_list,
193
cert_list->ipl_info_header.len = sizeof(IplInfoBlockHeader);
194
}
195
196
+static void check_comp_overlap(IplDeviceComponentList *comp_list,
197
+ IplDeviceComponentEntry comp_entry)
198
+{
199
+ IplDeviceComponentEntry *comp;
200
+
201
+ /*
202
+ * Check component's address range does not overlap with any
203
+ * signed component's address range.
204
+ */
205
+ for_each_rb_entry(comp, comp_list) {
206
+ if (comp->flags & S390_IPL_DEV_COMP_FLAG_SC &&
207
+ intersects(comp->addr, comp->len, comp_entry.addr, comp_entry.len)) {
208
+ zipl_secure_error("Component addresses overlap");
209
+ }
210
+ }
211
+}
212
+
213
static int zipl_load_signature(ComponentEntry *entry, uint64_t sig)
214
{
215
if (entry->compdat.sig_info.format != DER_SIGNATURE_FORMAT) {
@@ -294,6 +311,8 @@ int zipl_run_secure(ComponentEntry **entry_ptr, const uint8_t *tmp_sec,
311
comp_entry.addr = comp_addr;
312
comp_entry.len = (uint64_t)comp_len;
313
314
+ check_comp_overlap(comp_list, comp_entry);
315
+
316
/* no signature present (unsigned component) */
317
if (!sig_entry.len) {
318
comp_list_add(comp_list, comp_entry);
pc-bios/s390-ccw/secure-ipl.h
+10
@@ -116,4 +116,14 @@ static inline bool verify_signature(IplDeviceComponentEntry comp_entry,
116
return false;
117
}
118
119
+static inline bool intersects(uint64_t addr0, uint64_t size0,
120
+ uint64_t addr1, uint64_t size1)
121
+{
122
+ if (addr1 > addr0) {
123
+ return addr1 - addr0 < size0;
124
+ }
125
+
126
+ return addr0 - addr1 < size1;
127
+}
128
+
129
#endif /* _PC_BIOS_S390_CCW_SECURE_IPL_H */