Skip to content

Commit f47ec06

Browse files
committed
ebpf: add trace wolfSSL_write() and wolfSSL_read() using eBPF uprobes.
Includes: - TLS client and server examples - eBPF programs for write/read entry and read return - userspace loader with perf buffer handling - automatic symbol lookup (no hardcoded offsets) - x86_64 and ARM64 register handling - full README with usage, architecture, and explanation Shows how to observe TLS plaintext inside applications without modifying wolfSSL or application code. Signed-off-by: sameeh.jubran <sameeh@wolfssl.com>
1 parent fef429e commit f47ec06

File tree

15 files changed

+1656
-12
lines changed

15 files changed

+1656
-12
lines changed

ebpf/syscall-write-trace/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Makefile for syscall-write-trace example
2-
31
CC = gcc
42
CLANG = clang
53

ebpf/syscall-write-trace/client-tcp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* client-tcp.c
22
*
3-
* Copyright (C) 2006-2020 wolfSSL Inc.
3+
* Copyright (C) 2006-2025 wolfSSL Inc.
44
*
5-
* This file is part of wolfSSL. (formerly known as CyaSSL)
5+
* This file is part of wolfSSL.
66
*
77
* wolfSSL is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
9-
* the Free Software Foundation; either version 2 of the License, or
9+
* the Free Software Foundation; either version 3 of the License, or
1010
* (at your option) any later version.
1111
*
1212
* wolfSSL is distributed in the hope that it will be useful,
@@ -16,7 +16,7 @@
1616
*
1717
* You should have received a copy of the GNU General Public License
1818
* along with this program; if not, write to the Free Software
19-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

2222
/* the usual suspects */

ebpf/syscall-write-trace/server-tcp.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/* server-tcp.c
22
*
3-
* Copyright (C) 2006-2020 wolfSSL Inc.
3+
* Copyright (C) 2006-2025 wolfSSL Inc.
44
*
5-
* This file is part of wolfSSL. (formerly known as CyaSSL)
5+
* This file is part of wolfSSL.
66
*
77
* wolfSSL is free software; you can redistribute it and/or modify
88
* it under the terms of the GNU General Public License as published by
9-
* the Free Software Foundation; either version 2 of the License, or
9+
* the Free Software Foundation; either version 3 of the License, or
1010
* (at your option) any later version.
1111
*
1212
* wolfSSL is distributed in the hope that it will be useful,
@@ -16,10 +16,9 @@
1616
*
1717
* You should have received a copy of the GNU General Public License
1818
* along with this program; if not, write to the Free Software
19-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22-
/* the usual suspects */
2322
#include <stdlib.h>
2423
#include <stdio.h>
2524
#include <string.h>

ebpf/syscall-write-trace/write_tracer.bpf.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
// SPDX-License-Identifier: GPL-2.0
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
/* wolfssl_tracer.bpf.c
4+
*
5+
* Copyright (C) 2006-2025 wolfSSL Inc.
6+
*
7+
* This file is part of wolfSSL.
8+
*
9+
* wolfSSL is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License as published by
11+
* the Free Software Foundation; either version 2 of the License, or
12+
* (at your option) any later version.
13+
*
14+
* wolfSSL is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
22+
*/
23+
224
#include <linux/bpf.h>
325
#include <bpf/bpf_helpers.h>
426
#include <bpf/bpf_tracing.h>

ebpf/syscall-write-trace/write_tracer.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/* write_tracer.c
2+
*
3+
* Copyright (C) 2006-2025 wolfSSL Inc.
4+
*
5+
* This file is part of wolfSSL.
6+
*
7+
* wolfSSL is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* wolfSSL is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program; if not, write to the Free Software
19+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20+
*/
21+
122
#include <stdio.h>
223
#include <stdlib.h>
324
#include <string.h>

ebpf/tls-uprobe-trace/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Binaries
2+
client-tls
3+
server-tls
4+
wolfssl_uprobe
5+
*.o
6+
*.bpf.o
7+
*.log
8+
9+
# Editor files
10+
*~
11+
*.swp
12+
.DS_Store
13+

ebpf/tls-uprobe-trace/Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
CC = gcc
2+
CLANG = clang
3+
CFLAGS = -O2 -g -Wall
4+
5+
# Auto-detect host arch, convert to BPF target name
6+
UNAME_M := $(shell uname -m)
7+
8+
ifeq ($(UNAME_M), x86_64)
9+
BPF_ARCH := x86
10+
UAPI_PATH := /usr/include/x86_64-linux-gnu
11+
else ifeq ($(UNAME_M), aarch64)
12+
BPF_ARCH := arm64
13+
UAPI_PATH := /usr/include/aarch64-linux-gnu
14+
else
15+
$(error Unsupported architecture: $(UNAME_M))
16+
endif
17+
18+
BPF_CFLAGS = -O2 -g -target bpf -D__TARGET_ARCH_$(BPF_ARCH)
19+
20+
LIBBPF_LIBS = -lbpf -lelf -lz
21+
22+
TARGETS = client-tls server-tls wolfssl_uprobe wolfssl_uprobe.bpf.o
23+
24+
all: $(TARGETS)
25+
26+
# ===== TLS Programs =====
27+
client-tls: client-tls.c
28+
$(CC) $(CFLAGS) $< -o $@ -lwolfssl
29+
30+
server-tls: server-tls.c
31+
$(CC) $(CFLAGS) $< -o $@ -lwolfssl
32+
33+
# ===== eBPF Program =====
34+
wolfssl_uprobe.bpf.o: wolfssl_uprobe.bpf.c
35+
$(CLANG) $(BPF_CFLAGS) \
36+
-I/usr/include \
37+
-I$(UAPI_PATH) \
38+
-c $< -o $@
39+
40+
wolfssl_uprobe: wolfssl_uprobe.c wolfssl_uprobe.bpf.o
41+
$(CC) $(CFLAGS) $< -o $@ $(LIBBPF_LIBS)
42+
43+
clean:
44+
rm -f $(TARGETS) *.o *.log

0 commit comments

Comments
 (0)