Skip to content

Commit ccbf6a9

Browse files
committed
components: standardise the hardware: meta field on the requirement
The hardware: key is defined as the hardware requirement, but several components put a mitigation there -- prefetch and prefetch_directmap named "KPTI", sidt named "UMIP", which read as "requires KPTI/UMIP" when the leak in fact needs them absent. Name the requirement and move the mitigating feature into a trailing "(mitigated by X)", matching databounce's form: prefetch, prefetch_directmap: prefetch side-channel (mitigated by KPTI) sidt: user-mode SIDT (mitigated by UMIP) Spell out the convention in the KASLD_META doc and the hardening-render comment, and add a check-component-meta rule that fails a bare KPTI/UMIP left where the requirement goes (KPTI is a kernel config, not hardware; UMIP is a CPU feature that only ever blocks user-mode leaks).
1 parent f232247 commit ccbf6a9

6 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/components/prefetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ KASLD_META("method:timing\n"
159159
"phase:probing\n"
160160
"live:1\n"
161161
"addr:virtual\n"
162-
"hardware:KPTI\n");
162+
"hardware:prefetch side-channel (mitigated by KPTI)\n");
163163

164164
static int verbose = 0;
165165

src/components/prefetch_directmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ KASLD_META("method:timing\n"
7575
"phase:probing\n"
7676
"live:1\n"
7777
"addr:virtual\n"
78-
"hardware:KPTI\n"
78+
"hardware:prefetch side-channel (mitigated by KPTI)\n"
7979
"config:RANDOMIZE_MEMORY\n");
8080

8181
static int verbose = 0;

src/components/sidt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ KASLD_META("method:parsed\n"
105105
"live:1\n"
106106
"addr:virtual\n"
107107
"patch:v3.10\n"
108-
"hardware:UMIP\n");
108+
"hardware:user-mode SIDT (mitigated by UMIP)\n");
109109

110110
/* IDTR layout: 2-byte limit followed by base address (4 or 8 bytes) */
111111
struct idtr {

src/include/kasld/api.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,11 @@ typedef int make_iso_compilers_happy;
14481448
* bypass: Capability that bypasses the mitigation.
14491449
* patch: Kernel version that closed the bug.
14501450
* cve: Associated CVE.
1451-
* hardware: Hardware requirement.
1451+
* hardware: Hardware requirement -- the positive condition the leak needs
1452+
* (e.g. "TSX required", "prefetch side-channel"). A feature that
1453+
* disables the leak goes in a trailing "(mitigated by <feature>)",
1454+
* never as the bare value: KPTI, UMIP and the like name the
1455+
* mitigation, not the requirement.
14521456
*/
14531457
#define KASLD_META(text) \
14541458
__attribute__(( \

src/render/hardening.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,8 @@ void render_hardening_text(void) {
982982
if (!rep.hw[i].succeeded)
983983
continue;
984984
/* Lead with the technique and what it leaks; the hardware field is the
985-
* relevant CPU feature/mitigation (e.g. KPTI, "TSX required"), labelled
986-
* so it does not read as the subject that leaks. */
985+
* requirement (e.g. "TSX required", "prefetch side-channel (mitigated by
986+
* KPTI)"), labelled so it does not read as the subject that leaks. */
987987
printf(" %-28s ", rep.hw[i].name);
988988
if (rep.hw[i].addr)
989989
printf("leaks %s address; ", rep.hw[i].addr);

tests/check-component-meta

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fi
2727
rc=0
2828
missing=""
2929
nomethod=""
30+
badhw=""
3031
n=0
3132
for f in "$COMP"/*.c; do
3233
n=$((n + 1))
@@ -38,6 +39,18 @@ for f in "$COMP"/*.c; do
3839
nomethod="$nomethod $base"
3940
rc=1
4041
fi
42+
# The hardware: field names the requirement; a feature that DISABLES the leak
43+
# belongs in a trailing "(mitigated by X)", never as the bare value. The flagged
44+
# tokens name mitigations, not requirements: KPTI is a kernel config, not
45+
# hardware (a KPTI dependency belongs in config:); UMIP is a CPU feature but one
46+
# that blocks user-mode instructions. A bare KPTI/UMIP where the requirement
47+
# goes is the inverted meaning this catches.
48+
hw=$(grep -E '"hardware:' "$f" | head -1 | sed -E 's/.*"hardware:([^"]*)".*/\1/')
49+
req=$(printf '%s' "${hw%\\n}" | sed -E 's/\(mitigated by [^)]*\)//g')
50+
if printf '%s' "$req" | grep -qwE 'KPTI|UMIP'; then
51+
badhw="$badhw $base"
52+
rc=1
53+
fi
4154
done
4255

4356
if [ -n "$missing" ]; then
@@ -48,6 +61,10 @@ if [ -n "$nomethod" ]; then
4861
printf '%scheck-component-meta: FAIL%s — KASLD_META without a method: key:\n' "$RED" "$RESET"
4962
for c in $nomethod; do printf ' %s\n' "$c"; done
5063
fi
64+
if [ -n "$badhw" ]; then
65+
printf '%scheck-component-meta: FAIL%s — hardware: names a mitigation as the requirement (move it into "(mitigated by X)"):\n' "$RED" "$RESET"
66+
for c in $badhw; do printf ' %s\n' "$c"; done
67+
fi
5168
if [ "$rc" -eq 0 ]; then
5269
printf '%scheck-component-meta: OK%s (%d components, all declare KASLD_META with a method: key)\n' "$GREEN" "$RESET" "$n"
5370
fi

0 commit comments

Comments
 (0)