Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
b96d171
KRN-1117: Add caller-owned stack trace fetch helper
May 26, 2026
0ffe344
KRN-1117: Add stackdepot files to MAINTAINERS
May 27, 2026
90214d6
KRN-1117: Clarify stack_depot_fetch_into contract
May 27, 2026
0becc55
KRN-1117: Stop page_owner reading stack entries directly
May 27, 2026
d328e21
KRN-1117: Store page_owner stack handles in stack list
May 27, 2026
3a5759e
KRN-1117: Hide page_owner stack count internals
May 28, 2026
42a90b1
KRN-1117: Keep stackdepot record layout private
May 28, 2026
75f1a4d
KRN-1117: Add stackdepot frame compression hooks
May 28, 2026
250c3b7
KRN-1117: Warn on stackdepot count underflow
May 28, 2026
03f8f0a
KRN-1117: Compress x86-64 stackdepot frames
May 28, 2026
8f7a08f
KRN-1117: Add stackdepot frame-run encoding helpers
May 29, 2026
fe07f92
KRN-1117: Tighten page_owner stack display accounting
May 29, 2026
dd85540
KRN-1117: Materialize stackdepot trie frame runs
May 29, 2026
83e1828
KRN-1117: Add stackdepot trie child arrays
May 29, 2026
78463e7
KRN-1117: Harden stackdepot trie helper contracts
May 29, 2026
60a1fa0
KRN-1117: Match stackdepot trie node prefixes
Jun 1, 2026
edfe0dd
KRN-1117: Build stackdepot trie append chains
Jun 1, 2026
2fe6b7a
KRN-1117: Publish stackdepot trie append chains
Jun 1, 2026
25ce568
KRN-1117: Order stackdepot trie append publication
Jun 1, 2026
3bc1633
KRN-1117: Classify stackdepot trie lookup steps
Jun 1, 2026
2663c87
KRN-1117: Harden stackdepot trie lookup prep
Jun 1, 2026
2d85c61
KRN-1117: Add stackdepot trie append insertion
Jun 2, 2026
cd0e400
KRN-1117: Add stackdepot trie descend insertion
Jun 2, 2026
a245616
KRN-1117: Add stackdepot maintainer routing
Jun 2, 2026
0040433
KRN-1117: Clarify stackdepot prep invariants
Jun 2, 2026
0569363
KRN-1117: Harden stackdepot prep helper contracts
Jun 2, 2026
2e18d10
KRN-1117: Add stackdepot trie promotion
Jun 3, 2026
5bf3754
KRN-1117: Preserve children during trie promotion
Jun 3, 2026
2f1fe8c
KRN-1117: Add stackdepot trie node slicing
Jun 3, 2026
c78948b
KRN-1117: Add stackdepot trie split child arrays
Jun 3, 2026
bf4d8ff
KRN-1117: Add stackdepot trie split tail planning
Jun 3, 2026
91c3fa7
KRN-1117: Add stackdepot trie split precheck
Jun 3, 2026
546033d
KRN-1117: Add stackdepot trie split subtree
Jun 3, 2026
677886e
KRN-1117: Harden stackdepot trie split precheck
Jun 3, 2026
b9469d6
KRN-1117: Add stackdepot trie split insertion
Jun 3, 2026
2658c72
KRN-1117: Add stackdepot trie leaf lookup
Jun 4, 2026
84fe194
KRN-1117: Add stackdepot trie pre-publish hook
Jun 4, 2026
feb01a3
KRN-1117: Add stackdepot trie insertion planning
Jun 4, 2026
8e6de92
KRN-1117: Add stackdepot trie handle namespace
Jun 4, 2026
b3e2e2a
KRN-1117: Fix stackdepot trie COW leaf lookup
Jun 4, 2026
b69ba25
KRN-1117: Clarify page_owner marker reporting
Jun 4, 2026
fa13111
KRN-1117: Add stackdepot trie side table
Jun 4, 2026
946ce65
KRN-1117: Harden stackdepot trie COW publication
Jun 5, 2026
e6f8b98
KRN-1117: Add stackdepot trie side-table prepare
Jun 5, 2026
a5d195c
KRN-1117: Add stackdepot trie pool sizing
Jun 5, 2026
403bd56
KRN-1117: Align stackdepot trie pool allocations
Jun 5, 2026
6f19677
KRN-1117: Add stackdepot trie pool carve helper
Jun 5, 2026
20027ae
KRN-1117: Add stackdepot trie pool batch carve
Jun 5, 2026
5628485
KRN-1117: Clarify page_owner count transition
Jun 5, 2026
3c2ee85
KRN-1117: Add stackdepot trie pool prealloc
Jun 8, 2026
8c8c0bc
KRN-1117: Add stackdepot trie pool rollover
Jun 8, 2026
72e99db
KRN-1117: Add stackdepot trie allocation rollback
Jun 8, 2026
258129d
KRN-1117: Add stackdepot trie transaction IDs
Jun 8, 2026
8c2112d
KRN-1117: Add stackdepot trie allocation reserve
Jun 8, 2026
e8820ad
KRN-1117: Add stackdepot trie allocation commit
Jun 8, 2026
8248768
KRN-1117: Add stackdepot trie allocation insert
Jun 8, 2026
4aeddae
KRN-1117: Serialize stackdepot trie allocation insert
Jun 8, 2026
0ee779c
KRN-1117: Add stackdepot trie feature flag
Jun 8, 2026
a405d3d
KRN-1117: Remove stackdepot trie feature flag
Jun 9, 2026
69b854a
KRN-1117: Add stackdepot trie allocation planning
Jun 9, 2026
3720e5f
KRN-1117: Add stackdepot trie allocation workspace
Jun 9, 2026
f93eb03
KRN-1117: Add stackdepot trie workspace insert
Jun 9, 2026
237bf20
KRN-1117: Add stackdepot trie allocation prealloc
Jun 9, 2026
9908ea6
KRN-1117: Add stackdepot trie save miss
Jun 9, 2026
f693df3
KRN-1117: Add stackdepot trie save helper
Jun 9, 2026
a1afe16
KRN-1117: Add stackdepot trie handle fetch helper
Jun 9, 2026
7e823e0
KRN-1117: Re-add stackdepot trie feature flag
Jun 9, 2026
76c26db
KRN-1117: Materialize stackdepot trie handles directly
Jun 9, 2026
c030eaf
KRN-1117: Route stackdepot fetch_into trie handles
Jun 10, 2026
7a8781f
KRN-1117: Add stackdepot trie materialization slots
Jun 10, 2026
2cd8dac
KRN-1117: Publish trie materialization slots locklessly
Jun 10, 2026
ed8ae1f
KRN-1117: Add stackdepot trie frame walker
Jun 10, 2026
8ee1a71
KRN-1117: Add stackdepot trie materialize helper
Jun 10, 2026
c76f251
KRN-1117: Size stackdepot trie materialization buffers
Jun 10, 2026
aff8685
KRN-1117: Add stackdepot trie materialized records
Jun 10, 2026
5d51a39
KRN-1117: Add stackdepot trie materialization cache
Jun 10, 2026
b94f73b
KRN-1117: Route stackdepot fetch to trie cache
Jun 10, 2026
0a86543
KRN-1117: Count stackdepot trie materialization bytes
Jun 11, 2026
dd3bf3e
KRN-1117: Add a locked stackdepot trie save helper
Jun 11, 2026
12d3d49
KRN-1117: Initialize stackdepot trie side table
Jun 11, 2026
a2ecf7b
KRN-1117: Initialize stackdepot trie workspace
Jun 11, 2026
b60ebcb
KRN-1117: Gate stackdepot trie allocation readiness
Jun 11, 2026
2a085a4
KRN-1117: Print stackdepot trie handles directly
Jun 11, 2026
ab20790
KRN-1117: Route stackdepot saves to trie storage
Jun 11, 2026
2c373ef
KRN-1117: Migrate persistent stackdepot fetches to copy-out
Jun 12, 2026
4007005
KRN-1117: Print stackdepot trie frames in stack order
Jun 12, 2026
50a0c84
KRN-1117: Stress stackdepot trie saves concurrently
Jun 15, 2026
72761b3
KRN-1117: Make stackdepot trie side table sparse
Jun 15, 2026
d8774f1
KRN-1117: Reuse retired stackdepot trie child arrays
Jun 15, 2026
222556b
KRN-1117: Assert x86 stackdepot frame prefix is nonzero
Jun 16, 2026
3358ba7
KRN-1117: Reuse retired stackdepot trie nodes
Jun 16, 2026
e356b33
KRN-1117: Harden arm64 stackdepot prefix scan
Jun 16, 2026
0df12cc
KRN-1117: Reduce stackdepot trie pool usage
Jun 16, 2026
961acf0
KRN-1117: Warn on direct fetch of trie stackdepot handles
Jun 17, 2026
3fddeba
KRN-1117: Clean up stackdepot save control flow
Jun 17, 2026
6f255eb
KRN-1117: Close stackdepot trie save-path gaps
Jun 17, 2026
428f519
KRN-1117: Preserve page owner handles without stack list nodes
Jun 17, 2026
88ac7ba
KRN-1117: Harden stackdepot trie teardown ordering
Jun 17, 2026
b8ee429
KRN-1117: Initialize stackdepot trie on runtime enable
Jun 18, 2026
8ca6e19
Merge greg/linux-6.18.y into KRN-1117 stackdepot port
Jun 18, 2026
4f5a99b
KRN-1117: Drop stackdepot MAINTAINERS entry
Jun 18, 2026
5bdac6c
KRN-1117: Reduce KMSAN stackdepot report stack usage
Jun 18, 2026
9fb876c
KRN-1117: Clarify stackdepot trie review details
Jun 18, 2026
842163f
KRN-1117: Read page owner threshold consistently
Jun 18, 2026
0f1de1c
KRN-1117: Clarify page owner count marker comment
Jun 18, 2026
6d9ee43
KRN-1117: Clarify stackdepot trie buffer contracts
Jun 18, 2026
c435880
KRN-1117: Drop test-only stackdepot pool carve helper
Jun 18, 2026
0c53020
KRN-1117: Simplify stackdepot trie internals
Jun 19, 2026
8ab08c2
KRN-1117: Clarify stackdepot caller assumptions
Jun 19, 2026
09a15a5
KRN-1117: Remove test-driven stackdepot trie indirection
Jun 19, 2026
bbf31e7
KRN-1117: Clarify stackdepot caller invariants
Jun 19, 2026
8f6d52c
KRN-1117: Fold stackdepot trie internals into implementation
Jun 22, 2026
3218ba2
KRN-1117: Document stackdepot trie design invariants
Jun 22, 2026
0542d6b
KRN-1117: Clarify stackdepot trie namespace checks
Jun 22, 2026
c1a9c70
KRN-1117: Avoid signed overflow in arm64 stackdepot compression
Jun 22, 2026
272a555
KRN-1117: Simplify stackdepot trie publication
Jun 22, 2026
d98d67e
KRN-1117: Reserve stackdepot trie IDs before pool storage
Jun 22, 2026
722792d
KRN-1117: Clear unused stackdepot trie child slots
Jun 23, 2026
3b2ea44
KRN-1117: Simplify stackdepot trie helpers
Jun 23, 2026
61a7987
KRN-1117: Simplify stackdepot trie state
Jun 23, 2026
891506d
KRN-1117: Test stackdepot overlong stack truncation
Jun 23, 2026
2858c84
KRN-1117: Tighten stackdepot trie save semantics
Jun 24, 2026
a4af172
KRN-1117: Tighten stackdepot trie reservation state
Jun 24, 2026
98b5919
KRN-1117: Simplify stackdepot trie and count handling
Jun 25, 2026
7029a52
KRN-1117: Clarify stackdepot trie failure semantics
Jun 25, 2026
6bbefcb
KRN-1117: Clarify stackdepot fetch handle constraints
Jun 25, 2026
20bb972
KRN-1117: Clarify stackdepot hash-only diagnostics
Jun 25, 2026
202dfc9
KRN-1117: Simplify stackdepot trie init paths
Jun 25, 2026
8cb7e4d
KRN-1117: Tighten stackdepot trie invariants
Jun 26, 2026
09c919f
KRN-1117: Remove unrelated page_owner changes
Jun 26, 2026
f91f9ca
KRN-1117: Add scratch CodeQL workflow
Jun 29, 2026
9235da2
KRN-1117: Speed up scratch CodeQL checkout
Jun 29, 2026
337a1e5
KRN-1117: Address stackdepot CodeQL findings
Jun 29, 2026
43169fb
KRN-1117: Add stackdepot CodeQL invariant queries
Jun 29, 2026
2c97c65
KRN-1117: Tighten stackdepot CodeQL workflow
Jul 2, 2026
f7b512e
KRN-1117: Restore stackdepot node-size CodeQL coverage
Jul 2, 2026
8d4cc6b
KRN-1117: Simplify stackdepot trie cleanup
Jul 6, 2026
7f56dc4
KRN-1117: Expand stackdepot CodeQL tripwires
Jul 6, 2026
b4616b1
KRN-1117: Fix stackdepot CodeQL query compilation
Jul 6, 2026
8a61e3c
KRN-1117: Reduce stackdepot CodeQL false positives
Jul 6, 2026
37f0611
KRN-1117: Tighten stackdepot CodeQL TSV output
Jul 6, 2026
791ecce
KRN-1117: Simplify stackdepot trie internals
Jul 6, 2026
321bcc2
KRN-1117: Trim stackdepot cleanup churn
Jul 6, 2026
a1aa173
KRN-1117: Clarify stackdepot trie helper contracts
Jul 7, 2026
ff27f5e
KRN-1117: Trim stackdepot trie helper churn
Jul 8, 2026
ac8913d
KRN-1117: Update stackdepot CodeQL tripwires
Jul 8, 2026
5df48c3
KRN-1117: Avoid stackdepot trie reservation wording
Jul 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/codeql/stackdepot/StackDepot.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import cpp

predicate isStackDepotFile(File f) {
f.getRelativePath() = "lib/stackdepot.c"
}

predicate isStackDepotFunction(Function f) {
isStackDepotFile(f.getFile())
}

predicate isTrieWriterOrchestrator(Function f) {
isStackDepotFunction(f) and
f.getName() = "stack_depot_trie_insert_locked"
}

predicate trustedStructuralHelperName(string name) {
name = "trie_build_append_chain" or
name = "trie_build_split" or
name = "trie_child_array_insert_at" or
name = "trie_child_array_replace_at" or
name = "trie_node_init_slice" or
name = "trie_publish_tail_append" or
name = "trie_reparent_children"
}

predicate isTrustedStructuralHelper(Function f) {
isStackDepotFunction(f) and
trustedStructuralHelperName(f.getName())
}

predicate isSidePublishFunction(Function f) {
isStackDepotFunction(f) and
(f.getName() = "trie_side_table_publish_new_leaf" or
f.getName() = "trie_side_table_publish_split_leaves")
}

predicate isBoundaryFunction(Function f) {
isStackDepotFunction(f) and
(
f.getName().matches("%init%") or
f.getName().matches("%prealloc%") or
f.getName().matches("%lookup%") or
f.getName().matches("%fetch%") or
f.getName().matches("%save%") or
f.getName().matches("%put%") or
f.getName().matches("%print%") or
f.getName().matches("%snprint%") or
f.getName().matches("%handle%")
)
}

