1515#include <stdio.h>
1616#include <string.h>
1717
18+ /* Enforcement surfaces for the two suggestions that are not gate_suggestions[]
19+ * entries (those carry their own .surface): kernel lockdown is an LSM, and the
20+ * dmesg fallback-file restriction is a filesystem-permissions change. Named
21+ * once here so the text, JSON, and markdown renderers agree on the label. */
22+ #define HR_SURFACE_LOCKDOWN "lsm"
23+ #define HR_SURFACE_DMESG_FALLBACK "file_permissions"
24+
1825/* Known sysctl gates */
1926struct sysctl_gate {
2027 const char * name ; /* meta value prefix, e.g. "dmesg_restrict" */
@@ -820,8 +827,13 @@ void render_hardening_text(void) {
820827
821828 for (int i = 0 ; i < rep .n_gate_suggestions ; i ++ ) {
822829 any_suggestions = 1 ;
823- printf (" %s\xe2\x86\x92%s Set %s = %d\n" , c (C_CYAN ), c (C_RESET ),
830+ /* Enforcement surface trails the action, so a reader routes the change to
831+ * the lever it lives on (a sysctl differs from a boot parameter). */
832+ printf (" %s\xe2\x86\x92%s Set %s = %d" , c (C_CYAN ), c (C_RESET ),
824833 rep .gate_suggestions [i ].display , rep .gate_suggestions [i ].threshold );
834+ if (rep .gate_suggestions [i ].surface )
835+ printf (" [%s]" , rep .gate_suggestions [i ].surface );
836+ printf ("\n" );
825837 printf (" affects %d component%s\n" , rep .gate_suggestions [i ].impact ,
826838 rep .gate_suggestions [i ].impact == 1 ? "" : "s" );
827839 if (rep .gate_suggestions [i ].has_projection )
@@ -832,8 +844,8 @@ void render_hardening_text(void) {
832844
833845 if (rep .suggest_lockdown ) {
834846 any_suggestions = 1 ;
835- printf (" %s\xe2\x86\x92%s Enable kernel lockdown (integrity mode)\n" ,
836- c (C_CYAN ), c (C_RESET ));
847+ printf (" %s\xe2\x86\x92%s Enable kernel lockdown (integrity mode) [%s] \n" ,
848+ c (C_CYAN ), c (C_RESET ), HR_SURFACE_LOCKDOWN );
837849 printf (" blocks klogctl() even with CAP_SYSLOG\n" );
838850 if (rep .lockdown_has_projection )
839851 print_necessity (rep .lockdown_silences , exposure , rep .all_vbits ,
@@ -843,8 +855,8 @@ void render_hardening_text(void) {
843855
844856 if (rep .suggest_dmesg_fallback ) {
845857 any_suggestions = 1 ;
846- printf (" %s\xe2\x86\x92%s Restrict dmesg fallback files to root\n" ,
847- c (C_CYAN ), c (C_RESET ));
858+ printf (" %s\xe2\x86\x92%s Restrict dmesg fallback files to root [%s] \n" ,
859+ c (C_CYAN ), c (C_RESET ), HR_SURFACE_DMESG_FALLBACK );
848860 printf (" %d dmesg component%s may have succeeded via log files\n" ,
849861 rep .dmesg_fallback_count , rep .dmesg_fallback_count == 1 ? "" : "s" );
850862 if (rep .dmesg_fallback_has_projection )
@@ -1134,7 +1146,7 @@ void render_hardening_json(void) {
11341146 printf (" {\n" );
11351147 printf (" \"action\": \"Enable kernel lockdown (integrity mode)\","
11361148 "\n" );
1137- printf (" \"surface\": \"lsm \",\n" );
1149+ printf (" \"surface\": \"%s \",\n" , HR_SURFACE_LOCKDOWN );
11381150 printf (" \"impact\": %d,\n" , rep .lockdown_impact );
11391151 printf (" \"detail\": \"Blocks klogctl() even with CAP_SYSLOG\"%s\n" ,
11401152 rep .lockdown_has_projection ? "," : "" );
@@ -1151,7 +1163,7 @@ void render_hardening_json(void) {
11511163 first_sug = 0 ;
11521164 printf (" {\n" );
11531165 printf (" \"action\": \"Restrict dmesg fallback files to root\",\n" );
1154- printf (" \"surface\": \"file_permissions \",\n" );
1166+ printf (" \"surface\": \"%s \",\n" , HR_SURFACE_DMESG_FALLBACK );
11551167 printf (" \"impact\": %d,\n" , rep .dmesg_fallback_count );
11561168 printf (" \"detail\": \"%d dmesg component%s may have succeeded via "
11571169 "log files\"%s\n" ,
@@ -1400,7 +1412,7 @@ void render_hardening_markdown(void) {
14001412 md_print_necessity (rep .lockdown_silences , exposure , rep .all_vbits ,
14011413 rep .lockdown_skip_vbits , rep .all_pbits ,
14021414 rep .lockdown_skip_pbits );
1403- printf (" [`lsm `]" );
1415+ printf (" [`%s `]" , HR_SURFACE_LOCKDOWN );
14041416 printf ("\n" );
14051417 }
14061418 if (rep .suggest_dmesg_fallback ) {
@@ -1412,7 +1424,7 @@ void render_hardening_markdown(void) {
14121424 md_print_necessity (rep .dmesg_fallback_silences , exposure , rep .all_vbits ,
14131425 rep .dmesg_fallback_skip_vbits , rep .all_pbits ,
14141426 rep .dmesg_fallback_skip_pbits );
1415- printf (" [`file_permissions `]" );
1427+ printf (" [`%s `]" , HR_SURFACE_DMESG_FALLBACK );
14161428 printf ("\n" );
14171429 }
14181430 if (!any_sug )
0 commit comments