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

Push 2024 07 06 #777

Merged
merged 53 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5cf322b
add service file for build.opensuse.org
rdementi Jun 21, 2024
4bf7325
add PCM_HARDENING_FLAGS
rdementi Jun 21, 2024
211e11d
add -fstack-protector option
rdementi Jun 21, 2024
af97dd1
add -D_FORTIFY_SOURCE=2
rdementi Jun 21, 2024
5e4c279
added corpus for urltest-fuzz
rdementi Jun 22, 2024
b6f2b67
use the corpus and refactor fuzz.sh
rdementi Jun 22, 2024
1692c5e
add fuzzer for pcm-sensor-server
rdementi Jun 24, 2024
5ad7a93
replace files with human readable corpus
rdementi Jun 24, 2024
8bd3024
print errno string
rdementi Jun 24, 2024
f818668
recv may fail sometimes
rdementi Jun 24, 2024
d62a429
fix 'invalid format character' error
rdementi Jun 24, 2024
fdca530
the scripts require bash. call bash explicitly
rdementi Jun 25, 2024
637119d
ignore leaks on libFuzzer side use
rdementi Jun 25, 2024
7ac4e31
fix a memory leak and throw exception with verbose reason
rdementi Jun 25, 2024
f8dda06
fix heap-buffer-overflow
rdementi Jun 25, 2024
e8219da
add /sys/fs/cgroup/cpuset/cpuset.cpus diagnostic message in tests (fo…
rdementi Jun 25, 2024
14dc7ac
make fuzzing period configurable
rdementi Jun 26, 2024
00369a0
make the fuzz-job run long on saturdays
rdementi Jun 26, 2024
78bda31
add fuzz-short-job
rdementi Jun 26, 2024
cc5d6e2
add on-push/pr micro fuzzing job
rdementi Jun 26, 2024
8c7d1cf
Stop using deprecated functions (#643)
ogbrugge-work Jun 27, 2024
f1c7703
fix a memory leak in SSL code
rdementi Jun 26, 2024
c4a205a
set pointers to nullptr after delete or free
rdementi Jun 28, 2024
4546df0
address warning: nullptr check
rdementi Jun 28, 2024
14e51ab
cmake: print more flags
rdementi Jun 28, 2024
3cb171b
more hardening compile flags
rdementi Jun 28, 2024
d103314
fix compilation on old gcc
rdementi Jun 28, 2024
2aff41b
do not include shared library code into pcm-core executable
rdementi Jun 28, 2024
4fe5318
delete forbidden methods
rdementi Jun 28, 2024
6cbab91
fix linking with asan
rdementi Jun 28, 2024
f1bd4a1
use compiled lib, not the installed one
rdementi Jun 29, 2024
8cf0a33
avoid pre-mature PCM init triggered by global counter state init
rdementi Jun 29, 2024
cf9f5d2
workaround a known bug with sanitizers
rdementi Jun 29, 2024
17c10e4
add -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
rdementi Jun 29, 2024
6a6ce98
harden the debug build too
rdementi Jun 29, 2024
98d9f98
fix compilation on gcc48
rdementi Jun 29, 2024
dc7f402
pcm-latency: avoid pre-mature PCM init triggered by global counter st…
rdementi Jun 29, 2024
4b92b80
run long fuzzer every every sunday at midnight
rdementi Jun 30, 2024
c461cd1
increase rss limit
rdementi Jun 30, 2024
65cfffa
reduce the duration fuzzing CI job to fit the GH timeout budget
rdementi Jun 30, 2024
aa549b1
parameter value checks
rdementi Jun 30, 2024
fd799ec
Merge remote-tracking branch 'opcm-github/master'
rdementi Jul 1, 2024
04d7db9
Merge remote-tracking branch 'opcm-github/master'
rdementi Jul 1, 2024
c15964c
Merge remote-tracking branch 'opcm-github/master'
rdementi Jul 1, 2024
6f4f68f
add pcm-sensor-server fuzzing with SSL
rdementi Jun 26, 2024
950db07
give more memory
rdementi Jun 27, 2024
bcfacbc
address review comments
rdementi Jun 27, 2024
cb88931
Suppress leaks in libcrypto
rdementi Jul 2, 2024
1054ddf
introduce -DNO_STATIC_MSVC_RUNTIME_LIBRARY=1 cmake option
rdementi Jul 3, 2024
af0376c
the second rank can be -1
rdementi Jul 4, 2024
84953ec
use -static-libasan option
rdementi Jul 4, 2024
c614ba6
drop support for gcc 4.8 - gcc 7.x
rdementi Jul 4, 2024
5ced9e2
support g++-7 on gcc9 runner
rdementi Jul 5, 2024
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
44 changes: 0 additions & 44 deletions .github/workflows/ci-gcc48.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/ci-gcc5.yml

This file was deleted.

24 changes: 7 additions & 17 deletions .github/workflows/ci-gcc7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
build:

runs-on: ci-gcc7
runs-on: ci-gcc9
if: ${{ github.repository != 'intel/pcm' }}

steps:
Expand All @@ -21,26 +21,16 @@ jobs:
with:
egress-policy: audit

- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: install simdjson
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
repository: simdjson/simdjson
path: src/simdjson
submodules: recursive
- name: Configure CMake
run: |
cmake --version
rm -rf ${{ github.workspace }}/build && mkdir ${{ github.workspace }}/build
cd ${{ github.workspace }}/build
cmake -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build ..
- name: Build
run: |
g++ --version
cd ${{ github.workspace }}/build
make -j$(nproc)
- name: Install
rm -rf ${{ github.workspace }}/build
CXX=g++-7 CC=gcc-7 cmake -B ${{ github.workspace }}/build -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build
- name: Build and Install
run: |
g++-7 --version
cd ${{ github.workspace }}/build
make install -j$(nproc)
- name: Diagnostic
run: date
19 changes: 14 additions & 5 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ if(UNIX) # LINUX, FREE_BSD, APPLE
add_subdirectory(MacMSRDriver)
include_directories("${CMAKE_SOURCE_DIR}/src/MacMSRDriver") # target_include_directories doesn't work
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT PcmMsr Threads::Threads)
elseif(LINUX)
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads asan)
else()
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads)
endif()
Expand All @@ -66,14 +64,21 @@ if(MSVC)
file(GLOB WINDOWS_SOURCES winpmem/winpmem.cpp windows/stdafx.cpp freegetopt/getopt.cpp)
add_library(PCM_STATIC STATIC ${COMMON_SOURCES} ${WINDOWS_SOURCES})
target_compile_definitions(PCM_STATIC PRIVATE UNICODE _UNICODE _CONSOLE)
target_compile_options(PCM_STATIC PRIVATE "/MT$<$<CONFIG:Debug>:d>")
if (NO_STATIC_MSVC_RUNTIME_LIBRARY)
set(PCM_MSVC_RUNTIME_LIBRARY_OPTIONS "")
else()
set(PCM_MSVC_RUNTIME_LIBRARY_OPTIONS "/MT$<$<CONFIG:Debug>:d>")
message(STATUS "Using static MSVC runtime library")
message(STATUS "To use default/dynamic MSVC runtime library, use -DNO_STATIC_MSVC_RUNTIME_LIBRARY=1 option")
endif()
target_compile_options(PCM_STATIC PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")

# Graphical perfmon front-end: pcm-lib, pcm-service
# Files: COMMON_FILES() + pcm-lib.cpp winpmem\winpmem.cpp dllmain.cpp
file(GLOB PCM_LIB_SOURCES winpmem/winpmem.cpp dllmain.cpp pcm-lib.cpp )
add_library(pcm-lib SHARED ${COMMON_SOURCES} ${PCM_LIB_SOURCES})
target_compile_definitions(pcm-lib PRIVATE _WINDOWS _USRDLL PCM_EXPORTS _WINDLL _UNICODE UNICODE)
target_compile_options(pcm-lib PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(pcm-lib PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")

# Pcm-service files: PCM_SHARED + AssemblyInfo.cpp PCMInstaller.cpp PCMService.cpp
file(GLOB PCM_SERVICE_SOURCES windows/PCMInstaller.cpp windows/PCMService.cpp windows/AssemblyInfo.cpp winddows/utils.cpp)
Expand Down Expand Up @@ -139,9 +144,13 @@ foreach(PROJECT_NAME ${PROJECT_NAMES})
add_executable(${PROJECT_NAME} ${PROJECT_FILE})

if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE "/MT$<$<CONFIG:Debug>:d>")
target_compile_options(${PROJECT_NAME} PRIVATE "${PCM_MSVC_RUNTIME_LIBRARY_OPTIONS}")
endif(MSVC)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static-libasan")
endif()

# specific file for pcm-raw project
if(${PROJECT_NAME} STREQUAL pcm-raw)
set(LIBS ${LIBS} PCM_SIMDJSON)
Expand Down
19 changes: 10 additions & 9 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8712,27 +8712,28 @@ void ServerUncorePMUs::programServerUncoreMemoryMetrics(const ServerUncoreMemory
std::cerr << "PCM Error: invalid rankA value: " << rankA << "\n";
return;
}
if (rankB < 0 || rankB > 7)
{
std::cerr << "PCM Error: invalid rankB value: " << rankB << "\n";
return;
}
switch(cpu_model)
{
case PCM::IVYTOWN:
MCCntConfig[EventPosition::READ_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::WRITE_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankB) all banks
if (rankB >= 0 && rankB <= 7)
{
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(0xff); // WR_CAS_RANK(rankB) all banks
}
break;
case PCM::HASWELLX:
case PCM::BDX_DE:
case PCM::BDX:
case PCM::SKX:
MCCntConfig[EventPosition::READ_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::WRITE_RANK_A] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankA)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankA) all banks
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankB) all banks
if (rankB >= 0 && rankB <= 7)
{
MCCntConfig[EventPosition::READ_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb0 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // RD_CAS_RANK(rankB) all banks
MCCntConfig[EventPosition::WRITE_RANK_B] = MC_CH_PCI_PMON_CTL_EVENT((0xb8 + rankB)) + MC_CH_PCI_PMON_CTL_UMASK(16); // WR_CAS_RANK(rankB) all banks
}
break;
case PCM::KNL:
MCCntConfig[EventPosition::READ] = MC_CH_PCI_PMON_CTL_EVENT(0x03) + MC_CH_PCI_PMON_CTL_UMASK(1); // monitor reads on counter 0: CAS.RD
Expand Down
1 change: 1 addition & 0 deletions src/pcm-sensor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ class basic_socketbuf : public std::basic_streambuf<CharT> {
bytesReceived = SSL_read( ssl_, static_cast<void*>(inputBuffer_), SIZE * sizeof( char_type ) );
if ( 0 >= bytesReceived ) {
int sslError = SSL_get_error( ssl_, bytesReceived );
ERR_print_errors_fp(stderr);
switch ( sslError ) {
case SSL_ERROR_WANT_READ:
case SSL_ERROR_WANT_WRITE:
Expand Down
8 changes: 7 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ if(UNIX)
endif(UNIX)

if(FUZZ)
find_package(OpenSSL REQUIRED)
set(SSL_LIBS OpenSSL::SSL OpenSSL::Crypto)
add_executable(urltest-fuzz urltest-fuzz.cpp)
add_executable(pcm-sensor-server-fuzz pcm-sensor-server-fuzz.cpp)
add_executable(pcm-sensor-server-ssl-fuzz pcm-sensor-server-fuzz.cpp)
target_compile_options(pcm-sensor-server-fuzz PRIVATE -DUSE_SSL=1)
target_compile_options(pcm-sensor-server-ssl-fuzz PRIVATE -DUSE_SSL=1 -DFUZZ_USE_SSL=1)
add_executable(pcm-fuzz pcm-fuzz.cpp)
add_executable(pcm-memory-fuzz pcm-memory-fuzz.cpp)
target_link_libraries(urltest-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-sensor-server-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-sensor-server-fuzz Threads::Threads PCM_STATIC ${SSL_LIBS})
target_link_libraries(pcm-sensor-server-ssl-fuzz Threads::Threads PCM_STATIC ${SSL_LIBS})
target_link_libraries(pcm-fuzz Threads::Threads PCM_STATIC)
target_link_libraries(pcm-memory-fuzz Threads::Threads PCM_STATIC)
endif()
29 changes: 29 additions & 0 deletions tests/fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ if [ "$#" -eq 1 ]; then
factor=$1
fi

# Suppress leaks in libcrypto
# Below is caused by openssl leaks
# similar to https://github.com/spdk/spdk/issues/2947
echo leak:libcrypto.so >> pcm_asan_suppression_file
export LSAN_OPTIONS=suppressions="pcm_asan_suppression_file"

echo "Running fuzz tests with running time multiplier $factor"

CC=`which clang` CXX=`which clang++` cmake .. -DCMAKE_BUILD_TYPE=Debug -DFUZZ=1 && mkdir -p corpus &&
make urltest-fuzz \
pcm-fuzz \
pcm-memory-fuzz \
pcm-sensor-server-fuzz \
pcm-sensor-server-ssl-fuzz \
-j &&
rm -rf corpus/* &&
printf '%b' "GET / HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/1 &&
Expand All @@ -34,6 +41,26 @@ printf '%b' "GET /dashboard/prometheus HTTP/1.1\r\nHost: localhost\r\nAccept: */
printf '%b' "GET /dashboard/prometheus/default HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/10 &&
printf '%b' "GET /dashboard HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/11 &&
printf '%b' "GET /favicon.ico HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/12 &&
LLVM_PROFILE_FILE="pcm-sensor-server-ssl.profraw" bin/tests/pcm-sensor-server-ssl-fuzz -detect_leaks=0 -max_total_time=$((10 * $factor)) -rss_limit_mb=10000 corpus > /dev/null &&
rm -rf corpus/* &&
printf '%b' "GET / HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/1 &&
printf '%b' "GET /metrics HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/2 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/3 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/3.1 &&
printf '%b' "GET /persecond HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/3.2 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/4 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/4.1 &&
printf '%b' "GET /persecond/1 HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/4.2 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/5 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/5.1 &&
printf '%b' "GET /persecond/10 HTTP/1.1\r\nHost: localhost\r\nAccept: text/plain; version=0.0.4\r\n\r\n" > corpus/5.2 &&
printf '%b' "GET /persecond/100 HTTP/1.1\r\nHost: localhost\r\nAccept: application/json\r\n\r\n" > corpus/6 &&
printf '%b' "GET /metrics HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/7 &&
printf '%b' "GET /dashboard/influxdb HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/8 &&
printf '%b' "GET /dashboard/prometheus HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/9 &&
printf '%b' "GET /dashboard/prometheus/default HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/10 &&
printf '%b' "GET /dashboard HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/11 &&
printf '%b' "GET /favicon.ico HTTP/1.1\r\nHost: localhost\r\nAccept: */*\r\n\r\n" > corpus/12 &&
LLVM_PROFILE_FILE="pcm-sensor-server.profraw" bin/tests/pcm-sensor-server-fuzz -detect_leaks=0 -rss_limit_mb=10000 -max_total_time=$((10 * $factor)) corpus > /dev/null &&
rm -rf corpus/* &&
printf '%b' "http://otto:[email protected]/~otto/file1.txt" > corpus/1 &&
Expand Down Expand Up @@ -71,11 +98,13 @@ llvm-profdata merge -sparse \
pcm.nmi_watchdog.profraw \
pcm-memory.profraw \
pcm-sensor-server.profraw \
pcm-sensor-server-ssl.profraw \
-o all.profdata &&
llvm-cov report --summary-only \
-object ./bin/tests/pcm-fuzz \
-object ./bin/tests/urltest-fuzz \
-object ./bin/tests/pcm-memory-fuzz \
-object ./bin/tests/pcm-sensor-server-fuzz \
-object ./bin/tests/pcm-sensor-server-ssl-fuzz \
-instr-profile=all.profdata | tee report.txt

Loading
Loading