bindingset[name]
predicate isForbiddenTrieAbstractionName(string name) {
name.matches("%lookup_status%") or
(name.matches("%trie_lookup%") and name.matches("%status%")) or
name.matches("%alloc_txn%") or
name.matches("%alloc_request%") or
name.matches("%pool_mark%") or
name.matches("%rollback%") or
name.matches("%insert_plan%") or
name.matches("%child_array_slot%") or
name.matches("%node_slot%") or
name.matches("%leaf_update%")
}

predicate returnsEinvalExpr(Expr e) {
// Linux UAPI errno value for EINVAL.
e.getValue().toInt() = -22
}
17 changes: 17 additions & 0 deletions .github/codeql/stackdepot/StackDepotForbiddenTrieAbstractions.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @name Deleted stackdepot trie abstraction reintroduced
* @description Flags names matching deleted lookup/status/transaction/slot/rollback machinery.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/forbidden-trie-abstraction
*/

import cpp
import StackDepot

from Declaration d
where
isStackDepotFile(d.getFile()) and
isForbiddenTrieAbstractionName(d.getName())
select d, "Stackdepot trie declaration '$@' looks like deleted status, transaction, plan, slot, update, or rollback machinery.", d, d.getName()
45 changes: 45 additions & 0 deletions .github/codeql/stackdepot/StackDepotGenericStateCarrier.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* @name Stackdepot trie generic state carrier
* @description Flags one-field trie wrappers and pointer/size carrier structs that may lack a real invariant.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id stackdepot/generic-state-carrier
*/

