From 0b3eceddf4c7547f05aa3351ded1e8a2dc7f56e0 Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Sun, 12 Jun 2022 09:37:17 +0300 Subject: [PATCH] Fix some of the issues on ARM64 --- .../Dockerfile | 2 +- tap/tlstapper/bpf/include/common.h | 2 +- tap/tlstapper/bpf/include/go_types.h | 2 +- tap/tlstapper/bpf/include/headers.h | 1 - tap/tlstapper/go_offsets.go | 20 ++++++++++++++---- tap/tlstapper/tlstapper_bpfeb.o | Bin 155800 -> 155800 bytes tap/tlstapper/tlstapper_bpfel.o | Bin 156616 -> 156616 bytes 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/devops/linux-x86_64-musl-go-libpcap-capstone/Dockerfile b/devops/linux-x86_64-musl-go-libpcap-capstone/Dockerfile index fc7a40bd5..d413bda76 100644 --- a/devops/linux-x86_64-musl-go-libpcap-capstone/Dockerfile +++ b/devops/linux-x86_64-musl-go-libpcap-capstone/Dockerfile @@ -34,6 +34,6 @@ WORKDIR / # Build and install Capstone from source RUN curl https://github.com/aquynh/capstone/archive/4.0.2.tar.gz -Lo ./capstone.tar.gz \ && tar -xzf capstone.tar.gz && mv ./capstone-* ./capstone -WORKDIR /work/capstone +WORKDIR /capstone RUN ./make.sh \ && ./make.sh install diff --git a/tap/tlstapper/bpf/include/common.h b/tap/tlstapper/bpf/include/common.h index fcffd3e2f..613376396 100644 --- a/tap/tlstapper/bpf/include/common.h +++ b/tap/tlstapper/bpf/include/common.h @@ -7,7 +7,7 @@ Copyright (C) UP9 Inc. #ifndef __COMMON__ #define __COMMON__ -const int32_t invalid_fd = -1; +const __s32 invalid_fd = -1; static int add_address_to_chunk(struct pt_regs *ctx, struct tls_chunk* chunk, __u64 id, __u32 fd); static void send_chunk_part(struct pt_regs *ctx, __u8* buffer, __u64 id, struct tls_chunk* chunk, int start, int end); diff --git a/tap/tlstapper/bpf/include/go_types.h b/tap/tlstapper/bpf/include/go_types.h index b6cd1b78b..c865448c6 100644 --- a/tap/tlstapper/bpf/include/go_types.h +++ b/tap/tlstapper/bpf/include/go_types.h @@ -8,7 +8,7 @@ Copyright (C) UP9 Inc. #define __GO_TYPES__ struct go_interface { - int64_t type; + __s64 type; void* ptr; }; diff --git a/tap/tlstapper/bpf/include/headers.h b/tap/tlstapper/bpf/include/headers.h index 756a92407..8078051af 100644 --- a/tap/tlstapper/bpf/include/headers.h +++ b/tap/tlstapper/bpf/include/headers.h @@ -8,7 +8,6 @@ Copyright (C) UP9 Inc. #define __HEADERS__ #include -#include #include #include #include diff --git a/tap/tlstapper/go_offsets.go b/tap/tlstapper/go_offsets.go index 2a202382f..5a10d6110 100644 --- a/tap/tlstapper/go_offsets.go +++ b/tap/tlstapper/go_offsets.go @@ -5,6 +5,7 @@ import ( "debug/elf" "fmt" "os" + "runtime" "github.com/Masterminds/semver" "github.com/cilium/ebpf/link" @@ -66,10 +67,21 @@ func findGoOffsets(filePath string) (goOffsets, error) { func getOffsets(filePath string) (offsets map[string]*goExtendedOffset, err error) { var engine gapstone.Engine - engine, err = gapstone.New( - gapstone.CS_ARCH_X86, - gapstone.CS_MODE_64, - ) + switch runtime.GOARCH { + case "amd64": + engine, err = gapstone.New( + gapstone.CS_ARCH_X86, + gapstone.CS_MODE_64, + ) + case "arm64": + engine, err = gapstone.New( + gapstone.CS_ARCH_ARM64, + gapstone.CS_MODE_ARM, + ) + default: + err = fmt.Errorf("Unsupported architecture: %v", runtime.GOARCH) + return + } if err != nil { return } diff --git a/tap/tlstapper/tlstapper_bpfeb.o b/tap/tlstapper/tlstapper_bpfeb.o index 2a68d1638b5e6bbb097388b5856162f743c48eae..ce984dfd4a44aa9e1fe753dbaf3f1c9de70b5ad8 100644 GIT binary patch delta 177 zcmbPnkaNaC&J8B#7|(1rJ;%>sn8U{a1|dL_k%2+E9Lo2G^83*Eizk;}Qx{wT6^(+b z+BkXbHF3%9{9rS{=7oVt1_lsn8(Ke1|dL_k%2+E63X|6@+YA2mrgFdrY^V&DjEe< zwR!T|YvPhS`N3v@%?ksQ3=AwlGY?L_drh42Drf)R+zp?q&BzYmSSc=Do~>X9p;qES#) z8-aYFZhjz_K@da$fdUY3M-mSM2?7BN5bsA4j|PiE#E)-Qy7f|7Fh0K6*oYxBuPiYq qGbKJPg<6x)i=8T2g7sfKFvjG6&U@0&F delta 199 zcmX?cob$wS&JBqd8P9D_y2#IAn5WDD0(>Drf)R)-p?q&Be*zkR>EuN>)gxCyMWdjq zHUs%U-TXi