Skip to content

Commit

Permalink
Warn if threadJoins is deactivated
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstanb committed Jul 31, 2023
1 parent cbaffbb commit c01585d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/analyses/useAfterFree.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(** An analysis for the detection of use-after-free vulnerabilities ([useAfterFree]). *)

open GobConfig
open GoblintCil
open Analyses
open MessageCategory
Expand Down Expand Up @@ -30,7 +31,16 @@ struct
let get_joined_threads ctx =
ctx.ask Queries.MustJoinedThreads

let warn_about_deactivated_thread_joins () =
if not @@ List.mem "threadJoins" @@ get_string_list "ana.activated" then
M.warn "Running without thread joins analysis. Multi-threaded UAF detection might be imprecise!"

let warn_for_multi_threaded_access ctx (heap_var:varinfo) behavior cwe_number =
(*
* We need the [threadJoins] analysis for making the multi-threaded UAF detection more precise
* Warn the user in case [threadJoins] is disabled
*)
warn_about_deactivated_thread_joins ();
let freeing_threads = ctx.global heap_var in
(* If we're single-threaded or there are no threads freeing the memory, we have nothing to WARN about *)
if ctx.ask (Queries.MustBeSingleThreaded { since_start = true }) || ThreadIdWithJoinedThreads.is_empty freeing_threads then ()
Expand Down

0 comments on commit c01585d

Please sign in to comment.