Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overflow in conversion from uvalue to svalue #769

Merged
merged 9 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 9 additions & 16 deletions src/crab/ebpf_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2334,11 +2334,9 @@ void ebpf_domain_t::shl(const Reg& dst_reg, int imm, const int finite_width) {
ub_n = ub_n << imm & uint_max;
}
m_inv.set(dst.uvalue, interval_t{lb_n, ub_n});
if (to_signed(ub_n) >= to_signed(lb_n)) {
m_inv.assign(dst.svalue, dst.uvalue);
} else {
havoc(dst.svalue);
}
m_inv.assign(dst.svalue, dst.uvalue);
overflow_signed(m_inv, dst.svalue, finite_width);
overflow_unsigned(m_inv, dst.uvalue, finite_width);
return;
}
}
Expand Down Expand Up @@ -2374,12 +2372,9 @@ void ebpf_domain_t::lshr(const Reg& dst_reg, int imm, int finite_width) {
}
}
m_inv.set(dst.uvalue, interval_t{lb_n, ub_n});
if (ub_n.narrow<int64_t>() >= lb_n.narrow<int64_t>()) {
// ? m_inv.set(dst.svalue, crab::interval_t{number_t{(int64_t)lb_n}, number_t{(int64_t)ub_n}});
m_inv.assign(dst.svalue, dst.uvalue);
} else {
havoc(dst.svalue);
}
m_inv.assign(dst.svalue, dst.uvalue);
overflow_signed(m_inv, dst.svalue, finite_width);
overflow_unsigned(m_inv, dst.uvalue, finite_width);
return;
}
havoc(dst.svalue);
Expand Down Expand Up @@ -2464,11 +2459,9 @@ void ebpf_domain_t::ashr(const Reg& dst_reg, const linear_expression_t& right_sv
}
}
m_inv.set(dst.svalue, interval_t{lb_n, ub_n});
if (to_unsigned(ub_n) >= to_unsigned(lb_n)) {
m_inv.assign(dst.uvalue, dst.svalue);
} else {
havoc(dst.uvalue);
}
m_inv.assign(dst.uvalue, dst.svalue);
overflow_signed(m_inv, dst.svalue, finite_width);
overflow_unsigned(m_inv, dst.uvalue, finite_width);
Alan-Jowett marked this conversation as resolved.
Show resolved Hide resolved
return;
}
}
Expand Down
Loading
Loading