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 simple strict provenance cases in analysis/test #699

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions analysis/test/src/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub struct S {
pub field4: T,
}
#[no_mangle]
pub static mut global: *mut S = 0 as *const S as *mut S;
pub static mut global: *mut S = std::ptr::null_mut();
#[no_mangle]
pub unsafe extern "C" fn malloc_wrapper(mut size: size_t) -> *mut libc::c_void {
return malloc(size);
Expand Down Expand Up @@ -105,7 +105,7 @@ pub unsafe extern "C" fn simple() {
(*y).field4 = T {
field: 0i32,
field2: 0u64,
field3: 0 as *const S,
field3: std::ptr::null(),
field4: 0i32,
};
let s = *y;
Expand Down Expand Up @@ -232,7 +232,7 @@ pub unsafe extern "C" fn fdevent_unregister(mut ev: *mut fdevents, mut fd: libc:
return;
}
let ref mut fresh1 = *((*ev).fdarray).offset(fd as isize);
*fresh1 = 0 as *mut fdnode;
*fresh1 = std::ptr::null_mut();
fdnode_free(fdn);
}
unsafe extern "C" fn fdnode_free(mut fdn: *mut fdnode) {
Expand Down Expand Up @@ -345,7 +345,7 @@ pub unsafe extern "C" fn invalid() {
b"%i\n\x00" as *const u8 as *const libc::c_char,
(*global).field,
);
global = 0 as *mut S;
global = std::ptr::null_mut();
free(s as *mut libc::c_void);
}
pub unsafe extern "C" fn testing() {
Expand Down Expand Up @@ -416,14 +416,14 @@ pub unsafe extern "C" fn test_ref_field() {
let t = T {
field: 0i32,
field2: 0u64,
field3: 0 as *const S,
field3: std::ptr::null(),
field4: 0i32,
};

let ref mut s = S {
field: 0i32,
field2: 0u64,
field3: 0 as *const S,
field3: std::ptr::null(),
field4: t,
};
s.field4.field4 = s.field4.field4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ nodes_that_need_write = []
g {
n[0]: copy _ => _14 @ bb6[4]: fn main; _14 = null_mut();
n[1]: copy n[0] => _1 @ bb0[0]: fn once; _13 = once(move _14);
n[2]: int_to_ptr _ => _17 @ bb4[29]: fn simple; _17 = const 0_usize as *const pointers::S (PointerFromExposedAddress);
n[3]: value.store _ => _20.* @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress);
n[4]: value.store _ => _17.* @ bb8[4]: fn fdevent_unregister; (*_17) = const 0_usize as *mut pointers::fdnode_st (PointerFromExposedAddress);
n[5]: int_to_ptr _ => _2 @ bb0[2]: fn test_ref_field; _2 = const 0_usize as *const pointers::S (PointerFromExposedAddress);
n[6]: int_to_ptr _ => _5 @ bb0[8]: fn test_ref_field; _5 = const 0_usize as *const pointers::S (PointerFromExposedAddress);
n[2]: copy _ => _17 @ bb4[29]: fn simple; _17 = null();
n[3]: copy _ => _20 @ bb4[6]: fn invalid; _20 = null_mut();
n[4]: value.store n[3] => _21.* @ bb5[2]: fn invalid; (*_21) = move _20;
n[5]: copy _ => _22 @ bb8[5]: fn fdevent_unregister; _22 = null_mut();
n[6]: value.store n[5] => _17.* @ bb9[0]: fn fdevent_unregister; (*_17) = move _22;
n[7]: copy _ => _2 @ bb0[2]: fn test_ref_field; _2 = null();
n[8]: copy _ => _5 @ bb1[5]: fn test_ref_field; _5 = null();
}
nodes_that_need_write = []

Expand All @@ -48,9 +50,9 @@ g {
n[1]: copy n[0] => _1 @ bb2[1]: fn simple; _1 = move _2 as *mut pointers::S (Misc);
n[2]: copy n[1] => _5 @ bb2[5]: fn simple; _5 = _1;
n[3]: field.0 n[1] => _10 @ bb4[5]: fn simple; _10 = &raw const ((*_1).0: i32);
n[4]: copy n[2] => _24 @ bb5[5]: fn simple; _24 = _5;
n[5]: copy n[4] => _23 @ bb5[6]: fn simple; _23 = move _24 as *mut libc::c_void (Misc);
n[6]: free n[5] => _22 @ bb5[8]: fn simple; _22 = free(move _23);
n[4]: copy n[2] => _24 @ bb6[5]: fn simple; _24 = _5;
n[5]: copy n[4] => _23 @ bb6[6]: fn simple; _23 = move _24 as *mut libc::c_void (Misc);
n[6]: free n[5] => _22 @ bb6[8]: fn simple; _22 = free(move _23);
}
nodes_that_need_write = []

Expand All @@ -74,11 +76,11 @@ g {
n[16]: field.2 n[3] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
n[17]: addr.store n[16] => _ @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
n[18]: value.store n[15] => _1.*.2 @ bb4[25]: fn simple; ((*_1).2: *const pointers::S) = move _15;
n[19]: field.3 n[1] => _ @ bb4[32]: fn simple; ((*_6).3: pointers::T) = move _16;
n[20]: addr.store n[19] => _ @ bb4[32]: fn simple; ((*_6).3: pointers::T) = move _16;
n[21]: addr.load n[1] => _ @ bb4[35]: fn simple; _18 = (*_6);
n[22]: addr.store n[3] => _ @ bb4[39]: fn simple; (*_1) = move _19;
n[23]: copy n[3] => _21 @ bb4[43]: fn simple; _21 = _1;
n[19]: field.3 n[1] => _ @ bb5[2]: fn simple; ((*_6).3: pointers::T) = move _16;
n[20]: addr.store n[19] => _ @ bb5[2]: fn simple; ((*_6).3: pointers::T) = move _16;
n[21]: addr.load n[1] => _ @ bb5[5]: fn simple; _18 = (*_6);
n[22]: addr.store n[3] => _ @ bb5[9]: fn simple; (*_1) = move _19;
n[23]: copy n[3] => _21 @ bb5[13]: fn simple; _21 = _1;
n[24]: copy n[23] => _2 @ bb0[0]: fn recur; _20 = recur(const 3_i32, move _21);
n[25]: copy n[24] => _13 @ bb8[3]: fn recur; _13 = _2;
n[26]: copy n[25] => _2 @ bb0[0]: fn recur; _9 = recur(move _10, move _13);
Expand Down Expand Up @@ -363,8 +365,8 @@ g {
n[10]: copy _ => _19 @ bb3[17]: fn invalid; _19 = const {alloc8: *mut *mut pointers::S};
n[11]: field.0 n[10] => _18 @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
n[12]: addr.load n[11] => _ @ bb3[18]: fn invalid; _18 = ((*(*_19)).0: i32);
n[13]: copy _ => _20 @ bb4[6]: fn invalid; _20 = const {alloc8: *mut *mut pointers::S};
n[14]: addr.store n[13] => _ @ bb4[7]: fn invalid; (*_20) = const 0_usize as *mut pointers::S (PointerFromExposedAddress);
n[13]: copy _ => _21 @ bb5[1]: fn invalid; _21 = const {alloc8: *mut *mut pointers::S};
n[14]: addr.store n[13] => _ @ bb5[2]: fn invalid; (*_21) = move _20;
}
nodes_that_need_write = [14, 13, 9, 8, 5, 4, 1, 0]

Expand All @@ -386,9 +388,9 @@ g {
n[5]: value.store n[4] => _6.* @ bb2[10]: fn invalid; (*_6) = move _5;
n[6]: field.0 n[1] => _12 @ bb2[25]: fn invalid; _12 = ((*_1).0: i32);
n[7]: addr.load n[6] => _ @ bb2[25]: fn invalid; _12 = ((*_1).0: i32);
n[8]: copy n[1] => _23 @ bb4[12]: fn invalid; _23 = _1;
n[9]: copy n[8] => _22 @ bb4[13]: fn invalid; _22 = move _23 as *mut libc::c_void (Misc);
n[10]: free n[9] => _21 @ bb4[15]: fn invalid; _21 = free(move _22);
n[8]: copy n[1] => _24 @ bb5[8]: fn invalid; _24 = _1;
n[9]: copy n[8] => _23 @ bb5[9]: fn invalid; _23 = move _24 as *mut libc::c_void (Misc);
n[10]: free n[9] => _22 @ bb5[11]: fn invalid; _22 = free(move _23);
}
nodes_that_need_write = [3, 2, 1, 0]

Expand Down Expand Up @@ -458,7 +460,7 @@ g {
n[12]: value.load _ => _19 @ bb7[4]: fn fdevent_unregister; _19 = ((*_1).0: *mut *mut pointers::fdnode_st);
n[13]: offset[0] n[12] => _18 @ bb7[10]: fn fdevent_unregister; _18 = offset(move _19, move _20);
n[14]: copy n[13] => _17 @ bb8[3]: fn fdevent_unregister; _17 = &mut (*_18);
n[15]: addr.store n[14] => _ @ bb8[4]: fn fdevent_unregister; (*_17) = const 0_usize as *mut pointers::fdnode_st (PointerFromExposedAddress);
n[15]: addr.store n[14] => _ @ bb9[0]: fn fdevent_unregister; (*_17) = move _22;
n[16]: copy n[1] => _20 @ bb6[6]: fn lighttpd_test; _20 = _1;
n[17]: copy n[16] => _19 @ bb6[7]: fn lighttpd_test; _19 = move _20 as *mut libc::c_void (Misc);
n[18]: free n[17] => _18 @ bb6[9]: fn lighttpd_test; _18 = free(move _19);
Expand Down Expand Up @@ -567,8 +569,8 @@ g {
n[29]: value.load _ => _3 @ bb1[2]: fn fdevent_unregister; _3 = (*_4);
n[30]: copy n[29] => _12 @ bb1[11]: fn fdevent_unregister; _12 = _3;
n[31]: ptr_to_int n[30] => _ @ bb1[12]: fn fdevent_unregister; _11 = move _12 as usize (PointerExposeAddress);
n[32]: copy n[29] => _23 @ bb8[7]: fn fdevent_unregister; _23 = _3;
n[33]: copy n[32] => _1 @ bb0[0]: fn fdnode_free; _22 = fdnode_free(move _23);
n[32]: copy n[29] => _24 @ bb9[4]: fn fdevent_unregister; _24 = _3;
n[33]: copy n[32] => _1 @ bb0[0]: fn fdnode_free; _23 = fdnode_free(move _24);
n[34]: copy n[33] => _4 @ bb0[3]: fn fdnode_free; _4 = _1;
n[35]: copy n[34] => _3 @ bb0[4]: fn fdnode_free; _3 = move _4 as *mut libc::c_void (Misc);
n[36]: free n[35] => _2 @ bb0[6]: fn fdnode_free; _2 = free(move _3);
Expand Down Expand Up @@ -942,16 +944,16 @@ g {
nodes_that_need_write = [75, 74, 73, 66, 65, 64, 63, 62, 61, 54, 53, 52, 45, 44, 43, 33, 32, 31, 27, 26, 25, 15, 14, 13, 6, 5, 4, 0]

g {
n[0]: &_4 _ => _3 @ bb0[15]: fn test_ref_field; _3 = &mut _4;
n[1]: field.3 n[0] => _ @ bb0[17]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[2]: field.3 n[1] => _7 @ bb0[17]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[3]: addr.load n[2] => _ @ bb0[17]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[4]: field.3 n[0] => _ @ bb0[18]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
n[5]: field.3 n[4] => _ @ bb0[18]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
n[6]: addr.store n[5] => _ @ bb0[18]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
n[0]: &_4 _ => _3 @ bb2[6]: fn test_ref_field; _3 = &mut _4;
n[1]: field.3 n[0] => _ @ bb2[8]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[2]: field.3 n[1] => _7 @ bb2[8]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[3]: addr.load n[2] => _ @ bb2[8]: fn test_ref_field; _7 = (((*_3).3: pointers::T).3: i32);
n[4]: field.3 n[0] => _ @ bb2[9]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
n[5]: field.3 n[4] => _ @ bb2[9]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
n[6]: addr.store n[5] => _ @ bb2[9]: fn test_ref_field; (((*_3).3: pointers::T).3: i32) = move _7;
}
nodes_that_need_write = [6, 5, 4, 0]

num_graphs = 64
num_nodes = 694
num_nodes = 696