File size: 8,613 Bytes
10e1ea9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/mjbommar/linux-ioctl-census-paper/data/schema.json",
  "title": "Linux IOCTL Census -- public structural tier",
  "description": "JSON-Schema describing the PUBLIC structural release tier of the Linux IOCTL Census. Mirrors the export allowlist in the engine (tools/linux_ioctl/export_census_release.py) and the DuckDB DDL in bot/linux_ioctl_kb/schema.py. Only tables/columns derivable from already-public kernel source appear here; the targeting tier (taint_sinks, handler_enrichment, bugclass_hits, findings, functions, call_edges, extraction_runs) is withheld and MUST NOT appear. Schema-compatible with the Windows IOCTL Census: identical table and column names so the corpora are query-compatible. Linux concession: every *_va column is a stable 64-bit id (hash of the kg USR), and human location lives in companion name/file/line columns with loc_kind in {symbol, site}; imagebase is 0.",
  "type": "object",
  "additionalProperties": false,
  "required": ["kb_meta", "binaries", "dispatchers", "ioctl_codes", "handlers", "gates"],
  "properties": {
    "kb_meta": {
      "type": "array",
      "description": "Key/value provenance. Includes schema_version and release_tier=public-structural.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["key", "value"],
        "properties": {
          "key": {"type": "string"},
          "value": {"type": "string"}
        }
      }
    },
    "binaries": {
      "type": "array",
      "description": "One row per analyzed module. 'binaries' name retained for query-compatibility with the Windows KB; on Linux a row is a kernel module/built-in source unit.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sha256", "name"],
        "properties": {
          "sha256": {"type": "string", "description": "Content hash, primary key."},
          "name": {"type": "string", "description": "Module name (e.g. ipmi_devintf)."},
          "corpus": {"type": ["string", "null"], "description": "Corpus tag for the extraction run."},
          "build": {"type": ["string", "null"], "description": "Build identifier (kernel tag/config)."},
          "arch": {"type": ["string", "null"], "description": "Architecture (e.g. x86_64)."},
          "driver_type": {"type": ["string", "null"], "enum": ["char_dev", "blockdev", "sysfs", "proc", null], "description": "Surface class of the module's registration."},
          "device_names": {"type": ["array", "null"], "items": {"type": "string"}, "description": "Device node names where recovered (node DAC coverage is partial; see data dictionary)."},
          "device_sddl": {"type": ["string", "null"], "description": "Gate summary. On Linux holds 'caps:CAP_...' when a hard init-ns capability gate is on the ioctl path."},
          "user_reachable": {"type": ["boolean", "null"], "description": "Static verdict: ioctl path has no hard init-ns capability gate (heuristic; see PLAN node-DAC caveat)."},
          "in_threat_model": {"type": ["boolean", "null"], "description": "True unless the module is out of the kernel's documented threat model (e.g. staging)."},
          "out_of_model_reason": {"type": ["string", "null"], "description": "Why a module is out of model (e.g. 'staging')."},
          "n_dispatchers": {"type": ["integer", "null"]},
          "n_codes": {"type": ["integer", "null"]},
          "n_handlers": {"type": ["integer", "null"]},
          "surface_recovered": {"type": ["boolean", "null"], "description": "True if a dispatch surface was recovered for this module."},
          "rel_path": {"type": ["string", "null"], "description": "Tree-relative source path (e.g. drivers/char/ipmi/ipmi_devintf.c)."},
          "subtree": {"type": ["string", "null"], "description": "Coverage subtree label (e.g. drivers-misc)."},
          "staging": {"type": ["boolean", "null"], "description": "True if under drivers/staging."}
        }
      }
    },
    "dispatchers": {
      "type": "array",
      "description": "One row per ioctl dispatch entry point (file_operations.unlocked_ioctl / compat_ioctl / proc_ops.proc_ioctl etc.).",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sha256", "dispatcher_va"],
        "properties": {
          "sha256": {"type": "string"},
          "dispatcher_va": {"type": "integer", "description": "Stable 64-bit id (hash of kg USR), NOT a load address. imagebase=0."},
          "role": {"type": ["string", "null"], "description": "Dispatcher role classification."},
          "name": {"type": ["string", "null"], "description": "Function symbol name."},
          "file": {"type": ["string", "null"]},
          "line": {"type": ["integer", "null"]},
          "ops_struct": {"type": ["string", "null"], "description": "Owning ops struct (e.g. file_operations)."},
          "ops_field": {"type": ["string", "null"], "enum": ["unlocked_ioctl", "compat_ioctl", "ioctl", "proc_ioctl", null], "description": "Ops-struct field the dispatcher fills."}
        }
      }
    },
    "ioctl_codes": {
      "type": "array",
      "description": "One row per decoded ioctl command code. Decoded via the _IOC resolver: access direction, _IOC_TYPE, _IOC_NR, _IOC_SIZE, arg-struct type.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sha256", "dispatcher_va", "code"],
        "properties": {
          "sha256": {"type": "string"},
          "dispatcher_va": {"type": "integer"},
          "code": {"type": "integer", "description": "The 32-bit ioctl command number."},
          "device_type": {"type": ["integer", "null"], "description": "_IOC_TYPE (the magic byte)."},
          "method": {"type": ["string", "null"], "description": "Windows-schema parity field; usually null on Linux."},
          "access": {"type": ["string", "null"], "enum": ["r", "w", "rw", "none", null], "description": "_IOC_DIR decoded."},
          "function_code": {"type": ["integer", "null"], "description": "_IOC_NR (the command ordinal)."},
          "cmd_symbol": {"type": ["string", "null"], "description": "The macro/symbol the case label resolved from (e.g. FS_IOC_GETFLAGS)."},
          "ioc_size": {"type": ["integer", "null"], "description": "_IOC_SIZE in bytes."},
          "arg_struct_type": {"type": ["string", "null"], "description": "Decoded argument struct type where recoverable."}
        }
      }
    },
    "handlers": {
      "type": "array",
      "description": "One row per ioctl command handler (the per-command body reached from a dispatcher).",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sha256", "handler_va"],
        "properties": {
          "sha256": {"type": "string"},
          "handler_va": {"type": "integer", "description": "Stable 64-bit id (hash of kg USR)."},
          "name": {"type": ["string", "null"]},
          "reachable": {"type": ["boolean", "null"], "description": "Reachable from a dispatcher within the closure depth bound."},
          "ioctl_distance": {"type": ["integer", "null"], "description": "Call-graph distance from the dispatcher."},
          "file": {"type": ["string", "null"]},
          "line": {"type": ["integer", "null"]}
        }
      }
    },
    "gates": {
      "type": "array",
      "description": "One row per permission gate on a handler's path. Capability checks, LSM hooks, f_mode/field checks, fd lookups.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["sha256", "handler_va", "gate_kind"],
        "properties": {
          "sha256": {"type": "string"},
          "handler_va": {"type": "integer"},
          "gate_kind": {"type": "string", "enum": ["cap_check", "lsm_hook", "field_check", "fd_lookup", "protocol_state_check"], "description": "The gate class."},
          "cap_constant": {"type": ["string", "null"], "description": "The CAP_* constant for cap_check gates."},
          "mask_constant": {"type": ["string", "null"], "description": "The f_mode / field mask for field_check gates."},
          "is_hard_gate": {"type": ["boolean", "null"], "description": "True if the gate hard-blocks unprivileged reach in init-ns."},
          "gate_ns": {"type": ["string", "null"], "description": "Namespace the gate is evaluated in."},
          "file": {"type": ["string", "null"]},
          "line": {"type": ["integer", "null"]}
        }
      }
    }
  }
}