-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
invalid mem access when navigating struct sock #253
Comments
From bpf verifier point of view, for the code: int kretprobe__tcp_v4_connect(struct pt_regs _ctx) After "skp = *skpp", skp becomes an unknown value since the verifier has no idea of I guess in this case that bcc rewriter could automatically convert the skp->__sk_common.sdk_addr to a bpf_probe_read since it can recognize the map value is dereferenced. |
Yes, I think I know what's missing in the rewriter. Shouldn't be too hard.
|
Thanks; navigating from sk to skc_daddr will likely be common, so would be good to improve. PS, for anyone trying to understand this code... I'm doing it on kretprobe instead of kprobe for two reasons:
|
@brendangregg , for your question above ctx->ax is always 0. On the other hand, ctx->ax=0 in tcp_v4_connect does not mean the syscall "connect" will succeed. In your code, I guess you still want to check ctx->ax. Otherwise, the value you tried to print may not |
I'm trying to implement if (ip_hdr(skb)->protocol!=IPPROTO_TCP)
return 0; and getting a similar error:
This operation seems simple enough but after two inlined function, it expands to a number of derefences. struct iphdr *iph = (struct iphdr *)(skb->head + skb->network_header);
if (iph->protocol!=IPPROTO_TCP)
return 0; Which fails with a similar error. The doc for bpf_probe_read says
Why is this case not covered by the compiler? Do I need to use bpf_probe_read for every dereference? |
Here is a program that I thought should work:
But won't run:
It works if I use this instead, in the kretprobe:
Is needing an explicit bpf_probe_read() a bug or is it supposed to be this way? If it is supposed to be this way, then we'll need to document the logic to make it easier to follow...
The text was updated successfully, but these errors were encountered: