Skip to content

Commit

Permalink
fix(test/libsinsp_e2e): fix UAF
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo committed Jul 14, 2024
1 parent cb99b99 commit de076fa
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions test/libsinsp_e2e/sys_call_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2407,33 +2407,33 @@ TEST_F(sys_call_test, thread_lookup_static)
before_close_t before_close = [&](sinsp* inspector)
{
platform = (scap_linux_platform*)inspector->get_scap_platform();
};

ASSERT_NO_FATAL_FAILURE(
{ event_capture::run(test, callback, filter, event_capture::do_nothing, before_close); });
ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 1, &scap_tinfo, err_buf, false));

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 1, &scap_tinfo, err_buf, false));
EXPECT_EQ(1, scap_tinfo.tid);
EXPECT_EQ(1, scap_tinfo.pid);
EXPECT_EQ(1, scap_tinfo.vtid);
EXPECT_EQ(0, scap_tinfo.ptid);

EXPECT_EQ(1, scap_tinfo.tid);
EXPECT_EQ(1, scap_tinfo.pid);
EXPECT_EQ(1, scap_tinfo.vtid);
EXPECT_EQ(0, scap_tinfo.ptid);
ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 62725, &scap_tinfo, err_buf, false));
EXPECT_EQ(62725, scap_tinfo.tid);
EXPECT_EQ(62725, scap_tinfo.pid);
EXPECT_EQ(62725, scap_tinfo.vtid);
EXPECT_EQ(1, scap_tinfo.ptid);

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 62725, &scap_tinfo, err_buf, false));
EXPECT_EQ(62725, scap_tinfo.tid);
EXPECT_EQ(62725, scap_tinfo.pid);
EXPECT_EQ(62725, scap_tinfo.vtid);
EXPECT_EQ(1, scap_tinfo.ptid);
ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 62727, &scap_tinfo, err_buf, false));
EXPECT_EQ(62727, scap_tinfo.tid);
EXPECT_EQ(62725, scap_tinfo.pid);
EXPECT_EQ(62727, scap_tinfo.vtid);
EXPECT_EQ(1, scap_tinfo.ptid);

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 62727, &scap_tinfo, err_buf, false));
EXPECT_EQ(62727, scap_tinfo.tid);
EXPECT_EQ(62725, scap_tinfo.pid);
EXPECT_EQ(62727, scap_tinfo.vtid);
EXPECT_EQ(1, scap_tinfo.ptid);
};

ASSERT_NO_FATAL_FAILURE(
{ event_capture::run(test, callback, filter, event_capture::do_nothing, before_close); });
}

TEST_F(sys_call_test, thread_lookup_live)
Expand Down Expand Up @@ -2488,24 +2488,25 @@ TEST_F(sys_call_test, thread_lookup_live)
// close scap to maintain the num_consumers at exit == 0 assertion
//close_capture(scap, platform);
platform = (scap_linux_platform*)inspector->get_scap_platform();
};
ASSERT_NO_FATAL_FAILURE(
{ event_capture::run(test, callback, filter, event_capture::do_nothing, before_close); });

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, getpid(),
&scap_tinfo, err_buf, false));
EXPECT_EQ(getpid(), scap_tinfo.tid);
EXPECT_EQ(getpid(), scap_tinfo.pid);
EXPECT_EQ(getpid(), scap_tinfo.vtid);
EXPECT_EQ(getppid(), scap_tinfo.ptid);

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 1,
&scap_tinfo, err_buf, false));
EXPECT_EQ(1, scap_tinfo.tid);
EXPECT_EQ(1, scap_tinfo.pid);
EXPECT_EQ(1, scap_tinfo.vtid);
EXPECT_EQ(0, scap_tinfo.ptid);
ASSERT_NO_FATAL_FAILURE(
{ event_capture::run(test, callback, filter, event_capture::do_nothing, before_close); });

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, getpid(),
&scap_tinfo, err_buf, false));
EXPECT_EQ(getpid(), scap_tinfo.tid);
EXPECT_EQ(getpid(), scap_tinfo.pid);
EXPECT_EQ(getpid(), scap_tinfo.vtid);
EXPECT_EQ(getppid(), scap_tinfo.ptid);

ASSERT_EQ(SCAP_SUCCESS,
scap_proc_read_thread(platform, proc, 1,
&scap_tinfo, err_buf, false));
EXPECT_EQ(1, scap_tinfo.tid);
EXPECT_EQ(1, scap_tinfo.pid);
EXPECT_EQ(1, scap_tinfo.vtid);
EXPECT_EQ(0, scap_tinfo.ptid);
};

}

0 comments on commit de076fa

Please sign in to comment.