Skip to content

Commit 8f4048e

Browse files
committed
Fix vojdani privatization unsoundness on 56-witness/69-ghost-ptr-protection
1 parent f6311a0 commit 8f4048e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/analyses/basePriv.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ struct
830830
| _ -> ()
831831

832832
let invariant_global (ask: Q.ask) getg g =
833-
let locks = ask.f (Q.MustProtectingLocks g) in (* TODO: read-write locks *)
833+
let locks = ask.f (Q.MustProtectingLocks {global = g; write = false}) in
834834
if LockDomain.MustLockset.is_all locks || LockDomain.MustLockset.is_empty locks then (* TODO: output unprotected invariant with empty lockset? *)
835835
Invariant.none
836836
else (
@@ -1030,7 +1030,7 @@ struct
10301030
| `Left g' -> (* unprotected *)
10311031
ValueDomain.invariant_global (fun g -> getg (V.unprotected g)) g'
10321032
| `Right g' -> (* protected *)
1033-
let locks = ask.f (Q.MustProtectingLocks g') in
1033+
let locks = ask.f (Q.MustProtectingLocks {global = g'; write = true}) in
10341034
if LockDomain.MustLockset.is_all locks || LockDomain.MustLockset.is_empty locks then
10351035
Invariant.none
10361036
else if VD.equal (getg (V.protected g')) (getg (V.unprotected g')) then

src/analyses/mutexAnalysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ struct
226226
true
227227
else *)
228228
MustLockset.mem ml protecting
229-
| Queries.MustProtectingLocks g ->
230-
protecting ~write:true Strong g
229+
| Queries.MustProtectingLocks {global; write} ->
230+
protecting ~write Strong global
231231
| Queries.MustLockset ->
232232
let held_locks = MustLocksetRW.to_must_lockset (MustLocksetRW.filter snd ls) in
233233
held_locks

src/domains/queries.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type maybepublic = {global: CilType.Varinfo.t; write: bool; protection: Protecti
5353
type maybepublicwithout = {global: CilType.Varinfo.t; write: bool; without_mutex: LockDomain.MustLock.t; protection: Protection.t} [@@deriving ord, hash]
5454
type mustbeprotectedby = {mutex: LockDomain.MustLock.t; global: CilType.Varinfo.t; write: bool; protection: Protection.t} [@@deriving ord, hash]
5555
type mustprotectedvars = {mutex: LockDomain.MustLock.t; write: bool} [@@deriving ord, hash]
56+
type mustprotectinglocks = {global: CilType.Varinfo.t; write: bool} [@@deriving ord, hash]
5657
type access =
5758
| Memory of {exp: CilType.Exp.t; var_opt: CilType.Varinfo.t option; kind: AccessKind.t} (** Memory location access (race). *)
5859
| Point (** Program point and state access (MHP), independent of memory location. *)
@@ -117,7 +118,7 @@ type _ t =
117118
| MustJoinedThreads: ConcDomain.MustThreadSet.t t
118119
| ThreadsJoinedCleanly: MustBool.t t
119120
| MustProtectedVars: mustprotectedvars -> VS.t t
120-
| MustProtectingLocks: CilType.Varinfo.t -> LockDomain.MustLockset.t t
121+
| MustProtectingLocks: mustprotectinglocks -> LockDomain.MustLockset.t t
121122
| Invariant: invariant_context -> Invariant.t t
122123
| InvariantGlobal: Obj.t -> Invariant.t t (** Argument must be of corresponding [Spec.V.t]. *)
123124
| WarnGlobal: Obj.t -> Unit.t t (** Argument must be of corresponding [Spec.V.t]. *)
@@ -405,7 +406,7 @@ struct
405406
| Any (IterSysVars (vq1, vf1)), Any (IterSysVars (vq2, vf2)) -> VarQuery.compare vq1 vq2 (* not comparing fs *)
406407
| Any (MutexType m1), Any (MutexType m2) -> Mval.Unit.compare m1 m2
407408
| Any (MustProtectedVars m1), Any (MustProtectedVars m2) -> compare_mustprotectedvars m1 m2
408-
| Any (MustProtectingLocks g1), Any (MustProtectingLocks g2) -> CilType.Varinfo.compare g1 g2
409+
| Any (MustProtectingLocks g1), Any (MustProtectingLocks g2) -> compare_mustprotectinglocks g1 g2
409410
| Any (MayBeModifiedSinceSetjmp e1), Any (MayBeModifiedSinceSetjmp e2) -> JmpBufDomain.BufferEntry.compare e1 e2
410411
| Any (MustBeSingleThreaded {since_start=s1;}), Any (MustBeSingleThreaded {since_start=s2;}) -> Stdlib.compare s1 s2
411412
| Any (TmpSpecial lv1), Any (TmpSpecial lv2) -> Mval.Exp.compare lv1 lv2
@@ -451,7 +452,7 @@ struct
451452
| Any (InvariantGlobal vi) -> Hashtbl.hash vi
452453
| Any (YamlEntryGlobal (vi, task)) -> Hashtbl.hash vi (* TODO: hash task *)
453454
| Any (MustProtectedVars m) -> hash_mustprotectedvars m
454-
| Any (MustProtectingLocks g) -> CilType.Varinfo.hash g
455+
| Any (MustProtectingLocks g) -> hash_mustprotectinglocks g
455456
| Any (MayBeModifiedSinceSetjmp e) -> JmpBufDomain.BufferEntry.hash e
456457
| Any (MustBeSingleThreaded {since_start}) -> Hashtbl.hash since_start
457458
| Any (TmpSpecial lv) -> Mval.Exp.hash lv

0 commit comments

Comments
 (0)