Skip to content

Commit a52e5cd

Browse files
svens-s390Vasily Gorbik
authored andcommitted
s390/ipl: add missing intersection check to ipl_report handling
The code which handles the ipl report is searching for a free location in memory where it could copy the component and certificate entries to. It checks for intersection between the sections required for the kernel and the component/certificate data area, but fails to check whether the data structures linking these data areas together intersect. This might cause the iplreport copy code to overwrite the iplreport itself. Fix this by adding two addtional intersection checks. Cc: <[email protected]> Fixes: 9641b8c ("s390/ipl: read IPL report at early boot") Signed-off-by: Sven Schnelle <[email protected]> Reviewed-by: Vasily Gorbik <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent eeac8ed commit a52e5cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/s390/boot/ipl_report.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ static unsigned long find_bootdata_space(struct ipl_rb_components *comps,
5757
if (IS_ENABLED(CONFIG_BLK_DEV_INITRD) && initrd_data.start && initrd_data.size &&
5858
intersects(initrd_data.start, initrd_data.size, safe_addr, size))
5959
safe_addr = initrd_data.start + initrd_data.size;
60+
if (intersects(safe_addr, size, (unsigned long)comps, comps->len)) {
61+
safe_addr = (unsigned long)comps + comps->len;
62+
goto repeat;
63+
}
6064
for_each_rb_entry(comp, comps)
6165
if (intersects(safe_addr, size, comp->addr, comp->len)) {
6266
safe_addr = comp->addr + comp->len;
6367
goto repeat;
6468
}
69+
if (intersects(safe_addr, size, (unsigned long)certs, certs->len)) {
70+
safe_addr = (unsigned long)certs + certs->len;
71+
goto repeat;
72+
}
6573
for_each_rb_entry(cert, certs)
6674
if (intersects(safe_addr, size, cert->addr, cert->len)) {
6775
safe_addr = cert->addr + cert->len;

0 commit comments

Comments
 (0)