Skip to content

Commit 96f317e

Browse files
committed
inference/directmap_page_offset_bounds: fix strict lower-bound off-by-one
PAGE_OFFSET > V_min − phys_span is a strict inequality, so the integer minimum is V_min − phys_span + 1, not V_min − phys_span. Update the lower-bound computation and comments accordingly.
1 parent 321dcf4 commit 96f317e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/inference/directmap_page_offset_bounds.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// → page_offset_max = min(page_offset_max, V_min)
1919
//
2020
// Lower bound: PAGE_OFFSET > V_min - phys_span
21-
// → page_offset_min = max(page_offset_min, V_min - phys_span)
21+
// → page_offset_min = max(page_offset_min, V_min - phys_span + 1)
2222
//
2323
// The upper bound is always sound: any single directmap leak pins PAGE_OFFSET
2424
// to within phys_span below the leaked address. When V_min happens to map
@@ -167,7 +167,10 @@ static void directmap_page_offset_bounds_run(struct kasld_analysis_ctx *ctx) {
167167
if (vdmap_min < phys_span)
168168
return;
169169

170-
unsigned long lower = vdmap_min - phys_span;
170+
/* PAGE_OFFSET > V_min − phys_span (strict), so the integer minimum is
171+
* V_min − phys_span + 1. The +1 is practically irrelevant (PAGE_OFFSET
172+
* is page-aligned) but keeps the bound mathematically precise. */
173+
unsigned long lower = vdmap_min - phys_span + 1;
171174

172175
if (lower > ctx->page_offset_min && lower < ctx->page_offset_max) {
173176
if (verbose && !quiet)

0 commit comments

Comments
 (0)