From c01585dac6ecc8d2efb42ff21c302ddcb675d705 Mon Sep 17 00:00:00 2001 From: Stanimir Bozhilov Date: Mon, 31 Jul 2023 18:50:25 +0200 Subject: [PATCH] Warn if threadJoins is deactivated --- src/analyses/useAfterFree.ml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/analyses/useAfterFree.ml b/src/analyses/useAfterFree.ml index 31203e505d..9a6484f624 100644 --- a/src/analyses/useAfterFree.ml +++ b/src/analyses/useAfterFree.ml @@ -1,5 +1,6 @@ (** An analysis for the detection of use-after-free vulnerabilities ([useAfterFree]). *) +open GobConfig open GoblintCil open Analyses open MessageCategory @@ -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 ()