Skip to content

Commit 4e7db09

Browse files
authored
utils: supported openssl 1.1.1w, 3.0.13, 3.1.5, 3.2.1 (#540)
Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
1 parent 3c53dd3 commit 4e7db09

5 files changed

Lines changed: 30 additions & 22 deletions

File tree

user/module/probe_openssl_lib.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,43 +24,43 @@ import (
2424
)
2525

2626
const (
27-
LinuxDefauleFilename_1_0_2 = "linux_default_1_0_2"
28-
LinuxDefauleFilename_1_1_0 = "linux_default_1_1_0"
29-
LinuxDefauleFilename_1_1_1 = "linux_default_1_1_1"
30-
LinuxDefauleFilename_3_0 = "linux_default_3_0"
31-
LinuxDefauleFilename_3_1 = "linux_default_3_0"
32-
LinuxDefauleFilename_3_2_0 = "linux_default_3_2"
33-
AndroidDefauleFilename = "android_default"
27+
Linuxdefaulefilename102 = "linux_default_1_0_2"
28+
Linuxdefaulefilename110 = "linux_default_1_1_0"
29+
Linuxdefaulefilename111 = "linux_default_1_1_1"
30+
Linuxdefaulefilename30 = "linux_default_3_0"
31+
Linuxdefaulefilename31 = "linux_default_3_0"
32+
Linuxdefaulefilename320 = "linux_default_3_2"
33+
AndroidDefauleFilename = "android_default"
3434

3535
OpenSslVersionLen = 30 // openssl version string length
3636
)
3737

3838
const (
3939
MaxSupportedOpenSSL102Version = 'u'
4040
MaxSupportedOpenSSL110Version = 'l'
41-
MaxSupportedOpenSSL111Version = 'u'
42-
MaxSupportedOpenSSL30Version = 12
43-
MaxSupportedOpenSSL31Version = 4
44-
MaxSupportedOpenSSL32Version = 0
41+
MaxSupportedOpenSSL111Version = 'w'
42+
MaxSupportedOpenSSL30Version = 13
43+
MaxSupportedOpenSSL31Version = 5
44+
MaxSupportedOpenSSL32Version = 1
4545
)
4646

4747
// initOpensslOffset initial BpfMap
4848
func (m *MOpenSSLProbe) initOpensslOffset() {
4949
m.sslVersionBpfMap = map[string]string{
5050
// openssl 1.0.2*
51-
LinuxDefauleFilename_1_0_2: "openssl_1_0_2a_kern.o",
51+
Linuxdefaulefilename102: "openssl_1_0_2a_kern.o",
5252

5353
// openssl 1.1.0*
54-
LinuxDefauleFilename_1_1_0: "openssl_1_1_0a_kern.o",
54+
Linuxdefaulefilename110: "openssl_1_1_0a_kern.o",
5555

5656
// openssl 1.1.1*
57-
LinuxDefauleFilename_1_1_1: "openssl_1_1_1j_kern.o",
57+
Linuxdefaulefilename111: "openssl_1_1_1j_kern.o",
5858

5959
// openssl 3.0.* and openssl 3.1.*
60-
LinuxDefauleFilename_3_0: "openssl_3_0_0_kern.o",
60+
Linuxdefaulefilename30: "openssl_3_0_0_kern.o",
6161

6262
// openssl 3.2.*
63-
LinuxDefauleFilename_3_2_0: "openssl_3_2_0_kern.o",
63+
Linuxdefaulefilename320: "openssl_3_2_0_kern.o",
6464

6565
// boringssl
6666
"boringssl 1.1.1": "boringssl_a_13_kern.o",
@@ -94,6 +94,7 @@ func (m *MOpenSSLProbe) initOpensslOffset() {
9494

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

@@ -233,11 +234,11 @@ func (m *MOpenSSLProbe) detectOpenssl(soPath string) error {
233234
}
234235
} else {
235236
if strings.Contains(soPath, "libssl.so.3") {
236-
bpfFile, _ = m.sslVersionBpfMap[LinuxDefauleFilename_3_0]
237-
m.logger.Info().Str("OpenSSL Version", LinuxDefauleFilename_3_0).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
237+
bpfFile, _ = m.sslVersionBpfMap[Linuxdefaulefilename30]
238+
m.logger.Info().Str("OpenSSL Version", Linuxdefaulefilename30).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
238239
} else {
239-
bpfFile, _ = m.sslVersionBpfMap[LinuxDefauleFilename_1_1_1]
240-
m.logger.Info().Str("OpenSSL Version", LinuxDefauleFilename_1_1_1).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
240+
bpfFile, _ = m.sslVersionBpfMap[Linuxdefaulefilename111]
241+
m.logger.Info().Str("OpenSSL Version", Linuxdefaulefilename111).Msg("OpenSSL/BoringSSL version not found from shared library file, used default version")
241242
}
242243
}
243244
m.sslBpfFile = bpfFile

utils/openssl_offset_1.1.1.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ function run() {
4545
sslVerMap["r"]="j"
4646
sslVerMap["s"]="j"
4747
sslVerMap["u"]="j"
48+
sslVerMap["v"]="j"
49+
sslVerMap["w"]="j"
4850

4951

5052
# exit 0

utils/openssl_offset_3.0.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function run() {
3838
sslVerMap["10"]="0"
3939
sslVerMap["11"]="0"
4040
sslVerMap["12"]="0"
41+
sslVerMap["13"]="0"
4142

4243
# shellcheck disable=SC2068
4344
for ver in ${!sslVerMap[@]}; do

utils/openssl_offset_3.1.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ function run() {
3030
sslVerMap["2"]="0"
3131
sslVerMap["3"]="0"
3232
sslVerMap["4"]="0"
33+
sslVerMap["5"]="0"
3334

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

4243
if [[ -f ${header_file} ]]; then
@@ -55,7 +56,7 @@ function run() {
5556
make clean
5657
make include/openssl/opensslconf.h
5758
make include/openssl/configuration.h
58-
make build_generated
59+
make build_generated
5960

6061

6162
clang -I include/ -I . offset.c -o offset

utils/openssl_offset_3.2.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function run() {
2626
cp -f ${PROJECT_ROOT_DIR}/utils/openssl_3_2_0_offset.c ${OPENSSL_DIR}/offset.c
2727
declare -A sslVerMap=()
2828
sslVerMap["0"]="0"
29+
sslVerMap["1"]="0"
2930

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

4647
# ./Configure and make openssl/opensslconf.h
4748
./Configure
49+
make clean
50+
make build_generated
4851

4952

5053
clang -I include/ -I . offset.c -o offset

0 commit comments

Comments
 (0)