Skip to content

Commit 2291f61

Browse files
ovalentiStringy
authored andcommitted
ROX-31971: Fix verifier issues with clang > 19 (#96)
* Adapt the modern probe to clang 21 The code generated by clang 21 is more 'complex' and reaches 1000000 instructions on execve(). * Force casting size(r2) parameter to bpf_probe_read_user() ...otherwise, the compiler thinks that the calling convention allows to optimize unsigned truncation, a the verifier disagrees. * Decrease MAX_IOVCNT to satisfy the verifier on rhel
1 parent d1a708b commit 2291f61

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

driver/modern_bpf/helpers/base/push_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static __always_inline uint16_t push__charbuf(uint8_t *data,
262262
static __always_inline uint16_t push__bytebuf(uint8_t *data,
263263
uint64_t *payload_pos,
264264
unsigned long bytebuf_pointer,
265-
uint16_t len_to_read,
265+
volatile uint16_t len_to_read,
266266
enum read_memory mem) {
267267
if(mem == KERNEL) {
268268
if(bpf_probe_read_kernel(&data[SAFE_ACCESS(*payload_pos)],

driver/modern_bpf/helpers/base/shared_size.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define MAX_UNIX_SOCKET_PATH 108 + 1
2525

2626
/* Maximum number of `iovec` structures that we can analyze. */
27-
#define MAX_IOVCNT 32
27+
#define MAX_IOVCNT 16
2828

2929
/* Maximum number of supported sendmmsg/recvmmsg loops with bpf_loop helper */
3030
#define MAX_SENDMMSG_RECVMMSG_SIZE 16

driver/modern_bpf/programs/attached/events/sched_process_exit.bpf.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ static __always_inline pid_t find_new_reaper_pid(struct task_struct *father) {
103103
*/
104104
uint8_t cnt = 0;
105105

106+
// ROX-31971: some verifiers fail to interpret the end condition and loop infinitely.
107+
#pragma unroll
106108
for(struct task_struct *possible_reaper = READ_TASK_FIELD(father, real_parent);
107109
cnt < MAX_HIERARCHY_TRAVERSE;
108110
possible_reaper = BPF_CORE_READ(possible_reaper, real_parent)) {

driver/modern_bpf/programs/tail_called/events/syscall_dispatched_events/execve.bpf.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ int BPF_PROG(execve_x, struct pt_regs *regs, long ret) {
6464
total_args_len - exe_arg_len,
6565
MAX_PROC_ARG_ENV - exe_arg_len);
6666
} else {
67-
unsigned long argv = extract__syscall_argument(regs, 1);
68-
69-
/* Parameter 2: exe (type: PT_CHARBUF) */
70-
/* Parameter 3: args (type: PT_CHARBUFARRAY) */
71-
auxmap__store_exe_args_failure(auxmap, (char **)argv);
67+
// ROX-31971: this branch makes the verifier overflow, skip this case.
68+
return 0;
7269
}
7370

7471
/* Parameter 4: tid (type: PT_PID) */

0 commit comments

Comments
 (0)