import cpp
import StackDepot

predicate isPointerSizeCarrier(Struct s) {
exists(Field ptr, Field sz |
ptr = s.getAField() and
sz = s.getAField() and
ptr != sz and
ptr.getType().toString().matches("%*%") and
(sz.getName().matches("%size%") or
sz.getName().matches("%bytes%") or
sz.getName().matches("%capacity%"))
)
}

predicate isKnownTrieStateStruct(Struct s) {
s.getName() = "stack_depot_trie_node" or
s.getName() = "stack_depot_trie_child_array" or
s.getName() = "stack_depot_trie_free_node" or
s.getName() = "stack_depot_trie_free_object" or
s.getName() = "stack_depot_trie_side_dir" or
s.getName() = "stack_depot_trie_side_root" or
s.getName() = "stack_depot_trie_side_prealloc" or
s.getName() = "stack_depot_trie_alloc_workspace"
}

from Struct s
where
isStackDepotFile(s.getFile()) and
s.getName().matches("%trie%") and
not isKnownTrieStateStruct(s) and
(
count(Field f | f = s.getAField()) = 1 or
isPointerSizeCarrier(s)
)
select s, "Trie struct '$@' looks like a one-field wrapper or generic pointer/size carrier; verify it carries a real invariant.", s, s.getName()
35 changes: 35 additions & 0 deletions .github/codeql/stackdepot/StackDepotKunitOnlyProductionHook.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @name Stackdepot production helper used only by KUnit
* @description Flags stackdepot production helpers that appear to exist only for KUnit tests.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id stackdepot/kunit-only-production-hook
*/

