Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
6acce50
Update Python binding to support INSERT/DELETE operations with dictio…
ChengyuSong Jan 15, 2026
060e1a0
Add linking constraints between string and bitvector variables on sha…
ChengyuSong Jan 16, 2026
f11e856
skip inst/func marked not to instrument
ChengyuSong Jan 16, 2026
05c0700
support ucsan
ChengyuSong Jan 17, 2026
6bfd19b
import ucsanpass
ChengyuSong Jan 18, 2026
369f650
import bridge and updates for importing ucsanrt
ChengyuSong Jan 18, 2026
05fb0a7
import ucsan runtime
ChengyuSong Jan 18, 2026
e5a1c5a
import thoroupy backend
ChengyuSong Jan 20, 2026
b65c26b
indexed access should use type dfsan_label
ChengyuSong Jan 21, 2026
a1557c3
add exporting to smt2
ChengyuSong Jan 22, 2026
711f3b8
fix GEP over under-constrained symbolic ptr; merge with existing stri…
ChengyuSong Jan 22, 2026
080ceeb
to support ucsan, (1) allow init parser without laucher, (2) we may h…
ChengyuSong Jan 27, 2026
05845cc
send point_by info through pipe_msg, ucsan no longer use the same uni…
ChengyuSong Jan 27, 2026
2d9c49b
use smaller types for ObjectMapKey (uint32_t, int32_t) with range che…
ChengyuSong Jan 27, 2026
d2141db
switch to dfsan.bb for bbid
ChengyuSong Jan 27, 2026
8ad6ef0
Fix struct return handling in SymSan and UCSan
ChengyuSong Jan 27, 2026
2a877ff
fix sext
ChengyuSong Jan 27, 2026
625d651
fix load type
ChengyuSong Jan 27, 2026
b97175f
update types
ChengyuSong Jan 27, 2026
11fc764
fix obj_id/offset passing for usage_cite and extension
ChengyuSong Jan 27, 2026
598ca24
fix indirect call handling
ChengyuSong Jan 27, 2026
8a08f96
fix loading indirect call retval in case uscan is used
ChengyuSong Jan 27, 2026
6e73455
finish trace_bb
ChengyuSong Jan 28, 2026
ad75e6c
fix tracebb
ChengyuSong Jan 28, 2026
a20fd34
fix bv1
ChengyuSong Jan 28, 2026
621ec33
avoid symbolizing statically initialized non-nullptr
ChengyuSong Jan 28, 2026
20a5a9c
DUMMY doesn't help, so far
ChengyuSong Jan 28, 2026
332b31e
update loop tracking
ChengyuSong Jan 28, 2026
38b6a3b
fix verify error
ChengyuSong Jan 29, 2026
c103351
add exit
ChengyuSong Jan 29, 2026
58f26fa
well, need to add them so check_pointer is invoked
ChengyuSong Jan 29, 2026
d5067f2
fix auto_custom for vararg func and prototype mismatch. mark __dfsw_ …
ChengyuSong Jan 29, 2026
60a889d
use ParseConstraints for constraint-aware pointer checking in inline asm
ChengyuSong Mar 2, 2026
aed3cb6
port kernel apis
ChengyuSong Mar 2, 2026
0e903f5
port ucsan_opt
ChengyuSong Mar 2, 2026
9ef497f
improve inline asm handling, fix stack alignment issue, fix dso intro…
ChengyuSong Mar 2, 2026
c0dddbb
capture violate effects of memory barrier
ChengyuSong Mar 2, 2026
1ab202f
fix GEP index sort mismatch and python ParseGEP arg parsing
ChengyuSong Mar 4, 2026
9043bc0
add WK_TaintCustom wrapper kind to defer string function wrapping to …
ChengyuSong Mar 4, 2026
e2294f7
propagate taint labels through ucsan_check_pointer
ChengyuSong Mar 4, 2026
a52defc
simplify PtrToInt(string_op) - base and x - x in taint union
ChengyuSong Mar 4, 2026
a583fd8
add flength op and __taint_add_constraint for memchr/memrchr length b…
ChengyuSong Mar 6, 2026
14229d5
use Int sort coercion to avoid expensive int2bv(indexof) in solver
ChengyuSong Mar 6, 2026
963f67d
add export_task_smt2 python binding for debugging solver constraints
ChengyuSong Mar 6, 2026
1d5c775
add minimize hints for malloc-family allocation sizes in solver
ChengyuSong Mar 7, 2026
882d4ce
propagate string labels through memcpy/memmove, bound memchr/memrchr/…
ChengyuSong Mar 9, 2026
660fd2c
add Int mirroring of BV nested constraints, fsubstr BV→Int conversion…
ChengyuSong Mar 9, 2026
d6f67cb
fix nosanitize accidentally marking GEP base pointer load
ChengyuSong Mar 10, 2026
08f0669
add string range linking constraints for overlapping substr variables
ChengyuSong Mar 10, 2026
ade66c2
read full Alloca object in get_str_label_n for symbolic-length string…
ChengyuSong Mar 10, 2026
e65631b
bridge malloc Alloca bounds labels from UCSan to SymSan runtime
ChengyuSong Mar 10, 2026
b1720af
refactor nosanitize __dfsw_* handling into handleUCSanCall, load retv…
ChengyuSong Mar 10, 2026
6c03030
add uninstrumented kind
ChengyuSong Mar 12, 2026
5e14763
hoist bounds checks out of loops using SCEV analysis
ChengyuSong Mar 12, 2026
48eeca1
can't translate constant nullptr
ChengyuSong Mar 13, 2026
f37fc84
port cfg dump
ChengyuSong Mar 14, 2026
7331d9c
fix overflow checks skipped when symbolic operands have concrete value 0
ChengyuSong Mar 14, 2026
ccfbc21
add assume/assert interfaces for pre-/post-conditions
ChengyuSong Mar 17, 2026
ccffb55
exit on unreachable
ChengyuSong Mar 18, 2026
394dba3
fix args
ChengyuSong Mar 18, 2026
1a92137
ugly hack, allow OP_NONE, input to pass
ChengyuSong Mar 18, 2026
5fbcbc4
preserve noreturn semantics in __external$ wrappers
ChengyuSong Mar 18, 2026
f228893
send assertion results as events
ChengyuSong Mar 19, 2026
0cfc435
forget header
ChengyuSong Mar 19, 2026
e6375f3
add compile-time type table and type_id plumbing for seed-to-unittest
ChengyuSong Mar 19, 2026
1046481
some optimizations: (1) memset -> mmap (2) remove stl (3) static link
ChengyuSong Mar 20, 2026
1fa575b
propagate taint through llvm.bswap intrinsic using Extract+Concat
ChengyuSong Mar 20, 2026
73238a7
pass actual byte count to checkPointer for mem/string functions
ChengyuSong Mar 21, 2026
167fd77
fix Z3 link: add libc++ after libZ3Solver to resolve libc++ symbols
ChengyuSong Mar 21, 2026
404888f
support negative offset from ucsan
ChengyuSong Mar 21, 2026
a7a4fbc
record and restore target offset
ChengyuSong Mar 21, 2026
efbf860
fix gv event, pass offset
ChengyuSong Mar 22, 2026
d19485b
add more heuristics for string constraints
ChengyuSong Mar 22, 2026
5115d3c
better assertion handling
ChengyuSong Mar 31, 2026
e0c2d9f
add __ucsan_symbolize_input API for KLEE-style symbolization
ChengyuSong Apr 1, 2026
f61e726
preserve dso_local on globals used in inline asm with immediate const…
ChengyuSong Apr 3, 2026
c0f8117
fix memmove shadow intrinsic type mismatch
ChengyuSong Apr 3, 2026
a9c0063
handle ConstantExpr users when preserving dso_local for inline asm
ChengyuSong Apr 3, 2026
f1a859b
handle ConstantExpr pointers in checkPointer cache movement
ChengyuSong Apr 3, 2026
16059ae
preserve internal linkage for static inline functions
ChengyuSong Apr 3, 2026
736c08d
add __taint_trace_bb stub to ucsan runtime
ChengyuSong Apr 3, 2026
7b3db8e
fix __taint_trace_bb stub name and add __dfsw_panic wrapper
ChengyuSong Apr 3, 2026
1f5cf01
add WK_Discard support to UCSanPass for discarded functions
ChengyuSong Apr 3, 2026
4e70621
fix checkPointer cache: use NCD for domination and avoid moving Ptr
ChengyuSong Apr 3, 2026
ddc0664
recalculate dominator tree after SplitBlockAndInsertIfThenElse
ChengyuSong Apr 4, 2026
aa83414
fix __taint_check_bounds call to use extended size argument
ChengyuSong Apr 4, 2026
963e146
fix dso_local/visibility issues for out-of-scope functions and local-…
ChengyuSong Apr 4, 2026
ea49443
use getShadowTy for aggregate types in PHI nodes and custom function …
ChengyuSong Apr 4, 2026
1718f4d
set KO_CC to LLVM clang path when building libSymsanProxy.o during in…
ChengyuSong Apr 12, 2026
b130a6b
add size_in_bits arg to __taint_union_load for sub-byte type truncation
ChengyuSong Apr 13, 2026
f02075f
fix invalid bitcast from pointer to float in driver wrapper arg setup
ChengyuSong Apr 15, 2026
edf519b
handle SIGFPE traps for division-by-zero and integer overflow in thor…
ChengyuSong Apr 15, 2026
aafb6f1
add ucsan custom wrappers for abort and __assert_fail
ChengyuSong May 12, 2026
db4b99a
add copy overflow detection for ucsan: strcpy/memcpy into bounded alloca
ChengyuSong May 13, 2026
e3ba098
support GV destinations in ucsan_check_copy_bounds
ChengyuSong May 14, 2026
24bcf13
also request copy enlargement for char-typed (type_id==2) objects
ChengyuSong May 14, 2026
6fc30b1
add ucsan custom wrappers for read/fread to symbolize I/O buffers
ChengyuSong May 15, 2026
5ddeddf
guard symsan read/fread/pread wrappers with USE_UCSAN_CUSTOM
ChengyuSong May 15, 2026
22e0386
use resign_shadow with zero label in read/fread wrappers
ChengyuSong May 15, 2026
8c0317e
fix indirect call return shadow always being zero
ChengyuSong May 16, 2026
ab15b51
reset bid and counter at loop exit
ChengyuSong May 16, 2026
ab61560
add taint function types to CustomFuncTypes for YAML auto-custom wrap…
ChengyuSong May 16, 2026
c6425dc
route auto-custom wrappers with taint ref_name through TaintPass
ChengyuSong May 16, 2026
83dfb57
size pointer-arg check via abilist sizeN; drop copyn
ChengyuSong May 17, 2026
20cfe8a
handle empty entry block in getShadowForTLSArgument
ChengyuSong May 17, 2026
8f7de4f
always store ucsan arg TLS at WK_AutoCustom call sites
ChengyuSong May 17, 2026
04d3d44
add invert_ret option to auto-custom YAML entries
ChengyuSong May 17, 2026
7aaadcb
resign check label of every byte, so store must too
ChengyuSong May 18, 2026
9414b39
invalidate CheckedPtrMap cache across function calls
ChengyuSong May 20, 2026
759ecb4
hoist strlen-bounded loop bounds checks for OOB detection and solving
ChengyuSong May 20, 2026
15c50f5
z3 solver fixes: clamp strlen INSERT, signed icmp, bool xor, exceptio…
ChengyuSong May 20, 2026
faef84e
fix input
ChengyuSong May 20, 2026
a5de44f
hoist ucsan_check_pointer for string base in bounds checks, handle ze…
ChengyuSong May 20, 2026
26edb14
add fake file I/O simulator for ucsan
ChengyuSong May 22, 2026
44ed42b
fix losing deps when Load load overlapping bytes; improve debug print
ChengyuSong May 23, 2026
960007c
improve global var handling
ChengyuSong May 25, 2026
bd49f70
a bit ugly but now we can track symbolic size allocation in ucsan. al…
ChengyuSong May 25, 2026
c7e54f3
add ignore type. save local cid for ub_solving
ChengyuSong May 25, 2026
efa0ea0
fix file simulation
ChengyuSong May 25, 2026
a101dc1
fix branch_dep allocation
ChengyuSong May 25, 2026
2c96978
updates loop-invariant-based check/solve
ChengyuSong May 25, 2026
4a4c38c
solver: avoid solving allocation sizes to zero
ChengyuSong Jun 8, 2026
a909eb7
compiler: enable taint UB solving in ucsan_opt
ChengyuSong Jun 8, 2026
cb870c7
runtime: model byte-swap and network byte-order functions
ChengyuSong Jun 8, 2026
d9017a9
ucsan: plumb max_obj_size flag into the object-size limit
ChengyuSong Jun 8, 2026
65d1e2a
ucsan: emit/consume memory-access summaries to hoist loop bounds solving
ChengyuSong Jun 8, 2026
79ff385
ucsan: simulate fstat/fileno/file-size in the file simulator
ChengyuSong Jun 9, 2026
b663c7d
symsan: support C++ exception handling
ChengyuSong Jun 11, 2026
1002a67
ucsan: C++ exception handling support
ChengyuSong Jun 11, 2026
4f0660a
ucsan: add prebuilt plain libc++abi/libunwind for C++ EH
ChengyuSong Jun 11, 2026
951420e
fix assert/assume interface
ChengyuSong Jun 11, 2026
a9688a8
ucsan: round-trip string-search results into UC pseudo-pointer space
ChengyuSong Jun 13, 2026
4cac57d
fix state transition
ChengyuSong Jun 18, 2026
2850460
improve assume contracts
ChengyuSong Jun 18, 2026
02607b1
add memleak checker
ChengyuSong Jun 22, 2026
df6ab4a
intovr event
ChengyuSong Jun 25, 2026
1bfa245
loop outline pass for ucsan
ChengyuSong Jun 25, 2026
1193ee3
type table
ChengyuSong Jun 25, 2026
79e5dfb
fix aflpp mutator build: rename stale fsize_type to add_constraint_type
ChengyuSong Jul 1, 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
17 changes: 13 additions & 4 deletions backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_STANDARD 17)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O3 -Wno-format")

