@@ -25,6 +25,11 @@ pub struct DataBuf {
25
25
pub buf : [ u8 ; uprobe_libcall_filter_common:: DATA_BUF_CAPACITY ] ,
26
26
}
27
27
28
+ struct c_ptr ( * const core:: ffi:: c_void ) ;
29
+ unsafe impl Send for c_ptr { }
30
+ unsafe impl Sync for c_ptr { }
31
+
32
+
28
33
// Data structures for exchanging SSL_read data with user space
29
34
#[ map]
30
35
static SSLREADDATABUF : PerCpuArray < DataBuf > = PerCpuArray :: with_max_entries ( 1 , 0 ) ;
@@ -35,8 +40,8 @@ static SSLREADDATA: PerfEventByteArray = PerfEventByteArray::new(0);
35
40
#[ map] // contains the pointer to the read buffer containing the decrypted data provided by OpenSSL
36
41
// key is the tgid_pid of the process
37
42
// value is the pointer to the read buffer
38
- static mut SSLREADARGSMAP : HashMap < u64 , * const core :: ffi :: c_void > =
39
- HashMap :: < u64 , * const core :: ffi :: c_void > :: with_max_entries ( 1024 , 0 ) ;
43
+ static SSLREADARGSMAP : HashMap < u64 , c_ptr > =
44
+ HashMap :: < u64 , c_ptr > :: with_max_entries ( 1024 , 0 ) ;
40
45
41
46
// Data structures for exchanging SSL_write data with user space
42
47
#[ map]
@@ -48,8 +53,8 @@ static SSLWRITEDATA: PerfEventByteArray = PerfEventByteArray::new(0);
48
53
#[ map] // contains the pointer to the read buffer containing the decrypted data provided by OpenSSL
49
54
// key is the tgid_pid of the process
50
55
// value is the pointer to the read buffer
51
- static mut SSLWRITEARGSMAP : HashMap < u64 , * const core :: ffi :: c_void > =
52
- HashMap :: < u64 , * const core :: ffi :: c_void > :: with_max_entries ( 1024 , 0 ) ;
56
+ static SSLWRITEARGSMAP : HashMap < u64 , c_ptr > =
57
+ HashMap :: < u64 , c_ptr > :: with_max_entries ( 1024 , 0 ) ;
53
58
54
59
/// This uprobe is triggered when a process calls the SSL_read function.
55
60
/// It stores the address of the buffer containing the unencrypted data under the pid/tgid of the calling process
@@ -62,8 +67,8 @@ pub fn osslreadprobe(ctx: ProbeContext) -> u32 {
62
67
let current_pid_tgid = unsafe { bpf_get_current_pid_tgid ( ) } ;
63
68
64
69
// get the parameter containing the read buffer, cf. https://docs.openssl.org/3.0/man3/SSL_read/, Note: aya starts from 0 (ie Parameter 2 = arg(1))
65
- let buffer_ptr: * const core :: ffi :: c_void = match * & ctx. arg ( 1 ) {
66
- Some ( ptr) => ptr,
70
+ let buffer_ptr: c_ptr = match * & ctx. arg ( 1 ) {
71
+ Some ( ptr) => c_ptr ( ptr) ,
67
72
None => return 0 ,
68
73
} ;
69
74
unsafe {
@@ -111,7 +116,7 @@ pub fn osslreadretprobe(ctx: RetProbeContext) -> u32 {
111
116
output_buf. buf . as_mut_ptr ( ) as * mut core:: ffi:: c_void ,
112
117
ret_value_len as u32
113
118
& ( uprobe_libcall_filter_common:: DATA_BUF_CAPACITY - 1 ) as u32 , // needed by eBPF verifier to be able to ensure that not more than necessary is read
114
- * src_buffer_ptr,
119
+ src_buffer_ptr. 0 ,
115
120
) ;
116
121
117
122
SSLREADDATA . output ( & ctx, & output_buf. buf [ ..ret_value_len as usize ] , 0 ) ;
@@ -143,8 +148,8 @@ pub fn osslwriteprobe(ctx: ProbeContext) -> u32 {
143
148
let current_pid_tgid = unsafe { bpf_get_current_pid_tgid ( ) } ;
144
149
145
150
// get the parameter containing the write buffer, cf. https://docs.openssl.org/3.0/man3/SSL_write/, Note: aya starts from 0 (ie Parameter 2 = arg(1))
146
- let buffer_ptr: * const core :: ffi :: c_void = match * & ctx. arg ( 1 ) {
147
- Some ( ptr) => ptr,
151
+ let buffer_ptr: c_ptr = match * & ctx. arg ( 1 ) {
152
+ Some ( ptr) => c_ptr ( ptr) ,
148
153
None => return 0 ,
149
154
} ;
150
155
unsafe {
@@ -191,7 +196,7 @@ pub fn osslwriteretprobe(ctx: RetProbeContext) -> u32 {
191
196
output_buf. buf . as_mut_ptr ( ) as * mut core:: ffi:: c_void ,
192
197
ret_value_len as u32
193
198
& ( uprobe_libcall_filter_common:: DATA_BUF_CAPACITY - 1 ) as u32 , // needed by eBPF verifier to be able to ensure that not more than necessary is read
194
- * src_buffer_ptr,
199
+ src_buffer_ptr. 0 ,
195
200
) ;
196
201
197
202
SSLWRITEDATA . output ( & ctx, & output_buf. buf [ ..ret_value_len as usize ] , 0 ) ;
0 commit comments