import cpp
import StackDepot

predicate calledFromStackdepotKunit(Function f) {
exists(FunctionCall call |
call.getTarget() = f and
call.getFile().getRelativePath() = "lib/tests/stackdepot_kunit.c"
)
}

predicate calledFromNonKunit(Function f) {
exists(FunctionCall call |
call.getTarget() = f and
call.getFile().getRelativePath() != "lib/tests/stackdepot_kunit.c"
)
}

from Function f
where
isStackDepotFunction(f) and
not f.getName().matches("%kunit%") and
not f.getName().matches("stack_depot_%") and
not f.getName().matches("__stack_depot_%") and
calledFromStackdepotKunit(f) and
not calledFromNonKunit(f)
select f, "Production stackdepot helper '$@' appears KUnit-only; avoid production helper surface just for tests.", f, f.getName()
20 changes: 20 additions & 0 deletions .github/codeql/stackdepot/StackDepotPageOwnerCountableSaves.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @name page_owner stackdepot save must stay countable
* @description Flags page_owner stackdepot saves that are not explicitly countable/hash-backed.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/page-owner-countable-save
*/

import cpp

predicate isPageOwnerFile(File f) {
f.getRelativePath() = "mm/page_owner.c"
}

from FunctionCall call
where
isPageOwnerFile(call.getFile()) and
call.getTarget().hasName("stack_depot_save")
select call, "page_owner direct stack_depot_save() can route into trie storage; use stack_depot_save_flags() with STACK_DEPOT_FLAG_COUNTABLE."
23 changes: 23 additions & 0 deletions .github/codeql/stackdepot/StackDepotTrieNodeSizeRevalidation.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @name Stackdepot trie node-size helper performs defensive checks
* @description Flags defensive checks inside __stack_depot_trie_node_size(); constructed trie runs should make node size a direct calculation.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id stackdepot/trie-node-size-defensive-check
* @previous-id stackdepot/trie-node-size-revalidation
*/

