pub enum TaintedType {
UntaintedValue,
TaintedValue,
UntaintedPointer(Pointee),
TaintedPointer(Pointee),
ArrayOrVector(Pointee),
Struct(Vec<Pointee>),
NamedStruct(String),
UntaintedFnPtr,
TaintedFnPtr,
}
Expand description
The type system which we use for taint-tracking
Variants§
UntaintedValue
An untainted value which is not a pointer, struct, array, or vector.
TaintedValue
A tainted value which is not a pointer, struct, array, or vector.
UntaintedPointer(Pointee)
An untainted pointer to either a scalar or an (implicit) array.
By implicit we mean that this represents LLVM i8*
, not LLVM [300 x i8]*
.
TaintedPointer(Pointee)
A tainted pointer to either a scalar or an (implicit) array.
By implicit we mean that this represents LLVM i8*
, not LLVM [300 x i8]*
.
ArrayOrVector(Pointee)
An array or vector, with the given element type (and any number of elements). All elements are assumed to have the same type, which means that if any of them is tainted, all of them are tainted.
Struct(Vec<Pointee>)
A struct, with the given element types
NamedStruct(String)
A named struct, with the given name. To get the actual type of the named
struct’s contents, use get_named_struct_type
in the TaintState
or
TaintResult
. (This avoids infinite recursion in TaintedType
.)
UntaintedFnPtr
An untainted function pointer
TaintedFnPtr
A tainted function pointer
Implementations§
Source§impl TaintedType
impl TaintedType
Sourcepub fn untainted_ptr_to(pointee: TaintedType) -> Self
pub fn untainted_ptr_to(pointee: TaintedType) -> Self
Create a (fresh, unaliased) pointer to the given TaintedType
Sourcepub fn tainted_ptr_to(pointee: TaintedType) -> Self
pub fn tainted_ptr_to(pointee: TaintedType) -> Self
Create a (fresh, unaliased) tainted pointer to the given TaintedType
Sourcepub fn untainted_ptr_to_pointee(pointee: Pointee) -> Self
pub fn untainted_ptr_to_pointee(pointee: Pointee) -> Self
Create a pointer to the given Pointee
Sourcepub fn tainted_ptr_to_pointee(pointee: Pointee) -> Self
pub fn tainted_ptr_to_pointee(pointee: Pointee) -> Self
Create a tainted pointer to the given Pointee
Sourcepub fn array_or_vec_of(element_ty: TaintedType) -> Self
pub fn array_or_vec_of(element_ty: TaintedType) -> Self
Create an array or vector with the given element type, assuming that no pointers to the elements already exist
Sourcepub fn array_or_vec_of_pointee(pointee: Pointee) -> Self
pub fn array_or_vec_of_pointee(pointee: Pointee) -> Self
Create an array or vector with the given Pointee
as its element type
Sourcepub fn struct_of(elements: impl IntoIterator<Item = TaintedType>) -> Self
pub fn struct_of(elements: impl IntoIterator<Item = TaintedType>) -> Self
Create a struct of the given elements, assuming that no pointers to those elements already exist
Sourcepub fn struct_of_pointees(elements: impl IntoIterator<Item = Pointee>) -> Self
pub fn struct_of_pointees(elements: impl IntoIterator<Item = Pointee>) -> Self
Create a struct of the given Pointee
s
Sourcepub fn from_llvm_type(llvm_ty: &Type) -> Self
pub fn from_llvm_type(llvm_ty: &Type) -> Self
Produce the equivalent (untainted) TaintedType
for a given LLVM type.
Pointers will point to fresh TaintedType
s to represent their element
types; they will be assumed not to point to existing variables.
Sourcepub fn is_tainted_nonamedstruct(&self) -> bool
pub fn is_tainted_nonamedstruct(&self) -> bool
Is this type tainted?
This function panics on named struct types. (It does work on array, vector, and anonymous struct types, as long as the element type isn’t a named struct type.)
For a more generic function that works on all types, use
TaintedType::is_tainted()
(below), TaintState::is_type_tainted()
, or
TaintResult::is_type_tainted()
.
Sourcepub fn is_tainted<'m>(
&self,
named_structs: Rc<RefCell<NamedStructs<'m>>>,
cur_fn: &'m str,
) -> bool
pub fn is_tainted<'m>( &self, named_structs: Rc<RefCell<NamedStructs<'m>>>, cur_fn: &'m str, ) -> bool
Is this type tainted?
This function handles all types, including named struct types.
Alternately you can also use TaintState::is_type_tainted()
or
TaintResult::is_type_tainted()
.
Sourcepub fn taint_contents<'m>(&self, named_structs: &mut NamedStructs<'m>)
pub fn taint_contents<'m>(&self, named_structs: &mut NamedStructs<'m>)
Mark everything pointed to by this pointer as tainted.
Recurses into structs/arrays/vectors, but not pointers:
- if this pointer points to a struct/array/vector, we will taint all elements of that struct/array/vector
- if this pointer points to another pointer P, we will taint P, but not
things pointed to by P. Of course, if
config.dereferencing_tainted_ptr_gives_tainted
istrue
, then things pointed to by P will also become tainted if they are ever loaded through P.
Trait Implementations§
Source§impl Clone for TaintedType
impl Clone for TaintedType
Source§fn clone(&self) -> TaintedType
fn clone(&self) -> TaintedType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TaintedType
impl Debug for TaintedType
Source§impl Display for TaintedType
impl Display for TaintedType
Source§impl PartialEq for TaintedType
impl PartialEq for TaintedType
impl Eq for TaintedType
impl StructuralPartialEq for TaintedType
Auto Trait Implementations§
impl Freeze for TaintedType
impl !RefUnwindSafe for TaintedType
impl !Send for TaintedType
impl !Sync for TaintedType
impl Unpin for TaintedType
impl !UnwindSafe for TaintedType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more