Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid indirect read from stack #694

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

Asphaltt
Copy link
Member

Fixes #692

The following verifier log is caused by uninitilized stack variable.

couldn't init manager xxx verifier error:load program: permission denied:
	0: R1=ctx(off=0,imm=0) R10=fp0
	; struct sock *sk = (struct sock *)PT_REGS_PARM1(ctx);
	0: (79) r2 = *(u64 *)(r1 +112)        ; R1=ctx(off=0,imm=0) R2_w=scalar()
	1: (b7) r3 = 1                        ; R3_w=1
	; conn.is_destroy = 1;
	2: (73) *(u8 *)(r10 -8) = r3          ; R3_w=1 R10=fp0 fp-8=1
	; conn.sock = (u64)sk;
	3: (7b) *(u64 *)(r10 -16) = r2        ; R2_w=scalar() R10=fp0 fp-16_w=mmmmmmmm
	4: (bf) r4 = r10                      ; R4_w=fp0 R10=fp0
	;
	5: (07) r4 += -64                     ; R4_w=fp-64
	; bpf_perf_event_output(ctx, &connect_events, BPF_F_CURRENT_CPU, &conn,
	6: (18) r2 = 0xffff8dd41e9c0000       ; R2_w=map_ptr(off=0,ks=4,vs=4,imm=0)
	8: (18) r3 = 0xffffffff               ; R3_w=4294967295
	10: (b7) r5 = 64                      ; R5_w=64
	11: (85) call bpf_perf_event_output#25
	invalid indirect read from stack R4 off -64+0 size 64
	processed 10 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0

The following verifier log is caused by uninitilized stack variable.

```log
couldn't init manager xxx verifier error:load program: permission denied:
	0: R1=ctx(off=0,imm=0) R10=fp0
	; struct sock *sk = (struct sock *)PT_REGS_PARM1(ctx);
	0: (79) r2 = *(u64 *)(r1 +112)        ; R1=ctx(off=0,imm=0) R2_w=scalar()
	1: (b7) r3 = 1                        ; R3_w=1
	; conn.is_destroy = 1;
	2: (73) *(u8 *)(r10 -8) = r3          ; R3_w=1 R10=fp0 fp-8=1
	; conn.sock = (u64)sk;
	3: (7b) *(u64 *)(r10 -16) = r2        ; R2_w=scalar() R10=fp0 fp-16_w=mmmmmmmm
	4: (bf) r4 = r10                      ; R4_w=fp0 R10=fp0
	;
	5: (07) r4 += -64                     ; R4_w=fp-64
	; bpf_perf_event_output(ctx, &connect_events, BPF_F_CURRENT_CPU, &conn,
	6: (18) r2 = 0xffff8dd41e9c0000       ; R2_w=map_ptr(off=0,ks=4,vs=4,imm=0)
	8: (18) r3 = 0xffffffff               ; R3_w=4294967295
	10: (b7) r5 = 64                      ; R5_w=64
	11: (85) call bpf_perf_event_output#25
	invalid indirect read from stack R4 off -64+0 size 64
	processed 10 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
```

Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
@Asphaltt Asphaltt force-pushed the fix/stack-indirect-access branch from b4bf74d to 5a1549e Compare December 17, 2024 15:09
@cfc4n cfc4n added 🐞 bug Something isn't working fix bug fix PR labels Dec 17, 2024
Copy link
Member

@cfc4n cfc4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thanks.

@cfc4n cfc4n merged commit 782e437 into gojue:master Dec 17, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working fix bug fix PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v0.9.0 run failed with verifier error: invalid indirect read from stack R4 off -64+0 size 64
2 participants