-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathmeminfo_facts.c
More file actions
27 lines (25 loc) · 1.03 KB
/
Copy pathmeminfo_facts.c
File metadata and controls
27 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// This file is part of KASLD - https://github.com/bcoles/kasld
//
// Emit memory-size scalar facts from /proc/meminfo and /proc/zoneinfo:
// SF_PHYS_MEMTOTAL, SF_PHYS_LOWMEM (highmem kernels), SF_PHYS_MAX_PFN. These
// bound the physical KASLR window (the kernel image must fit within RAM).
// ---
// <bcoles@gmail.com>
#include "include/kasld/api.h"
#include "include/kasld/meminfo.h"
KASLD_EXPLAIN("Reads /proc/meminfo (MemTotal, LowTotal) and /proc/zoneinfo "
"(spanned PFNs) and emits them as scalar system facts that bound "
"the physical address window. World-readable, no privileges.");
KASLD_META("method:parsed\n"
"phase:inference\n"
"discloses:facts\n");
int main(void) {
unsigned long v;
if ((v = kasld_read_memtotal_bytes()))
kasld_emit_scalar(SF_PHYS_MEMTOTAL, v, CONF_PARSED);
if ((v = kasld_read_lowmem_bytes()))
kasld_emit_scalar(SF_PHYS_LOWMEM, v, CONF_PARSED);
if ((v = kasld_read_max_pfn()))
kasld_emit_scalar(SF_PHYS_MAX_PFN, v, CONF_PARSED);
return 0;
}