add_library(Fastgen STATIC fastgen.cpp)
target_compile_options(Fastgen PRIVATE -stdlib=libc++)
# Fastgen backend (dfsan symbolic execution + out-of-process solving)
add_library(Fastgen STATIC fastgen.cpp solver_common.cpp)
target_include_directories(Fastgen PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../runtime
${CMAKE_CURRENT_SOURCE_DIR}
)
install (TARGETS Fastgen DESTINATION ${SYMSAN_LIB_DIR})

# Thoroupy backend (ucsan under-constrained execution + fastgen dfsan callbacks)
add_library(Thoroupy STATIC thoroupy.cpp fastgen.cpp solver_common.cpp)
target_include_directories(Thoroupy PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../runtime
${CMAKE_CURRENT_SOURCE_DIR}
)

install (TARGETS Fastgen Thoroupy DESTINATION ${SYMSAN_LIB_DIR})
175 changes: 109 additions & 66 deletions backend/fastgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,7 @@

*/

#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_file.h"
#include "sanitizer_common/sanitizer_posix.h"
#include "dfsan/dfsan.h"

using namespace __dfsan;

static uint32_t __instance_id;
static uint32_t __session_id;
static int __pipe_fd;

// filter?
SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL uint32_t __taint_trace_callstack;

static inline void __solve_cond(dfsan_label label, uint8_t result,
uint8_t add_nested, uint8_t loop_flag,
uint32_t cid, void *addr) {

if (__pipe_fd < 0)
return;

uint16_t flags = 0;
if (add_nested) flags |= F_ADD_CONS;

// set the loop flags according to branching results
switch (loop_flag) {
case TrueBranchLoopExit:
flags |= result ? F_LOOP_EXIT : F_LOOP_LATCH;
break;
case TrueBranchLoopLatch:
flags |= result ? F_LOOP_LATCH : F_LOOP_EXIT;
break;
case FalseBranchLoopExit:
flags |= result ? F_LOOP_LATCH : F_LOOP_EXIT;
break;
case FalseBranchLoopLatch:
flags |= result ? F_LOOP_EXIT : F_LOOP_LATCH;
break;
default:
// No loop flag or unrecognized flag, do nothing
break;
}

// send info
pipe_msg msg = {
.msg_type = cond_type,
.flags = flags,
.instance_id = __instance_id,
.addr = (uptr)addr,
.context = __taint_trace_callstack,
.id = cid,
.label = label,
.result = result
};

if (internal_write(__pipe_fd, &msg, sizeof(msg)) < 0) {
Die();
}
}
#include "solver_common.h"

