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

utils: supported openssl 1.1.1w, 3.0.13, 3.1.5, 3.2.1 #540

Merged
merged 1 commit into from
May 11, 2024
Merged
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
41 changes: 21 additions & 20 deletions user/module/probe_openssl_lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ import (
)

const (
LinuxDefauleFilename_1_0_2 = "linux_default_1_0_2"
LinuxDefauleFilename_1_1_0 = "linux_default_1_1_0"
LinuxDefauleFilename_1_1_1 = "linux_default_1_1_1"
LinuxDefauleFilename_3_0 = "linux_default_3_0"
LinuxDefauleFilename_3_1 = "linux_default_3_0"
LinuxDefauleFilename_3_2_0 = "linux_default_3_2"
AndroidDefauleFilename = "android_default"
Linuxdefaulefilename102 = "linux_default_1_0_2"
Linuxdefaulefilename110 = "linux_default_1_1_0"
Linuxdefaulefilename111 = "linux_default_1_1_1"
Linuxdefaulefilename30 = "linux_default_3_0"
Linuxdefaulefilename31 = "linux_default_3_0"
Linuxdefaulefilename320 = "linux_default_3_2"
AndroidDefauleFilename = "android_default"

OpenSslVersionLen = 30 // openssl version string length
)

const (
MaxSupportedOpenSSL102Version = 'u'
MaxSupportedOpenSSL110Version = 'l'
MaxSupportedOpenSSL111Version = 'u'
MaxSupportedOpenSSL30Version = 12
MaxSupportedOpenSSL31Version = 4
MaxSupportedOpenSSL32Version = 0
MaxSupportedOpenSSL111Version = 'w'
MaxSupportedOpenSSL30Version = 13
MaxSupportedOpenSSL31Version = 5
MaxSupportedOpenSSL32Version = 1
)

// initOpensslOffset initial BpfMap
func (m *MOpenSSLProbe) initOpensslOffset() {
m.sslVersionBpfMap = map[string]string{
// openssl 1.0.2*
LinuxDefauleFilename_1_0_2: "openssl_1_0_2a_kern.o",
Linuxdefaulefilename102: "openssl_1_0_2a_kern.o",

// openssl 1.1.0*
LinuxDefauleFilename_1_1_0: "openssl_1_1_0a_kern.o",
Linuxdefaulefilename110: "openssl_1_1_0a_kern.o",

// openssl 1.1.1*
LinuxDefauleFilename_1_1_1: "openssl_1_1_1j_kern.o",
Linuxdefaulefilename111: "openssl_1_1_1j_kern.o",

// openssl 3.0.* and openssl 3.1.*
LinuxDefauleFilename_3_0: "openssl_3_0_0_kern.o",
Linuxdefaulefilename30: "openssl_3_0_0_kern.o",

// openssl 3.2.*
LinuxDefauleFilename_3_2_0: "openssl_3_2_0_kern.o",
Linuxdefaulefilename320: "openssl_3_2_0_kern.o",

// boringssl
"boringssl 1.1.1": "boringssl_a_13_kern.o",
Expand Down Expand Up @@ -94,6 +94,7 @@ func (m *MOpenSSLProbe) initOpensslOffset() {

// openssl 3.1.0 - 3.1.4
for ch := 0; ch <= MaxSupportedOpenSSL31Version; ch++ {
// The OpenSSL 3.0 series is the same as the 3.1 series of offsets
m.sslVersionBpfMap[fmt.Sprintf("openssl 3.1.%d", ch)] = "openssl_3_0_0_kern.o"
}

Expand Down Expand Up @@ -233,11 +234,11 @@ func (m *MOpenSSLProbe) detectOpenssl(soPath string) error {
}
} else {
if strings.Contains(soPath, "libssl.so.3") {
bpfFile, _ = m.sslVersionBpfMap[LinuxDefauleFilename_3_0]
m.logger.Info().Str("OpenSSL Version", LinuxDefauleFilename_3_0).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
bpfFile, _ = m.sslVersionBpfMap[Linuxdefaulefilename30]
m.logger.Info().Str("OpenSSL Version", Linuxdefaulefilename30).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
} else {
bpfFile, _ = m.sslVersionBpfMap[LinuxDefauleFilename_1_1_1]
m.logger.Info().Str("OpenSSL Version", LinuxDefauleFilename_1_1_1).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
bpfFile, _ = m.sslVersionBpfMap[Linuxdefaulefilename111]
m.logger.Info().Str("OpenSSL Version", Linuxdefaulefilename111).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
}
}
m.sslBpfFile = bpfFile
Expand Down
2 changes: 2 additions & 0 deletions utils/openssl_offset_1.1.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function run() {
sslVerMap["r"]="j"
sslVerMap["s"]="j"
sslVerMap["u"]="j"
sslVerMap["v"]="j"
sslVerMap["w"]="j"


# exit 0
Expand Down
1 change: 1 addition & 0 deletions utils/openssl_offset_3.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function run() {
sslVerMap["10"]="0"
sslVerMap["11"]="0"
sslVerMap["12"]="0"
sslVerMap["13"]="0"

# shellcheck disable=SC2068
for ver in ${!sslVerMap[@]}; do
Expand Down
5 changes: 3 additions & 2 deletions utils/openssl_offset_3.1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ function run() {
sslVerMap["2"]="0"
sslVerMap["3"]="0"
sslVerMap["4"]="0"
sslVerMap["5"]="0"

# shellcheck disable=SC2068
for ver in ${!sslVerMap[@]}; do
tag="openssl-3.1.${ver}"
val=${sslVerMap[$ver]}
# 3.1.X and 3.0.X OFFSET is the same, use the same for the time being
header_file="${OUTPUT_DIR}/openssl_3_0_${val}_kern.c"
header_file="${OUTPUT_DIR}/openssl_3_1_${val}_kern.c"
header_define="OPENSSL_3_0_$(echo ${val} | tr "[:lower:]" "[:upper:]")_KERN_H"

if [[ -f ${header_file} ]]; then
Expand All @@ -55,7 +56,7 @@ function run() {
make clean
make include/openssl/opensslconf.h
make include/openssl/configuration.h
make build_generated
make build_generated


clang -I include/ -I . offset.c -o offset
Expand Down
3 changes: 3 additions & 0 deletions utils/openssl_offset_3.2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function run() {
cp -f ${PROJECT_ROOT_DIR}/utils/openssl_3_2_0_offset.c ${OPENSSL_DIR}/offset.c
declare -A sslVerMap=()
sslVerMap["0"]="0"
sslVerMap["1"]="0"

# shellcheck disable=SC2068
for ver in ${!sslVerMap[@]}; do
Expand All @@ -45,6 +46,8 @@ function run() {

# ./Configure and make openssl/opensslconf.h
./Configure
make clean
make build_generated


clang -I include/ -I . offset.c -o offset
Expand Down
Loading