linux-kernel-defence-map.gv 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. //
  2. // Linux Kernel Defence Map showing the relationships between:
  3. // - Vulnerability classes
  4. // - Exploitation techniques
  5. // - Bug detection mechanisms
  6. // - Defence technologies
  7. //
  8. // Author: Alexander Popov <alex.popov@linux.com>
  9. //
  10. // License terms: GNU General Public License (GPL), version 3.0.
  11. // For details see LICENSE file.
  12. //
  13. // N.B. The node connections don't mean "full mitigation". These connections
  14. // represent some kind of relation. So ideally, this map should help to navigate
  15. // in documentation and Linux kernel sources.
  16. //
  17. // It is written in DOT language.
  18. // How to generate svg:
  19. // dot -Tsvg linux-kernel-defence-map.dot -o linux-kernel-defence-map.svg
  20. //
  21. // References:
  22. //
  23. // - The State of Kernel Self Protection by Kees Cook
  24. // https://outflux.net/slides/2018/lca/kspp.pdf
  25. //
  26. // - grsecurity features
  27. // https://grsecurity.net/features.php
  28. //
  29. // - Linux kernel security documentation:
  30. // https://www.kernel.org/doc/html/latest/security/self-protection.html
  31. //
  32. // - Linux kernel mitigation checklist by Shawn C
  33. // https://github.com/hardenedlinux/grsecurity-101-tutorials/blob/master/kernel_mitigation.md
  34. //
  35. /*
  36. https://github.com/a13xp0p0v/linux-kernel-defence-map
  37. Linux kernel security is a very complex topic. Some defence technologies are provided by the Linux kernel mainline. Others are going out‑of‑tree for various reasons (some of them are commercial, for example). Plus there are kernel defences that depend on special hardware features.
  38. It would be nice to have a graphical representation of the current state of Linux kernel security.
  39. So I've created a Linux Kernel Defence Map showing the relationships between:
  40. Vulnerability classes
  41. Exploitation techniques
  42. Bug detection mechanisms
  43. Defence technologies
  44. N.B. The node connections don't mean "full mitigation." Rather, each connection represents some kind of relationship. So this map should help to navigate the documentation and Linux kernel sources. It also provides the Common Weakness Enumeration (CWE) numbers for vulnerability classes.
  45. How this Map is made
  46. This map is written in the DOT language, which makes maintenance and updating in Git very convenient. The diagram is generated using GraphViz with the following command:
  47. dot -Tsvg linux-kernel-defence-map.dot -o linux-kernel-defence-map.svg
  48. Do you want to check your kernel config?
  49. So there are plenty of security hardening options in the Linux kernel. A lot of them are not enabled by the major distros. We have to enable these options ourselves to make our systems more secure.
  50. But nobody likes verifying configs manually. So I've created the kconfig-hardened-check that checks security hardening options of the Linux kernel. You are welcome to try it.
  51. Documentation
  52. Grsecurity features:
  53. https://grsecurity.net/features.php
  54. The State of Kernel Self Protection by Kees Cook:
  55. https://outflux.net/slides/2018/lca/kspp.pdf
  56. Linux kernel security documentation:
  57. https://www.kernel.org/doc/html/latest/security/self-protection.html
  58. Linux kernel mitigation checklist by Shawn C:
  59. https://github.com/hardenedlinux/grsecurity-101-tutorials/blob/master/kernel_mitigation.md
  60. Trends, challenge, and shifts in software vulnerability mitigation by MSRC:
  61. https://github.com/Microsoft/MSRC-Security-Research/tree/master/presentations/2019_02_BlueHatIL
  62. Pursuing Durable Safety for Systems Software by Matt Miller @mamillmsft:
  63. https://www.sstic.org/2020/presentation/ouverture_2020/
  64. A Decade of Linux Kernel Vulnerabilities, their Mitigation and Open Problems by Abhilash Raj:
  65. https://github.com/maxking/linux-vulnerabilities-10-years
  66. Linux Kernel Runtime Guard (LKRG) threat model:
  67. https://openwall.info/wiki/p_lkrg/Threat_model
  68. Spectre & Meltdown Checker by Stéphane Lesimple @speed47
  69. https://github.com/speed47/spectre-meltdown-checker
  70. */
  71. digraph {
  72. labelloc=top;
  73. fontsize=30;
  74. fontname=monospace;
  75. label="Linux Kernel Defence Map";
  76. compound=true;
  77. nodesep=0.5;
  78. splines=line;
  79. remincross=true;
  80. rankdir=LR;
  81. node [style=filled, fontname=monospace, margin="0.22,0.055"];
  82. subgraph cluster_legend {
  83. fontsize=25;
  84. label="Legend:";
  85. style="solid";
  86. margin=35;
  87. "Mainline Defences" [shape=oval, color=palegreen3];
  88. "Out-of-tree Defences" [shape=oval, color=cornflowerblue];
  89. "Commercial Defences" [shape=oval, color=lightgrey];
  90. "HW Defences" [shape=oval, color=aquamarine];
  91. "Generic Defence Techniques" [shape=oval, color=black, style=solid];
  92. "Bug Detection" [shape=octagon, color=mediumpurple];
  93. "Vulnerabilities" [shape=box, color=pink];
  94. "Exploitation Techniques" [shape=box, color=gold];
  95. }
  96. // For pretty legend layout:
  97. edge [arrowhead=none, style=invis];
  98. "Mainline Defences":e -> "Out-of-tree Defences";
  99. "Out-of-tree Defences":e -> "Commercial Defences";
  100. "Commercial Defences":e -> "HW Defences";
  101. "Generic Defence Techniques":e -> "Bug Detection";
  102. "Bug Detection":e -> "Vulnerabilities";
  103. "Vulnerabilities":e -> "Exploitation Techniques";
  104. // Defences
  105. {
  106. rank=same;
  107. // Mainline Defences
  108. node [shape=oval, color=palegreen3, style=filled];
  109. "DEBUG_{LIST,SG,CREDENTIALS,NOTIFIERS,VIRTUAL}";
  110. "SLAB_FREELIST_RANDOM";
  111. "SHUFFLE_PAGE_ALLOCATOR";
  112. "STRICT_{KERNEL,MODULE}_RWX";
  113. "DEBUG_WX";
  114. "ARM: RODATA_FULL_DEFAULT_ENABLED";
  115. "BUG_ON_DATA_CORRUPTION";
  116. "MODULE_SIG*";
  117. "SECURITY_LOADPIN";
  118. "bpf_jit_harden";
  119. "DEFAULT_MMAP_MIN_ADDR=65536";
  120. "SCHED_STACK_END_CHECK";
  121. "TIF_FSCHECK flag";
  122. "slab_nomerge"; // similar to disabled SLAB_MERGE_DEFAULT
  123. "LOCKDOWN_LSM";
  124. "unprivileged_userfaultfd=0";
  125. "LDISC_AUTOLOAD is not set";
  126. "ARM: SHADOW_CALL_STACK";
  127. "STACKPROTECTOR";
  128. "ARM: KASAN_HW_TAGS with ARM64_MTE";
  129. // Mainline Defences against Transient Execution Attacks
  130. "X86: mds=full,nosmt";
  131. "X86: l1tf=full,force";
  132. // Out-of-tree Defences
  133. node [shape=oval, color=cornflowerblue];
  134. "XPFO";
  135. "PROTECTABLE_MEMORY";
  136. "request_module_cap()";
  137. "LKRG"; // Disable MODULE_UNLOAD to make bypass harder
  138. // Commercial Defences
  139. node [shape=oval, color=lightgrey];
  140. "GRKERNSEC_KSTACKOVERFLOW";
  141. "PAX_REFCOUNT";
  142. "PAX_SIZE_OVERFLOW";
  143. "PAX_USERCOPY";
  144. "PAX_KERNEXEC";
  145. "GRKERNSEC_JIT_HARDEN";
  146. "PAX_MEMORY_STACKLEAK";
  147. "GRKERNSEC_MODHARDEN";
  148. grsecurity_hardened_usermodehelper [label="by default in grsecurity"];
  149. "AUTOSLAB";
  150. // HW Defences
  151. node [shape=oval, color=aquamarine];
  152. "SMEP/PXN";
  153. // Generic Defence Techniques
  154. node [shape=oval, color=black, style=solid];
  155. "Control Flow Integrity";
  156. }
  157. subgraph cluster_cwe514_mitigations {
  158. label="";
  159. rank=same;
  160. style="solid"; // Should work together
  161. margin=10;
  162. node [shape=oval, color=palegreen3]; // Mainline Defences
  163. "mitigations=auto,nosmt";
  164. "X86: MICROCODE";
  165. }
  166. subgraph cluster_pti {
  167. label="";
  168. rank=same;
  169. style="solid"; // Similar functionality, for different architectures
  170. margin=10;
  171. node [shape=oval, color=palegreen3]; // Mainline Defences
  172. "X86: pti=on (PAGE_TABLE_ISOLATION)";
  173. "ARM: kpti=on (UNMAP_KERNEL_AT_EL0)";
  174. }
  175. subgraph cluster_smap_pan_uderef {
  176. label="";
  177. rank=same;
  178. style="solid"; // Similar functionality
  179. margin=10;
  180. "SMAP/PAN" [shape=oval, color=aquamarine]; // HW Defence
  181. "PAX_UDEREF" [shape=oval, color=lightgrey]; // Commercial Defence
  182. }
  183. subgraph cluster_ro {
  184. label="";
  185. rank=same;
  186. style="dashed";
  187. margin=15;
  188. // Commercial Defences
  189. node [shape=oval, color=lightgrey];
  190. "__read_only";
  191. "PAX_CONSTIFY_PLUGIN";
  192. }
  193. subgraph cluster_v1_mitigations {
  194. label="";
  195. rank=same;
  196. style="solid"; // Similar functionality
  197. margin=15;
  198. "RESPECTRE" [shape=oval, color=lightgrey]; // Commercial Defence
  199. "Manual usage of nospec barriers" [shape=oval, color=palegreen3]; // Mainline Defence
  200. }
  201. subgraph cluster_v2_mitigations {
  202. label="";
  203. rank=same;
  204. style="solid"; // Similar functionality, for different architectures
  205. margin=15;
  206. node [shape=oval, color=palegreen3]; // Mainline Defence
  207. "X86: spectre_v2=on (RETPOLINE)";
  208. "ARM: HARDEN_BRANCH_PREDICTOR";
  209. }
  210. subgraph cluster_ssb_mitigations {
  211. label="";
  212. rank=same;
  213. style="solid"; // Similar functionality, for different architectures
  214. margin=15;
  215. node [shape=oval, color=palegreen3]; // Mainline Defence
  216. "X86: spec_store_bypass_disable=on";
  217. "ARM: ssbd=force-on";
  218. }
  219. subgraph cluster_layout_randomization {
  220. label="Layout Randomization";
  221. rank=same;
  222. fontsize=18;
  223. style="dashed";
  224. margin=15;
  225. "RANDOMIZE_{BASE,MEMORY}" [shape=oval, color=palegreen3]; // Mainline Defence
  226. "GRKERNSEC_RANDSTRUCT" [shape=oval, color=lightgrey]; // Commercial Defence
  227. "PAX_RANDKSTACK" [shape=oval, color=lightgrey]; // Commercial Defence
  228. "PAX_LATENT_ENTROPY" [shape=oval, color=lightgrey]; // Commercial Defence
  229. }
  230. subgraph cluster_info_exposure_mitigations {
  231. label="";
  232. rank=same;
  233. style="dashed";
  234. margin=15;
  235. "X86: X86_INTEL_UMIP" [shape=oval, color=palegreen3]; // Mainline Defence
  236. "kptr_restrict" [shape=oval, color=palegreen3]; // Mainline Defence
  237. "GRKERNSEC_HIDESYM" [shape=oval, color=lightgrey]; // Commercial Defence
  238. "GRKERNSEC_DMESG" [shape=oval, color=lightgrey]; // Commercial Defence
  239. }
  240. subgraph cluster_freelist_hardening {
  241. label="";
  242. rank=same;
  243. style="invis";
  244. margin=15;
  245. "SLAB_FREELIST_HARDENED" [shape=oval, color=palegreen3]; // Mainline Defence
  246. grsecurity_hardened_freelist [label="by default in grsecurity", shape=oval, color=lightgrey]; // Commercial Defence
  247. }
  248. subgraph cluster_stack_init {
  249. label="";
  250. rank=same;
  251. style="solid"; // Similar functionality
  252. margin=15;
  253. "INIT_STACK_ALL_ZERO" [shape=oval, color=palegreen3]; // Mainline Defence
  254. "PAX_MEMORY_STRUCTLEAK" [shape=oval, color=lightgrey]; // Commercial Defence
  255. }
  256. subgraph cluster_heap_erasing {
  257. label="";
  258. rank=same;
  259. style="dashed";
  260. margin=15;
  261. "Heap free() Poisoning" [shape=oval, color=black, style=solid]; // Generic Defence Technique
  262. "init_on_alloc" [shape=oval, color=palegreen3]; // Mainline Defence
  263. }
  264. subgraph cluster_oob_detection {
  265. label="";
  266. rank=same;
  267. style="dashed";
  268. margin=15;
  269. node [shape=oval, color=palegreen3]; // Mainline Defence
  270. "FORTIFY_SOURCE";
  271. "UBSAN_BOUNDS";
  272. }
  273. // Defences: child nodes
  274. {
  275. rank=same;
  276. // Mainline Defences
  277. node [shape=oval, color=palegreen3];
  278. "REFCOUNT_FULL";
  279. "HARDENED_USERCOPY";
  280. "PAGE_POISONING";
  281. "VMAP_STACK";
  282. "THREAD_INFO_IN_TASK";
  283. "RANDSTRUCT";
  284. "STRUCTLEAK_BYREF_ALL";
  285. "LATENT_ENTROPY";
  286. "__ro_after_init";
  287. "SECURITY_DMESG_RESTRICT";
  288. "ARM: CPU_SW_DOMAIN_PAN";
  289. "ARM: ARM64_SW_TTBR0_PAN";
  290. "STATIC_USERMODEHELPER";
  291. "slub_debug=P"; // object and padding poisoning
  292. "init_on_free";
  293. "STACKLEAK";
  294. // Out-of-tree Defences
  295. node [shape=oval, color=cornflowerblue];
  296. "RANDOMIZE_KSTACK_OFFSET_DEFAULT";
  297. "Clang CFI";
  298. // Commercial Defences
  299. node [shape=oval, color=lightgrey];
  300. "PAX_RAP";
  301. "PAX_MEMORY_SANITIZE";
  302. // HW Defences
  303. node [shape=oval, color=aquamarine];
  304. "ARM: ARM64_PTR_AUTH + ARM64_BTI_KERNEL" [fontsize=10];
  305. "X86: Intel CET";
  306. }
  307. // Defences relations
  308. edge [style=dotted, arrowhead=none, dir=none, headport=_, tailport=_];
  309. "Clang CFI":e -> "Control Flow Integrity":w;
  310. "PAX_RAP":e -> "Control Flow Integrity":w;
  311. "ARM: ARM64_PTR_AUTH + ARM64_BTI_KERNEL":e -> "Control Flow Integrity":w;
  312. "X86: Intel CET":e -> "Control Flow Integrity":w;
  313. "REFCOUNT_FULL":e -> "PAX_REFCOUNT":w;
  314. "HARDENED_USERCOPY":e -> "PAX_USERCOPY":w;
  315. "PAGE_POISONING" -> "PAX_MEMORY_SANITIZE";
  316. "VMAP_STACK":e -> "GRKERNSEC_KSTACKOVERFLOW":w;
  317. "THREAD_INFO_IN_TASK":e -> "GRKERNSEC_KSTACKOVERFLOW":w;
  318. "RANDSTRUCT":e -> "GRKERNSEC_RANDSTRUCT";
  319. "STRUCTLEAK_BYREF_ALL":e -> "PAX_MEMORY_STRUCTLEAK":w;
  320. "LATENT_ENTROPY":e -> "PAX_LATENT_ENTROPY";
  321. "__ro_after_init":e -> "__read_only";
  322. "SECURITY_DMESG_RESTRICT":e -> "GRKERNSEC_DMESG";
  323. "STACKLEAK":e -> "PAX_MEMORY_STACKLEAK":w;
  324. "ARM: CPU_SW_DOMAIN_PAN":e -> "SMAP/PAN":w;
  325. "ARM: ARM64_SW_TTBR0_PAN":e -> "SMAP/PAN":w;
  326. "STATIC_USERMODEHELPER":e -> grsecurity_hardened_usermodehelper;
  327. "SLAB_FREELIST_HARDENED" -> grsecurity_hardened_freelist [constraint=false];
  328. "PAX_MEMORY_SANITIZE":e -> "Heap free() Poisoning":w [style=filled];
  329. "slub_debug=P":e -> "Heap free() Poisoning":w [style=filled];
  330. "init_on_free" -> "Heap free() Poisoning":w [style=filled];
  331. "RANDOMIZE_KSTACK_OFFSET_DEFAULT":e -> "PAX_RANDKSTACK";
  332. // Vulnerabilities and Exploitation Techniques
  333. {
  334. rank=same;
  335. // Vulnerabilities
  336. node [shape=box, color=pink];
  337. "Stack Depth Overflow (CWE-674,?)" [URL="https://cwe.mitre.org/data/definitions/674.html"];
  338. "Int Overflow/Underflow (CWE-190/191)" [URL="https://cwe.mitre.org/data/definitions/190.html"];
  339. "Use-After-Free (CWE-416)" [URL="https://cwe.mitre.org/data/definitions/416.html"];
  340. "Double Free (CWE-415)" [URL="https://cwe.mitre.org/data/definitions/415.html"];
  341. "Race Condition (CWE-362)" [URL="https://cwe.mitre.org/data/definitions/362.html"];
  342. "Undefined Behaviour (CWE-758)" [URL="https://cwe.mitre.org/data/definitions/758.html"];
  343. "Type Confusion (CWE-843)" [URL="https://cwe.mitre.org/data/definitions/843.html"];
  344. "Double Fetch (CWE-367)" [URL="https://cwe.mitre.org/data/definitions/367.html"];
  345. "Memory Leak (CWE-401)" [URL="https://cwe.mitre.org/data/definitions/401.html"];
  346. // Exploitation Techniques
  347. node [shape=box, color=gold];
  348. "Metadata Corruption";
  349. "Allocator Data Corruption";
  350. "Heap Layout Control";
  351. "Finding Kernel Objects";
  352. "JIT Abuse";
  353. "WX Area Abuse";
  354. "Changing Kernel Image";
  355. "Bad Module Loading";
  356. "Unbalanced set_fs()";
  357. "'ops' Structures Overwrite";
  358. }
  359. subgraph cluster_oob {
  360. label="";
  361. rank=same;
  362. style="dashed";
  363. margin=25;
  364. // Vulnerabilities
  365. node [shape=box, color=pink];
  366. "Heap Out-of-Bounds Access (CWE-122,119)" [URL="https://cwe.mitre.org/data/definitions/122.html"];
  367. "Stack Out-of-Bounds Access (CWE-121,119)" [URL="https://cwe.mitre.org/data/definitions/121.html"];
  368. "Global Variable Out-of-Bounds Access (CWE-?,119)" [fontsize=12, margin="0.04", URL="https://cwe.mitre.org/data/definitions/119.html"];
  369. }
  370. subgraph cluster_userspace_access {
  371. label="";
  372. rank=same;
  373. style="dashed";
  374. margin=25;
  375. // Vulnerability
  376. "NULL Pointer Dereference (CWE-476)" [shape=box, color=pink, URL="https://cwe.mitre.org/data/definitions/476.html"];
  377. // Exploitation Technique
  378. "Userspace Data Access" [shape=box, color=gold];
  379. }
  380. subgraph cluster_control_flow_hijack {
  381. label=" Control Flow Hijack Techniques ";
  382. fontsize=18;
  383. rank=same;
  384. style="dashed";
  385. margin=25;
  386. node [shape=box, color=gold]; // Exploitation Techniques
  387. subgraph cluster_with_rop {
  388. label="";
  389. margin=25;
  390. "ROP";
  391. "ret2usr + ROP";
  392. "ret2dir + ROP";
  393. }
  394. "ret2usr";
  395. "ret2dir";
  396. "Return Address Overwrite";
  397. }
  398. subgraph cluster_info_exposures {
  399. label="";
  400. rank=same;
  401. style="dashed";
  402. margin=25;
  403. node [shape=box, color=pink]; // Vulnerabilities
  404. "Info Exposure (CWE-200)" [URL="https://cwe.mitre.org/data/definitions/200.html"];
  405. "Uninitialized Memory Usage (CWE-908)" [URL="https://cwe.mitre.org/data/definitions/908.html"];
  406. }
  407. subgraph cluster_hang {
  408. label="";
  409. rank=same;
  410. style="invis";
  411. margin=25;
  412. node [shape=box, color=pink]; // Vulnerabilities
  413. "Deadlock (CWE-833)" [URL="https://cwe.mitre.org/data/definitions/833.html"];
  414. "Infinite Loop (CWE-835)" [URL="https://cwe.mitre.org/data/definitions/835.html"];
  415. }
  416. subgraph cluster_transient_execution_vulnerabilities {
  417. label="Transient Execution Vulnerabilities \n (Covert Channels, CWE-514)";
  418. URL="https://cwe.mitre.org/data/definitions/514.html";
  419. rank=same;
  420. fontsize=18;
  421. style="solid"; // CWE-514
  422. margin=25;
  423. node [shape=box, color=pink]; // Vulnerabilities
  424. subgraph cluster_v1 {
  425. label="";
  426. style="solid";
  427. margin=25;
  428. "Spectre v1 / BCB / CVE-2017-5753";
  429. "Spectre v1.1 / BCBS / CVE-2018-3693";
  430. "Spectre v1 swapgs / CVE-2019-1125";
  431. }
  432. subgraph cluster_v2 {
  433. label="";
  434. style="solid";
  435. margin=25;
  436. "Spectre v2 / BTI / CVE-2017-5715";
  437. "Spectre RSB / CVE-2018-15572";
  438. }
  439. "Spectre v3 / RDCL / CVE-2017-5754 / Meltdown";
  440. "Spectre v3a / RSRE / CVE-2018-3640";
  441. "Spectre v4 / SSB / CVE-2018-3639";
  442. "L1TF / CVE-2018-3620,3646 / Foreshadow";
  443. "Lazy FP State Restore / CVE-2018-3665";
  444. subgraph cluster_mds_all {
  445. label="MDS (aka RIDL)";
  446. style="solid";
  447. margin=25;
  448. subgraph cluster_mds {
  449. label="";
  450. "MFBDS / CVE-2018-12130 / ZombieLoad";
  451. "MLPDS / CVE-2018-12127";
  452. "MDSUM / CVE-2019-11091";
  453. "TAA / CVE-2019-11135 / ZombieLoad v2 ";
  454. "MSBDS / CVE-2018-12126 / Fallout";
  455. "VRS / CVE-2020-0548";
  456. }
  457. "SRBDS / CVE-2020-0543 / CROSSTalk";
  458. "L1DES / CVE-2020-0549 / CacheOut";
  459. "Snoop / CVE-2020-0550";
  460. }
  461. }
  462. // Bug Detection Mechanisms
  463. {
  464. rank=same;
  465. node [shape=octagon, color=mediumpurple];
  466. "UBSAN";
  467. "KMSAN";
  468. "KTSAN";
  469. "KCSAN";
  470. "KMEMLEAK";
  471. "PROVE_LOCKING";
  472. "DEBUG_ATOMIC_SLEEP";
  473. "LOCKUP_DETECTOR";
  474. "WQ_WATCHDOG";
  475. "slub_debug=F"; // sanity checks
  476. "slub_debug=Z"; // red zoning
  477. }
  478. subgraph cluster_uaf_detection {
  479. label="";
  480. rank=same;
  481. style="dashed";
  482. margin=25;
  483. node [shape=octagon, color=mediumpurple]; // Bug Detection Mechanisms
  484. "KASAN_GENERIC";
  485. "KFENCE";
  486. }
  487. // Relations: Bug Detection Mechanisms vs Vulnerabilities
  488. edge [style=solid, arrowhead=normal, dir=back, headport=_, tailport=_];
  489. "Global Variable Out-of-Bounds Access (CWE-?,119)":e -> "KASAN_GENERIC":w [ltail=cluster_oob];
  490. "Use-After-Free (CWE-416)":e -> "KFENCE" [lhead=cluster_uaf_detection];
  491. "Double Free (CWE-415)":e -> "KASAN_GENERIC" [lhead=cluster_uaf_detection];
  492. "Undefined Behaviour (CWE-758)":e -> "UBSAN";
  493. "Int Overflow/Underflow (CWE-190/191)":e -> "UBSAN";
  494. "Uninitialized Memory Usage (CWE-908)":e -> "KMSAN" [ltail=cluster_info_exposures];
  495. "Race Condition (CWE-362)":e -> "KTSAN";
  496. "Race Condition (CWE-362)":e -> "KCSAN";
  497. "Memory Leak (CWE-401)":e -> "KMEMLEAK";
  498. "Deadlock (CWE-833)" -> "PROVE_LOCKING":w;
  499. "Deadlock (CWE-833)" -> "DEBUG_ATOMIC_SLEEP":w;
  500. "Infinite Loop (CWE-835)" -> "LOCKUP_DETECTOR":w;
  501. "Infinite Loop (CWE-835)" -> "WQ_WATCHDOG":w;
  502. "Heap Out-of-Bounds Access (CWE-122,119)":e -> "slub_debug=Z":w;
  503. "Double Free (CWE-415)" -> "slub_debug=F";
  504. "Allocator Data Corruption" -> "slub_debug=F";
  505. "Heap Out-of-Bounds Access (CWE-122,119)":e -> "KFENCE":w;
  506. // Relations: Defences vs Vulnerabilities and Exploitation Techniques
  507. edge [style=solid, arrowhead=normal, dir=forward, headport=_, tailport=_];
  508. "GRKERNSEC_KSTACKOVERFLOW":e -> "Stack Depth Overflow (CWE-674,?)";
  509. "PAX_MEMORY_STACKLEAK":e -> "Stack Depth Overflow (CWE-674,?)";
  510. "SCHED_STACK_END_CHECK":e -> "Stack Depth Overflow (CWE-674,?)";
  511. "PAX_USERCOPY":e -> "Heap Out-of-Bounds Access (CWE-122,119)":w;
  512. "ARM: KASAN_HW_TAGS with ARM64_MTE":e -> "Heap Out-of-Bounds Access (CWE-122,119)":w;
  513. "FORTIFY_SOURCE":e -> "Heap Out-of-Bounds Access (CWE-122,119)" [ltail=cluster_oob_detection, lhead=cluster_oob];
  514. "PAX_USERCOPY":e -> "Stack Out-of-Bounds Access (CWE-121,119)":w;
  515. "PAX_REFCOUNT":e -> "Int Overflow/Underflow (CWE-190/191)";
  516. "PAX_SIZE_OVERFLOW":e -> "Int Overflow/Underflow (CWE-190/191)";
  517. "PAX_MEMORY_STACKLEAK":e -> "Uninitialized Memory Usage (CWE-908)" [lhead=cluster_info_exposures];
  518. "PAX_MEMORY_STRUCTLEAK":e -> "Uninitialized Memory Usage (CWE-908)" [ltail=cluster_stack_init, lhead=cluster_info_exposures];
  519. "Heap free() Poisoning":e -> "Uninitialized Memory Usage (CWE-908)" [ltail=cluster_heap_erasing, lhead=cluster_info_exposures];
  520. "Heap free() Poisoning":s -> "Use-After-Free (CWE-416)" [ltail=cluster_heap_erasing];
  521. "ARM: KASAN_HW_TAGS with ARM64_MTE":e -> "Use-After-Free (CWE-416)":w;
  522. "SLAB_FREELIST_HARDENED":e -> "Double Free (CWE-415)";
  523. "ARM: KASAN_HW_TAGS with ARM64_MTE":e -> "Double Free (CWE-415)":w;
  524. "kptr_restrict":e -> "Info Exposure (CWE-200)":w [ltail=cluster_info_exposure_mitigations];
  525. "DEBUG_{LIST,SG,CREDENTIALS,NOTIFIERS,VIRTUAL}":e -> "Metadata Corruption";
  526. "BUG_ON_DATA_CORRUPTION":e -> "Metadata Corruption";
  527. "PROTECTABLE_MEMORY":e -> "Metadata Corruption";
  528. grsecurity_hardened_usermodehelper:e -> "Metadata Corruption";
  529. "LKRG":e -> "Metadata Corruption";
  530. grsecurity_hardened_freelist:e -> "Allocator Data Corruption";
  531. "SLAB_FREELIST_HARDENED":e -> "Allocator Data Corruption";
  532. "__read_only":e -> "'ops' Structures Overwrite" [ltail=cluster_ro];
  533. "SLAB_FREELIST_RANDOM":e -> "Heap Layout Control";
  534. "slab_nomerge":e -> "Heap Layout Control";
  535. "SHUFFLE_PAGE_ALLOCATOR":e -> "Heap Layout Control";
  536. "unprivileged_userfaultfd=0":e -> "Heap Layout Control";
  537. "AUTOSLAB":e -> "Heap Layout Control";
  538. "STACKPROTECTOR":e -> "Return Address Overwrite":w;
  539. "ARM: SHADOW_CALL_STACK":e -> "Return Address Overwrite":w;
  540. "Control Flow Integrity":e -> "Return Address Overwrite":w;
  541. "Control Flow Integrity":e -> "ROP" [lhead=cluster_with_rop];
  542. "PAX_KERNEXEC":e -> "ret2usr":w;
  543. "X86: pti=on (PAGE_TABLE_ISOLATION)":e -> "ret2usr":w [ltail=cluster_pti];
  544. "SMEP/PXN":e -> "ret2usr":w;
  545. "SMAP/PAN":s -> "ret2usr":w [ltail=cluster_smap_pan_uderef];
  546. "SMAP/PAN":s -> "Userspace Data Access" [ltail=cluster_smap_pan_uderef, lhead=cluster_userspace_access];
  547. "DEFAULT_MMAP_MIN_ADDR=65536":e -> "NULL Pointer Dereference (CWE-476)":w;
  548. "SMAP/PAN":s -> "ret2usr + ROP":sw [ltail=cluster_smap_pan_uderef];
  549. "PAX_KERNEXEC":e -> "ret2dir";
  550. "XPFO":e -> "ret2dir";
  551. "XPFO":e -> "ret2dir + ROP";
  552. "PAX_RANDKSTACK":e -> "Finding Kernel Objects" [ltail=cluster_layout_randomization];
  553. "GRKERNSEC_JIT_HARDEN":e -> "JIT Abuse";
  554. "bpf_jit_harden":e -> "JIT Abuse";
  555. "PAX_KERNEXEC":e -> "WX Area Abuse";
  556. "STRICT_{KERNEL,MODULE}_RWX":e -> "WX Area Abuse";
  557. "DEBUG_WX":e -> "WX Area Abuse";
  558. "ARM: RODATA_FULL_DEFAULT_ENABLED":e -> "WX Area Abuse";
  559. "LOCKDOWN_LSM":e -> "Changing Kernel Image";
  560. "LKRG":e -> "Changing Kernel Image";
  561. "GRKERNSEC_MODHARDEN":e -> "Bad Module Loading";
  562. "MODULE_SIG*":e -> "Bad Module Loading";
  563. "SECURITY_LOADPIN":e -> "Bad Module Loading";
  564. "request_module_cap()":e -> "Bad Module Loading";
  565. "LDISC_AUTOLOAD is not set":e -> "Bad Module Loading";
  566. "TIF_FSCHECK flag":e -> "Unbalanced set_fs()";
  567. "mitigations=auto,nosmt":e -> "Spectre v3a / RSRE / CVE-2018-3640" [ltail=cluster_cwe514_mitigations, lhead=cluster_transient_execution_vulnerabilities]
  568. "RESPECTRE":e -> "Spectre v1 / BCB / CVE-2017-5753" [ltail=cluster_v1_mitigations, lhead=cluster_v1];
  569. "X86: spectre_v2=on (RETPOLINE)":e -> "Spectre v2 / BTI / CVE-2017-5715" [ltail=cluster_v2_mitigations, lhead=cluster_v2];
  570. "X86: pti=on (PAGE_TABLE_ISOLATION)":e -> "Spectre v3 / RDCL / CVE-2017-5754 / Meltdown":w [ltail=cluster_pti];
  571. "X86: spec_store_bypass_disable=on":e -> "Spectre v4 / SSB / CVE-2018-3639" [ltail=cluster_ssb_mitigations];
  572. "X86: l1tf=full,force":e -> "L1TF / CVE-2018-3620,3646 / Foreshadow":w;
  573. "X86: l1tf=full,force":e -> "L1DES / CVE-2020-0549 / CacheOut":w;
  574. "X86: l1tf=full,force":e -> "Snoop / CVE-2020-0550":w;
  575. "X86: mds=full,nosmt":e -> "MSBDS / CVE-2018-12126 / Fallout" [lhead=cluster_mds];
  576. }