Skip to content

Commit 95f0271

Browse files
committed
feat: latest aya and edition 2024
1 parent 9f7c1f2 commit 95f0271

File tree

6 files changed

+27
-22
lines changed

6 files changed

+27
-22
lines changed

conf/uprobe-libcall-filter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
applications:
22
filter:
33
openssl3.2:
4-
openssl_lib: "/lib64/glibc-hwcaps/x86-64-v3/libssl.so.3.2.3"
4+
openssl_lib: "/lib64/glibc-hwcaps/x86-64-v3/libssl.so.3.2.4"
55

uprobe-libcall-filter/uprobe-libcall-filter-app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "uprobe-libcall-filter-app"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

uprobe-libcall-filter/uprobe-libcall-filter-app/src/main.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,39 @@ async fn main() -> Result<(), anyhow::Error> {
6262
bpf.program_mut("osslreadprobe").unwrap().try_into()?;
6363
program_ossreadprobe.load()?;
6464
program_ossreadprobe.attach(
65-
Some("SSL_read"),
66-
0,
65+
"SSL_read",
6766
&application_definition.openssl_lib,
6867
None,
68+
None,
6969
)?;
7070

7171
let program_ossreadprobe_ret: &mut UProbe =
7272
bpf.program_mut("osslreadretprobe").unwrap().try_into()?;
7373
program_ossreadprobe_ret.load()?;
7474
program_ossreadprobe_ret.attach(
75-
Some("SSL_read"),
76-
0,
75+
"SSL_read",
7776
&application_definition.openssl_lib,
7877
None,
78+
None,
7979
)?;
8080
// attach probes for write
8181
let program_osswriteprobe: &mut UProbe =
8282
bpf.program_mut("osslwriteprobe").unwrap().try_into()?;
8383
program_osswriteprobe.load()?;
8484
program_osswriteprobe.attach(
85-
Some("SSL_write"),
86-
0,
85+
"SSL_write",
8786
&application_definition.openssl_lib,
8887
None,
88+
None,
8989
)?;
9090
let program_osswriteprobe_ret: &mut UProbe =
9191
bpf.program_mut("osslwriteretprobe").unwrap().try_into()?;
9292
program_osswriteprobe_ret.load()?;
9393
program_osswriteprobe_ret.attach(
94-
Some("SSL_write"),
95-
0,
94+
"SSL_write",
9695
&application_definition.openssl_lib,
9796
None,
97+
None,
9898
)?;
9999
}
100100
}

uprobe-libcall-filter/uprobe-libcall-filter-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "uprobe-libcall-filter-common"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

uprobe-libcall-filter/uprobe-libcall-filter-ebpf/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "uprobe-libcall-filter-ebpf"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

uprobe-libcall-filter/uprobe-libcall-filter-ebpf/src/main.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ pub struct DataBuf {
2525
pub buf: [u8; uprobe_libcall_filter_common::DATA_BUF_CAPACITY],
2626
}
2727

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+
2833
// Data structures for exchanging SSL_read data with user space
2934
#[map]
3035
static SSLREADDATABUF: PerCpuArray<DataBuf> = PerCpuArray::with_max_entries(1, 0);
@@ -35,8 +40,8 @@ static SSLREADDATA: PerfEventByteArray = PerfEventByteArray::new(0);
3540
#[map] // contains the pointer to the read buffer containing the decrypted data provided by OpenSSL
3641
// key is the tgid_pid of the process
3742
// 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);
4045

4146
// Data structures for exchanging SSL_write data with user space
4247
#[map]
@@ -48,8 +53,8 @@ static SSLWRITEDATA: PerfEventByteArray = PerfEventByteArray::new(0);
4853
#[map] // contains the pointer to the read buffer containing the decrypted data provided by OpenSSL
4954
// key is the tgid_pid of the process
5055
// 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);
5358

5459
/// This uprobe is triggered when a process calls the SSL_read function.
5560
/// 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 {
6267
let current_pid_tgid = unsafe { bpf_get_current_pid_tgid() };
6368

6469
// 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),
6772
None => return 0,
6873
};
6974
unsafe {
@@ -111,7 +116,7 @@ pub fn osslreadretprobe(ctx: RetProbeContext) -> u32 {
111116
output_buf.buf.as_mut_ptr() as *mut core::ffi::c_void,
112117
ret_value_len as u32
113118
& (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,
115120
);
116121

117122
SSLREADDATA.output(&ctx, &output_buf.buf[..ret_value_len as usize], 0);
@@ -143,8 +148,8 @@ pub fn osslwriteprobe(ctx: ProbeContext) -> u32 {
143148
let current_pid_tgid = unsafe { bpf_get_current_pid_tgid() };
144149

145150
// 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),
148153
None => return 0,
149154
};
150155
unsafe {
@@ -191,7 +196,7 @@ pub fn osslwriteretprobe(ctx: RetProbeContext) -> u32 {
191196
output_buf.buf.as_mut_ptr() as *mut core::ffi::c_void,
192197
ret_value_len as u32
193198
& (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,
195200
);
196201

197202
SSLWRITEDATA.output(&ctx, &output_buf.buf[..ret_value_len as usize], 0);

0 commit comments

Comments
 (0)