Page MenuHomeFreeBSD

loader: disk io should not use alloca()
ClosedPublic

Authored by tsoome on Feb 5 2017, 6:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 2 2024, 11:47 AM
Unknown Object (File)
Dec 20 2023, 7:32 AM
Unknown Object (File)
Nov 2 2023, 2:53 AM
Unknown Object (File)
Oct 1 2023, 2:53 AM
Unknown Object (File)
Oct 1 2023, 2:00 AM
Unknown Object (File)
Sep 29 2023, 3:09 AM
Unknown Object (File)
Jun 16 2023, 9:49 AM
Unknown Object (File)
Jun 15 2023, 2:42 PM

Details

Summary

The alloca() does give us pointer and we have no practical way to check if the area
is actually available, resulting in corruption in corner cases.

Unfortunately we do not have too many options right now, but to use one page.

Test Plan

Done usb/disk boot and no immediate issues were detected, CD boot is in queue.
The CD boot is the most probable victim as the one page is just enough for
2 sectors (2KB).

About the background: The loader (user) memory starts from physical address 0xa000,
we have loader code, data and bss segments there. The stack is set on memory end.
The memory end in this case means the value from BDA address 0x413 (2 bytes, value is
in kilobytes). Therefore the stack address is actually system specific and in general
is at about 610k-640k range. So it is entirely possible that at some point the
loader runtime setup and the loader stack will meet heads up.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tsoome retitled this revision from to loader: disk io should not use alloca().
tsoome updated this object.
tsoome edited the test plan for this revision. (Show Details)
tsoome added reviewers: allanjude, imp.
allanjude edited edge metadata.

Approved for commit

This revision is now accepted and ready to land.Feb 5 2017, 10:54 PM

11.0.1 release did not boot out the box for me, with this patch applied it boots again -- so I can verify it works and fixed my previous problem.

This revision was automatically updated to reflect the committed changes.