static inline void __send_ubi(dfsan_label label, uint64_t result,
uint32_t cid, void *addr) {
Expand Down Expand Up @@ -140,7 +82,7 @@ __taint_trace_cmp(dfsan_label op1, dfsan_label op2, uint32_t size,
__switch_true_case.cid = cid;
} else {
// solve without add_nested
__solve_cond(temp, r, 0, 0, cid, addr);
__taint_send_cond(temp, r, 0, 0, cid, addr);
}
}

Expand All @@ -160,7 +102,7 @@ __taint_trace_switch_end(uint32_t cid) {
__switch_true_case.label, cid, addr);

// solve the true case
__solve_cond(__switch_true_case.label, 1, 1, 0, cid, addr);
__taint_send_cond(__switch_true_case.label, 1, 1, 0, cid, addr);
__switch_true_case.label = 0;
}

Expand Down Expand Up @@ -190,7 +132,7 @@ __taint_trace_cond(dfsan_label label, bool r, uint8_t flag, uint32_t cid) {
uint8_t loop_flag = flag & LoopFlagMask;

// always add nested
__solve_cond(label, r, add_nested, loop_flag, cid, addr);
__taint_send_cond(label, r, add_nested, loop_flag, cid, addr);
}

extern "C" SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
Expand All @@ -217,18 +159,18 @@ __taint_trace_select(dfsan_label cond_label, dfsan_label true_label,
if (true_label != 0 && false_op == 0) {
dfsan_label land = dfsan_union(cond_label, true_label, And, 1, r, true_op);
uint8_t lr = (r && true_op) ? 1 : 0;
__solve_cond(land, lr, 1, 0, cid, addr);
__taint_send_cond(land, lr, 1, 0, cid, addr);
return land;
} else if (false_label != 0 && true_op == 1) {
// logical OR: select cond, true, label
dfsan_label lor = dfsan_union(cond_label, false_label, Or, 1, r, false_op);
uint8_t lr = (r || false_op) ? 1 : 0;
__solve_cond(lor, lr, 1, 0, cid, addr);
__taint_send_cond(lor, lr, 1, 0, cid, addr);
return lor;
} else {
// normal select?
AOUT("normal select?!\n");
__solve_cond(cond_label, r, 1, 0, cid, addr);
__taint_send_cond(cond_label, r, 1, 0, cid, addr);
return r ? true_label : false_label;
}
}
Expand Down Expand Up @@ -307,9 +249,109 @@ __taint_trace_gep(dfsan_label ptr_label, uint64_t ptr,

extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__taint_trace_offset(dfsan_label offset_label, s64 offset, unsigned size) {
// use add_constraint_type to send offset constraints
if (offset_label == 0)
return;

void *addr = __builtin_return_address(0);

AOUT("tainted offset: %ld = %d, size: %u @%p\n",
offset, offset_label, size, addr);

if (__pipe_fd < 0)
return;

pipe_msg msg = {
.msg_type = add_constraint_type,
.flags = 0,
.instance_id = __instance_id,
.addr = (uptr)addr,
.context = __taint_trace_callstack,
.label = offset_label, // just in case
.result = (uint64_t)offset
};

if (internal_write(__pipe_fd, &msg, sizeof(msg)) < 0) {
Die();
}

return;
}

extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__taint_add_constraint(dfsan_label label, uint8_t result) {
if (label == 0)
return;

void *addr = __builtin_return_address(0);

AOUT("tainted add_constraint: %d, result: %u @%p\n", label, result, addr);

if (__pipe_fd < 0)
return;

pipe_msg msg = {
.msg_type = add_constraint_type,
.flags = 0,
.instance_id = __instance_id,
.addr = (uptr)addr,
.context = __taint_trace_callstack,
.label = label,
.result = (uint64_t)result
};

if (internal_write(__pipe_fd, &msg, sizeof(msg)) < 0) {
Die();
}

return;
}

extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__taint_minimize_label(dfsan_label label, u64 size, dfsan_label bounds) {
if (label == 0 || label == kInitializingLabel)
return;

void *addr = __builtin_return_address(0);

AOUT("minimize label: %d, bounds: %d, size: %lu\n", label, bounds, size);

if (bounds != 0) {
dfsan_label_info *bounds_info = get_label_info(bounds);
if (bounds_info->op == __dfsan::Alloca) {
AOUT("update size label from %d to %d\n", bounds_info->l2, label);
bounds_info->l2 = label;
}
}

if (__pipe_fd < 0)
return;

pipe_msg msg = {
.msg_type = minimize_type,
.flags = 0,
.instance_id = __instance_id,
.addr = 0,
.context = __taint_trace_callstack,
.label = label,
.result = 0
};

if (internal_write(__pipe_fd, &msg, sizeof(msg)) < 0) {
Die();
}

if (!flags().allow_zero_size_alloc && size == 0) {
// Emit this after the minimize message so the manager records the hint
// before solving the synthetic nonzero condition.
static constexpr uint32_t kMinimizeNonzeroCid = 12;
dfsan_label_info *size_info = get_label_info(label);
dfsan_label nonzero_label =
dfsan_union(label, 0, (__dfsan::bvneq << 8) | ICmp, size_info->size, 0, 0);
__taint_send_cond(nonzero_label, 0, 1, 0, kMinimizeNonzeroCid, addr);
}
}

extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
__taint_trace_memcmp(dfsan_label label) {
if (label == 0)
Expand Down Expand Up @@ -403,8 +445,9 @@ __taint_trace_memerr(dfsan_label ptr_label, uptr ptr, dfsan_label size_label,
}
}

extern "C" void InitializeSolver() {
extern "C" void InitializeSymSanSolver() {
__instance_id = flags().instance_id;
__session_id = flags().session_id;
__pipe_fd = flags().pipe_fd;
__control_pipe_fd = flags().control_pipe_fd;
}
78 changes: 78 additions & 0 deletions backend/solver_common.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Common code shared between fastgen and thoroupy solvers.

------------------------------------------------

Written by Chengyu Song <csong@cs.ucr.edu> and
Ju Chen <jchen757@ucr.edu>

Copyright 2021-2025 UC Riverside. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

*/

#include "solver_common.h"

//===----------------------------------------------------------------------===//
// Shared Global State
//===----------------------------------------------------------------------===//

uint32_t __instance_id;
uint32_t __session_id;
int __pipe_fd;
int __control_pipe_fd;

//===----------------------------------------------------------------------===//
// Shared Helper Functions
//===----------------------------------------------------------------------===//

void __taint_send_cond(dfsan_label label, uint8_t result,
uint8_t add_nested, uint8_t loop_flag,
uint32_t cid, void *addr) {

if (__pipe_fd < 0)
return;

uint16_t flags = 0;
if (add_nested) flags |= F_ADD_CONS;

// set the loop flags according to branching results
switch (loop_flag) {
case TrueBranchLoopExit:
flags |= result ? F_LOOP_EXIT : F_LOOP_LATCH;
break;
case TrueBranchLoopLatch:
flags |= result ? F_LOOP_LATCH : F_LOOP_EXIT;
break;
case FalseBranchLoopExit:
flags |= result ? F_LOOP_LATCH : F_LOOP_EXIT;
break;
case FalseBranchLoopLatch:
flags |= result ? F_LOOP_EXIT : F_LOOP_LATCH;
break;
default:
// No loop flag or unrecognized flag, do nothing
break;
}

// send info
pipe_msg msg = {
.msg_type = cond_type,
.flags = flags,
.instance_id = __instance_id,
.addr = (uptr)addr,
.context = __taint_trace_callstack,
.id = cid,
.label = label,
.result = result
};

if (internal_write(__pipe_fd, &msg, sizeof(msg)) < 0) {
Die();
}
}
52 changes: 52 additions & 0 deletions backend/solver_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Common code shared between fastgen and thoroupy solvers.

------------------------------------------------

Written by Chengyu Song <csong@cs.ucr.edu> and
Ju Chen <jchen757@ucr.edu>

Copyright 2021-2025 UC Riverside. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

*/

#ifndef SOLVER_COMMON_H
#define SOLVER_COMMON_H

#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_file.h"
#include "sanitizer_common/sanitizer_posix.h"
#include "dfsan/dfsan.h"

using namespace __dfsan;

//===----------------------------------------------------------------------===//
// Shared Global State
//===----------------------------------------------------------------------===//

extern uint32_t __instance_id;
extern uint32_t __session_id;
extern int __pipe_fd;
extern int __control_pipe_fd;

// filter, defined in dfsan.cpp
extern SANITIZER_INTERFACE_ATTRIBUTE THREADLOCAL uint32_t __taint_trace_callstack;

//===----------------------------------------------------------------------===//
// Shared Helper Functions
//===----------------------------------------------------------------------===//

// Note: get_const_result() is defined in dfsan.h

// Send conditional branch info to solver
void __taint_send_cond(dfsan_label label, uint8_t result,
uint8_t add_nested, uint8_t loop_flag,
uint32_t cid, void *addr);

#endif // SOLVER_COMMON_H
Loading
Loading