import cpp
import StackDepot

predicate isNodeSizeHelper(Function f) {
isStackDepotFile(f.getFile()) and
f.getName() = "__stack_depot_trie_node_size"
}

from Function f, IfStmt ifs
where
isNodeSizeHelper(f) and
ifs.getEnclosingFunction() = f
select ifs, "__stack_depot_trie_node_size() contains conditional validation; constructed frame-run metadata should make node size a direct calculation."
27 changes: 27 additions & 0 deletions .github/codeql/stackdepot/StackDepotTrieNullModeSelector.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @name Stackdepot trie helper uses NULL as operation mode
* @description Flags trusted structural helpers branching on pointer parameters, a common hidden operation selector.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id stackdepot/trie-null-mode-selector
*/

import cpp
import StackDepot

predicate conditionMentionsPointerParam(IfStmt ifs, Parameter p) {
p.getType().toString().matches("%*%") and
(
ifs.getCondition().toString().matches("%" + p.getName() + "%NULL%") or
ifs.getCondition().toString().matches("%!" + p.getName() + "%")
)
}

from Function f, Parameter p, IfStmt ifs
where
isTrustedStructuralHelper(f) and
p.getFunction() = f and
ifs.getEnclosingFunction() = f and
conditionMentionsPointerParam(ifs, p)
select ifs, "Trusted trie helper $@ branches on pointer parameter '$@'; verify NULL is not an operation selector.", f, f.getName(), p, p.getName()
21 changes: 21 additions & 0 deletions .github/codeql/stackdepot/StackDepotTrieOncePrimitive.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @name Stackdepot trie READ_ONCE or WRITE_ONCE use
* @description Flags trie-specific READ_ONCE/WRITE_ONCE uses so reviewers verify a lockless reader or publication pairing.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/trie-once-primitive
*/

import cpp
import StackDepot

from MacroInvocation m
where
isStackDepotFile(m.getFile()) and
(m.getMacroName() = "READ_ONCE" or m.getMacroName() = "WRITE_ONCE") and
(
m.toString().matches("%nr_children%") or
m.toString().matches("%trie%")
)
select m, "Trie-specific $@ use; verify a documented lockless reader or publication pairing justifies it.", m, m.getMacroName()
43 changes: 43 additions & 0 deletions .github/codeql/stackdepot/StackDepotTriePublishThenFailure.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @name Stackdepot trie normal failure after publication
* @description Flags normal error returns after side-table or structural publication starts in the writer path.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id stackdepot/trie-publish-then-failure
*/

import cpp
import StackDepot

