Skip to content

Commit 0aacbba

Browse files
Stringyclaude
andcommitted
Fix remaining BPF verifier failures
1. Mask ret with & 0xFFFF in recvfrom_x, recvmsg_x, and sendmsg_x. The BPF verifier on older kernels rejects bpf_probe_read_user calls where the size argument (ret) could be negative. The mask bounds the value for the verifier. Only applied to programs collector subscribes to (kSendRecvSyscalls) — other programs with this pattern are already excluded via MODERN_BPF_EXCLUDE_PROGS. 2. Stub out t1_execveat_x and t2_execveat_x with #if 0 (ROX-31971). Collector does not subscribe to execveat, but these programs are compiled into the skeleton and verified during load. Their complexity exceeded the 1M instruction verifier limit on RHCOS 4.16/4.18 and RHEL SAP 9.4. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d63a342 commit 0aacbba

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ int BPF_PROG(execveat_x, struct pt_regs *regs, long ret) {
131131

132132
SEC("tp_btf/sys_exit")
133133
int BPF_PROG(t1_execveat_x, struct pt_regs *regs, long ret) {
134+
/* ROX-31971: This tail call contributes to exceeding the BPF verifier's
135+
* 1M instruction limit on some kernels (e.g. RHCOS 4.16, RHEL SAP 9.4).
136+
* Collector does not subscribe to execveat, so this code is not needed.
137+
* Kept as a stub so the program symbol exists in the skeleton.
138+
*/
139+
#if 0
134140
struct auxiliary_map *auxmap = auxmap__get();
135141
if(!auxmap) {
136142
return 0;
@@ -254,11 +260,14 @@ int BPF_PROG(t1_execveat_x, struct pt_regs *regs, long ret) {
254260
/*=============================== COLLECT PARAMETERS ===========================*/
255261

256262
bpf_tail_call(ctx, &syscall_exit_extra_tail_table, T2_EXECVEAT_X);
263+
#endif
257264
return 0;
258265
}
259266

260267
SEC("tp_btf/sys_exit")
261268
int BPF_PROG(t2_execveat_x, struct pt_regs *regs, long ret) {
269+
/* ROX-31971: See comment on t1_execveat_x above. */
270+
#if 0
262271
struct auxiliary_map *auxmap = auxmap__get();
263272
if(!auxmap) {
264273
return 0;
@@ -289,6 +298,7 @@ int BPF_PROG(t2_execveat_x, struct pt_regs *regs, long ret) {
289298
auxmap__finalize_event_header(auxmap);
290299

291300
auxmap__submit_event(auxmap);
301+
#endif
292302
return 0;
293303
}
294304

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int BPF_PROG(recvfrom_x, struct pt_regs *regs, long ret) {
4242
uint16_t snaplen = maps__get_snaplen();
4343
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
4444
if(snaplen > ret) {
45-
snaplen = ret;
45+
snaplen = ret & 0xFFFF;
4646
}
4747

4848
/* Parameter 2: data (type: PT_BYTEBUF) */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int BPF_PROG(recvmsg_x, struct pt_regs *regs, long ret) {
4646
uint16_t snaplen = maps__get_snaplen();
4747
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
4848
if(snaplen > ret) {
49-
snaplen = ret;
49+
snaplen = ret & 0xFFFF;
5050
}
5151

5252
/* Parameter 3: data (type: PT_BYTEBUF) */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int BPF_PROG(sendmsg_x, struct pt_regs *regs, long ret) {
5959
};
6060
apply_dynamic_snaplen(regs, &snaplen, &snaplen_args);
6161
if(ret > 0 && snaplen > ret) {
62-
snaplen = ret;
62+
snaplen = ret & 0xFFFF;
6363
}
6464

6565
unsigned long iov_pointer = (unsigned long)msghdr.msg_iov;

0 commit comments

Comments
 (0)