Skip to content

Commit 5b1b10e

Browse files
committed
sysfs_kernel_notes_xen: pin the likely image base from pvh_start_xen
pvh_start_xen (PHYS32_ENTRY) sits within one KASLR step of _text, so kasld_floor_text_base() recovers _text exactly. Emit it as a CONF_HEURISTIC image-base pin — it collapses the likely window to _text while staying below the guaranteed floor, so the guaranteed window (the interior-sample upper bound) is unchanged. Previously only the interior sample was emitted, leaving the base bounded but not pinned.
1 parent 6997ea4 commit 5b1b10e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/components/sysfs_kernel_notes_xen.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,11 @@ static int has_xen_elfnote_symbols(void) {
150150
* pvh_start_xen is the anchor for that floor. hypercall_page sits at _text +
151151
* 0x1000 on <= 5.x (inside the 2 MiB window), but 6.x moves it to .noinstr.text
152152
* ~16-19 MiB past _text, so its floor overshoots _text by ~16 MiB; startup_xen
153-
* (.init.text) is ~25-40 MiB out. All three are emitted as interior samples;
154-
* the engine bounds the base from the lowest. */
153+
* (.init.text) is ~25-40 MiB out. All three are emitted as interior samples, so
154+
* the floor of the lowest bounds the guaranteed base from above. pvh_start_xen
155+
* alone also pins the LIKELY base: its offset is below the align, so its own
156+
* floor is _text exactly — emitted at CONF_HEURISTIC, which refines the likely
157+
* window without ever narrowing the guaranteed one. */
155158

156159
int main(void) {
157160
int fd;
@@ -324,6 +327,18 @@ int main(void) {
324327
kasld_found("Xen PHYS32_ENTRY -> virtual: %lx", virt);
325328
kasld_result_sample(KASLD_TYPE_VIRT, REGION_KERNEL_TEXT, virt,
326329
"pvh_start_xen", CONF_PARSED);
330+
/* pvh_start_xen is the PVH entry in .head.text (_text+0..0x5f0), so
331+
* its VA sits within one KASLR step of _text; kasld_floor_text_base()
332+
* rounds it down to the base grid (preserving any arch sub-offset),
333+
* landing on _text exactly. Pin that as the likely image base at
334+
* CONF_HEURISTIC: "within one step" is a structural regularity, not a
335+
* runtime-provable bound, so it stays below the guaranteed floor and
336+
* refines the likely window only — never the guaranteed base, which
337+
* rests on the interior sample above. */
338+
unsigned long base = kasld_floor_text_base(virt);
339+
if (kasld_addr_is_kernel_text(base))
340+
kasld_result_base(KASLD_TYPE_VIRT, REGION_KERNEL_IMAGE, base,
341+
"_text", CONF_HEURISTIC);
327342
found++;
328343
}
329344
}

0 commit comments

Comments
 (0)