predicate publishCall(FunctionCall call) {
call.getTarget().getName().matches("trie_side_table_publish_%") or
call.getTarget().getName().matches("trie_publish_%")
}

predicate normalFailureReturn(ReturnStmt ret) {
ret.hasExpr() and
(
ret.getExpr().toString().matches("-%") or
ret.getExpr().toString() = "ret"
)
}

predicate retFailureGuard(IfStmt guard) {
guard.getCondition().toString().matches("%ret%")
}

from Function f, FunctionCall pub, IfStmt guard, ReturnStmt ret
where
isTrieWriterOrchestrator(f) and
pub.getEnclosingFunction() = f and
guard.getEnclosingFunction() = f and
ret.getEnclosingFunction() = f and
publishCall(pub) and
retFailureGuard(guard) and
normalFailureReturn(ret) and
guard.getLocation().getStartLine() > pub.getLocation().getStartLine() and
guard.getLocation().getStartLine() <= pub.getLocation().getStartLine() + 2 and
ret.getLocation().getStartLine() >= guard.getLocation().getStartLine() and
ret.getLocation().getStartLine() <= guard.getLocation().getEndLine()
select ret, "Normal failure guard immediately after trie side-table or structural publication; expected failures should happen before publication begins."
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @name Trusted stackdepot trie helper publishes side-table state directly
* @description Flags direct side-table publication calls in trusted trie insertion helpers.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/trie-side-publish-in-trusted-helper
*/

import cpp
import StackDepot

predicate sidePublishFunctionName(string name) {
name = "trie_side_table_publish_new_leaf" or
name = "trie_side_table_publish_split_leaves"
}

from FunctionCall call, Function f
where
f = call.getEnclosingFunction() and
isTrustedStructuralHelper(f) and
sidePublishFunctionName(call.getTarget().getName())
select call, "Trusted trie insertion helper $@ publishes side-table state directly; verify this belongs in the planned publish operation and has clear failure handling.", f, f.getName()
24 changes: 24 additions & 0 deletions .github/codeql/stackdepot/StackDepotTrieStateRediscovery.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @name Trusted stackdepot trie helper rediscovers insertion state
* @description Flags calls that rediscover planner/writer state inside trusted trie insertion helpers.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/trie-state-rediscovery
*/

import cpp
import StackDepot

predicate rediscoveryFunctionName(string name) {
name = "trie_child_array_find_slot" or
name = "stack_depot_trie_lookup"
}

from FunctionCall call, Function f, Function target
where
f = call.getEnclosingFunction() and
isTrustedStructuralHelper(f) and
target = call.getTarget() and
rediscoveryFunctionName(target.getName())
select call, "Trusted trie insertion helper $@ calls $@ here; verify this state was not already established by planning/writer serialization.", f, f.getName(), target, target.getName()
24 changes: 24 additions & 0 deletions .github/codeql/stackdepot/StackDepotTrustedHelperReturnEinval.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @name Trusted stackdepot trie helper returns direct -EINVAL
* @description Flags direct -EINVAL returns in trusted trie structural helpers.
* @kind problem
* @problem.severity recommendation
* @precision high
* @id stackdepot/trusted-helper-return-einval
*/

import cpp
import StackDepot

predicate returnsEinval(ReturnStmt ret) {
ret.hasExpr() and
// Linux UAPI errno value for EINVAL.
ret.getExpr().getValue().toInt() = -22
}

from ReturnStmt ret, Function f
where
f = ret.getEnclosingFunction() and
isTrustedStructuralHelper(f) and
returnsEinval(ret)
select ret, "Trusted trie structural helper $@ returns direct -EINVAL here; verify this is not rediscovering a writer-side invariant.", f, f.getName()
6 changes: 6 additions & 0 deletions .github/codeql/stackdepot/qlpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: stackdepot/codeql
version: 0.0.1
dependencies:
codeql/cpp-all: "*"
extractor: cpp
warnOnImplicitThis: true
Loading
Loading