Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3e78eaa
add more debug info
sgzeng Feb 22, 2025
f70340d
update ground truth of test 5
sgzeng Feb 22, 2025
a08332f
Merge branch 'ChengyuSong:mzt' into mzt
sgzeng Feb 25, 2025
8788411
add unit test 8
sgzeng Feb 25, 2025
4b1c47d
fixup
Apr 18, 2025
89ab832
Merge branch 'mzt' of github.com:sgzeng/kernel-analyzer into mzt
sgzeng May 22, 2025
b6bcc4a
replace function multiple defination assertion with warning
sgzeng Feb 11, 2025
b3efead
dump bid and func_guid info
sgzeng Feb 11, 2025
1ad51d4
do not dump unreachable BB yet
sgzeng Feb 18, 2025
ab83e46
fixup
Apr 18, 2025
5a97be6
dump branch target BIDs in policy. Format: bid, dis_FT, dis_TT, FT_bi…
Jun 13, 2025
c4d878f
Merge branch 'mzt' of github.com:sgzeng/kernel-analyzer into mzt
sgzeng Jun 20, 2025
fb6dfba
Merge remote-tracking branch 'upstream/mzt' into mzt
sgzeng Jun 21, 2025
47e8539
fixup
sgzeng Jun 21, 2025
27ad8d5
dump distances for indirect callees
sgzeng Jul 18, 2025
1e75cdf
Allow other routes back propagate to the entry when computing distances.
sgzeng Jul 21, 2025
3be9951
annotate every BB with an id
sgzeng Jul 23, 2025
7cf310d
Add max callstack depth threshold to ReachableCallGraphPass to cap ca…
sgzeng Jul 23, 2025
65c36c2
fixup
sgzeng Jul 23, 2025
7a6ed7a
also check callstack length when computing distances
sgzeng Jul 24, 2025
5fc4c49
add an option to control callstack length
sgzeng Jul 24, 2025
b81c622
Guard against empty distances in annotateModules
sgzeng Jul 24, 2025
471c03c
Sort dumpDistance output by ascending distance and simplify iteration
sgzeng Jul 25, 2025
b2cbc16
more exit functions
sgzeng Jul 29, 2025
75e7f53
find and dump critical BBs from reachable and unreachable BBs.
sgzeng Jul 29, 2025
f0e4754
disable __taint_trace_distance instrumentation, only annotate bbid
sgzeng Jul 29, 2025
cb12c80
rewrite propagateThroughReturnEdgees
sgzeng Jul 30, 2025
e7ac35b
do not readd reachable BB
sgzeng Jul 30, 2025
84a2dd5
add author info
sgzeng Jul 30, 2025
3365902
add png_error to isExitFn list
sgzeng Jul 30, 2025
3dfc4f0
dump unreachable BBs
sgzeng Jul 30, 2025
9c8cd6c
python script to verify critical branch result
sgzeng Jul 30, 2025
a56bd77
instrument __taint_trace_divergence callback for detecting divergent …
sgzeng Jul 30, 2025
6baa75d
set global flag has_reached_target to true once target has reached
sgzeng Jul 31, 2025
2225fee
more robust unreachable exitBBs detection
sgzeng Aug 2, 2025
6f1267a
skip any unreachable Preds when computing distances.
sgzeng Aug 2, 2025
ef388a7
more friendly logs
sgzeng Aug 2, 2025
57ba1f9
Reachable: use iterative BFS with queued dedup in propagateThroughRet…
sgzeng Aug 12, 2025
05f16e9
Reachable: never treat entry blocks as exits; skip removing entry blo…
sgzeng Aug 12, 2025
fe24ea3
more logs
sgzeng Aug 12, 2025
410a08c
Reachability: decouple return-edge propagation from CFG/caller BFS
sgzeng Aug 12, 2025
530d839
more robust processing
sgzeng Aug 13, 2025
8701f88
Fix: Improve debug location path handling for system libs
sgzeng Aug 13, 2025
0750b22
better logging on unreachable BBs
sgzeng Aug 13, 2025
943710a
Remove reachable BB from exitBBs
sgzeng Aug 13, 2025
aa4c1af
make sure no intersection bewteen reachable and unreachable BB sets.
sgzeng Aug 13, 2025
8348f1f
reachable: count resume as exit only for developer EH (skip cleanup L…
sgzeng Aug 13, 2025
79ef2a6
update entry function list
sgzeng Aug 14, 2025
38bea69
sha bi AI, shan wo dai ma, xia xie yi tong
sgzeng Aug 14, 2025
744c7f0
add more BB to exitBBs from unknow reachable BB in normal functions
sgzeng Aug 14, 2025
aa98432
move logic from doInitialization to runOnFunction
sgzeng Aug 14, 2025
60a6f53
fixup
sgzeng Aug 14, 2025
e703907
dump caller→callee and callee→caller mappings
sgzeng Aug 17, 2025
3f5dbfd
remove return ins from exitBBs
sgzeng Aug 26, 2025
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
18 changes: 6 additions & 12 deletions src/lib/Annotation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,8 @@ bool isAllocFn(StringRef name, int *size, int *flag) {

bool isEntryFn(StringRef name) {
if (name.equals("main") ||
name.startswith("do_syscall_") ||
name.endswith("do_softirq") ||
name.equals("start_kernel") ||
name.equals("init") ||
name.equals("module_init") ||
name.equals("module_exit") ||
name.equals("init_module") ||
name.equals("cleanup_module") ||
name.equals("do_init_module") ||
name.equals("do_cleanup_module") ||
name.equals("do_one_initcall") ||
name.equals("do_one_initcall_sync"))
name.startswith("LLVMFuzzerTestOneInput") ||
name.startswith("FuzzerTestOneInput"))
return true;
else return false;
}
Expand All @@ -249,8 +239,12 @@ bool isExitFn(StringRef name) {
if (name.equals("exit") ||
name.equals("_exit") ||
name.equals("_Exit") ||
name.equals("quick_exit") ||
name.equals("exit_group") ||
name.equals("terminate") ||
name.equals("abort") ||
name.equals("panic") ||
name.equals("png_error") ||
name.equals("BUG") ||
name.equals("BUG_ON"))
return true;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/CallGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ bool CallGraphPass::runOnFunction(Function *F) {
#pragma clang diagnostic pop
#endif
// normal handling
bool isNull = false;
Value *ptr = I->getOperand(0);
NodeIndex ptrNode = NF.getValueNodeFor(ptr);
auto itr = funcPtsGraph.find(ptrNode);
Expand All @@ -438,7 +437,6 @@ bool CallGraphPass::runOnFunction(Function *F) {
CG_LOG("Load: source obj: " << idx << "\n");
if (idx == NF.getNullObjectNode() && itr->second.find_next(idx) == end) {
CG_LOG("Loading from null obj, ptr = " << ptrNode << "\n");
isNull = true;
// XXX
funcPtsGraph[valNode].insert(idx);
break;
Expand Down
38 changes: 33 additions & 5 deletions src/lib/KAMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2015 Byoungyoung Lee
* Copyright (C) 2016 Kangjie Lu
* Copyright (C) 2015 - 2024 Chengyu Song
* Copyrigth (C) 2024 - 2025 Haochen Zeng
*
* For licensing details see LICENSE
*/
Expand Down Expand Up @@ -42,6 +43,9 @@ cl::list<std::string> InputFilenames(
cl::opt<unsigned> VerboseLevel(
"verbose", cl::desc("Verbose level"), cl::init(0));

cl::opt<unsigned> CallStackLen(
"call-stack-len", cl::desc("The maximum call stack length from entry to the targets"), cl::init(10));

cl::opt<bool> UseTypeBasedCallGraph(
"type-based-callgraph", cl::desc("Use type-based call graph"), cl::init(false));

Expand All @@ -52,17 +56,30 @@ cl::opt<std::string> EntryList(
"entry-list", cl::desc("Entry list"), cl::init(""));

cl::opt<std::string> DumpPolicy(
"dump-policy", cl::desc("Dump static policy"), cl::init(""));
"dump-policy", cl::desc("Dump policy, format: bid,true_distance,false_distance,false_bid,true_bid"), cl::init(""));

cl::opt<std::string> DumpDistance(
"dump-distance", cl::desc("Dump distance"), cl::init(""));
"dump-distance", cl::desc("Dump distances, format: bid,bb_hash,loc,distance"), cl::init(""));

cl::opt<std::string> DumpCriticalBBs(
"dump-critical-branch", cl::desc("Dump critical basic blocks, format: critical_bid, exit_bid_1, exit_bid_2, ..."), cl::init(""));

cl::opt<std::string> DumpBidMapping(
"dump-bid-mapping", cl::desc("Dump basic block ID mapping, format: bid,fun_GUID,filepath:linenum"), cl::init(""));
"dump-bid-mapping", cl::desc("Dump basic block ID mapping, format: bid,bb_hash,fun_GUID,filepath:linenum"), cl::init(""));

cl::opt<std::string> DumpFuncInfo(
"dump-func-info", cl::desc("Dump function info, format: fun_GUID,fun_name,filepath,start_linenum,end_linenum"), cl::init(""));

cl::opt<std::string> DumpCallerCallee(
"dump-caller-callee",
cl::desc("Dump caller → callee mapping, format: caller_GUID,callee_GUID,..."),
cl::init(""));

cl::opt<std::string> DumpCalleeCaller(
"dump-callee-caller",
cl::desc("Dump callee → caller mapping, format: callee_GUID,caller_GUID,..."),
cl::init(""));

cl::opt<std::string> DumpAnnotatedIR(
"dump-annotated-ir", cl::desc("Dump annotated IR"), cl::init(""));

Expand Down Expand Up @@ -222,25 +239,36 @@ int main(int argc, char **argv) {
TyCG.run(GlobalCtx.Modules);
}

ReachableCallGraphPass RCGPass(&GlobalCtx, TargetList, EntryList, UseTypeBasedCallGraph);
ReachableCallGraphPass RCGPass(&GlobalCtx, TargetList, EntryList,
UseTypeBasedCallGraph, CallStackLen);
RCGPass.run(GlobalCtx.Modules);

if (!DumpBidMapping.empty() && !DumpFuncInfo.empty()){
std::ofstream bbLocs(DumpBidMapping);
std::ofstream funcInfo(DumpFuncInfo);
RCGPass.dumpIDMapping(GlobalCtx.Modules, bbLocs, funcInfo);
}
if (!DumpCallerCallee.empty() && !DumpCalleeCaller.empty()){
std::ofstream callercallee(DumpCallerCallee);
std::ofstream calleecaller(DumpCalleeCaller);
RCGPass.dumpCallees(callercallee);
RCGPass.dumpCallers(calleecaller);
}
if (!DumpPolicy.empty()) {
std::ofstream policy(DumpPolicy);
RCGPass.dumpPolicy(policy);
}
if (!DumpDistance.empty()) {
std::ofstream distance(DumpDistance);
RCGPass.dumpDistance(distance, true, false);
RCGPass.dumpDistance(distance, true);
}
if (!DumpAnnotatedIR.empty()) {
RCGPass.annotateModules(GlobalCtx.Modules, DumpAnnotatedIR);
}
if (!DumpCriticalBBs.empty()) {
std::ofstream criticalBBs(DumpCriticalBBs);
RCGPass.dumpCriticalBBs(criticalBBs);
}

return 0;
}
Loading