staticint check_prng(void)
{ if (!cpacf_query_func(CPACF_KMC, CPACF_KMC_PRNG)) {
boot_warn("KASLR disabled: CPU has no PRNG\n"); return 0;
} if (cpacf_query_func(CPACF_PRNO, CPACF_PRNO_TRNG)) return PRNG_MODE_TRNG; if (cpacf_query_func(CPACF_PRNO, CPACF_PRNO_SHA512_DRNG_GEN)) return PRNG_MODE_SHA512; else return PRNG_MODE_TDES;
}
while (start + size <= end) { /* skip reserved ranges below the start */ while (res && res->end <= start) {
res++; if (res >= res_end)
res = NULL;
}
skip_res = NULL;
tmp_end = end; /* has intersecting reserved range */ if (res && res->start < end) {
skip_res = res;
tmp_end = res->start;
} if (start + size <= tmp_end) {
range_pos = (tmp_end - start - size) / align + 1; if (pos_count) {
pos += range_pos;
} else { if (range_pos >= find_pos) return start + (find_pos - 1) * align;
find_pos -= range_pos;
}
} if (!skip_res) break;
start = round_up(skip_res->end, align);
}
}
return pos_count ? pos : 0;
}
/* * Two types of decompressor memory allocations/reserves are considered * differently. * * "Static" or "single" allocations are done via physmem_alloc_range() and * physmem_reserve(), and they are listed in physmem_info.reserved[]. Each * type of "static" allocation can only have one allocation per type and * cannot have chains. * * On the other hand, "dynamic" or "repetitive" allocations are done via * physmem_alloc_or_die(). These allocations are tightly packed together * top down from the end of online memory. physmem_alloc_pos represents * current position where those allocations start. * * Functions randomize_within_range() and iterate_valid_positions() * only consider "dynamic" allocations by never looking above * physmem_alloc_pos. "Static" allocations, however, are explicitly * considered by checking the "res" (reserves) array. The first * reserved_range of a "dynamic" allocation may also be checked along the * way, but it will always be above the maximum value anyway.
*/ unsignedlong randomize_within_range(unsignedlong size, unsignedlong align, unsignedlong min, unsignedlong max)
{ struct reserved_range res[RR_MAX]; unsignedlong max_pos, pos;
memcpy(res, physmem_info.reserved, sizeof(res));
sort_reserved_ranges(res, ARRAY_SIZE(res));
max = min(max, get_physmem_alloc_pos());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.