-
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
bpf_probe_read_user returns error (-14) on Android 11, Kernel 4.14, ARM64 #3175
Comments
Small update, I've found out that despite having |
@vadimkotov For user provided |
Hi @yonghong-song, thank you for the reply! Originally kernel 4.14 didn't have it, but I've added using this patch, and I can see it in
|
Hi @vadimkotov
Sorry for my carelessness, I missed the latest ternary operator. |
Hi @ismhong, thank you for pointing to the code!
Unless I'm missing a subtle error here, this means that |
It looks like in my case Does anyone happen to know a pace in BCC's pipeline where |
Found this bit: https://github.com/iovisor/bcc/blob/master/src/cc/frontends/clang/b_frontend_action.cc#L1678 If Since I've only ported over If I comment out
I'll try porting |
Nope, simply porting over
Yet it is visible on
At some point there was a kernel version check in |
Hey folks, I kind of solved it for my specific case with a simple hack which seems to work. Namely, instead of porting over BPF_CALL_3(bpf_probe_read, void *, dst, u32, size, const void *, unsafe_ptr)
{
int ret;
ret = probe_kernel_read(dst, unsafe_ptr, size);
if (unlikely(ret < 0)) {
// Beginning of added code
ret = probe_user_read(dst, unsafe_ptr, size);
if (unlikely(ret < 0))
// end of added code
memset(dst, 0, size);
}
return ret;
} Explanation of the code aboveSince BCC can't see This fixed my issue and now tools like But the fact that this hack worked tells me, that previously BCC couldn't "see" Thanks all who replied to the ticket, it helped me narrow down the issue. |
@vadimkotov Thanks for your explanation. It is a little bit unique since you do manual backports. I think you bcc should work if you remove kernel version check in b_frontend_action.cc. But you above kernel change should work too. The reason with in the newer implementation of probe_kernel_read, it will check address space, if it belongs to user space, it will return failure. That is why probe_kernel_read should work in earlier kernel versions, but it will return failure in later kernels if address space belongs to user space. |
same problem on Debian9 kernel 4.19 amd64 |
change to use bpf_probe_read_str ,same result
|
Could you share what exactly the problem is? A reproducible code is the best so people here can really help you. |
I record my questions here, The problem is not resolved. |
@davemarchevsky could you help take a look? |
Thank you for your patience, I submitted the demo code, and there will be problems if I run it directly. https://github.com/hz-kelpie/bpf-demo/tree/main/tracepoint-execve |
@hz-kelpie Could you try explicitly using Aside from that, I can help more directly if you modify the BPF program in your example such that I can load/attach it with |
Thank you,you gave me hope again |
execsnoop.py can work fine, But I can't use bcc for production environment limit |
The linked demo is using a go linker/loader and userspace component which I
don't have any experience with. If you could make some small changes to
your program such that I could load it using `bpftool`?
execsnoop.py can work fine, But I can't use bcc for production
environment limit
There is an `execsnoop` in `libbpf-tools` directory which uses plain
libbpf, could you try comparing that functionality to yours in your env?
…On Sat, Sep 18, 2021 at 5:26 AM hz-kelpie ***@***.***> wrote:
https://github.com/hz-kelpie/bpf-demo/tree/main/tracepoint-execve
@hz-kelpie <https://github.com/hz-kelpie> Could you try explicitly using
bpf_probe_read_user and bpf_probe_read_user_str in your arg loop? If that
doesn't work, could you try running the execsnoop.py tool from this repo
<https://github.com/iovisor/bcc/blob/master/tools/execsnoop.py> on your
system to see if it fails similarly?
Aside from that, I can help more directly if you modify the BPF program in
your example such that I can load/attach it with bpftool instead of using
the go wrapper stuff: remove perf buffer, change perf buffer writes to
printk, minimize extraneous stuff. A more fleshed out version of the
example you gave in cilium/ebpf#419
<cilium/ebpf#419> would be ideal.
execsnoop.py can work fine, But I can't use bcc for production environment
limit
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3175 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJJYUGSHYONPJQMGLRDA6LUCRLM3ANCNFSM4T3AD3JQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Thank you for your patience, I will make change to my program later, this is my program print
when i use
Clearly, when my program print error log, bpftrace also print blank |
https: //github.com/iovisor/bcc/issues/3175 Change-Id: I1e31fc6d62a32eebfb68f92ec18c362d14439e30
this may caused by MTE(Memory Tagging Extension) e.g. addr = 0xb400007c81c93f60 after (addr & 0xffffffffff), then bpf_probe_read read success, test from Android 12 kernel 5.10 |
Does this check still exists? I'm running into the same issue where backported helpers do not show in bcc or bpftrace |
Hi folks,
I'm running BCC on Android 11, Kernel 4.14, ARM64 and
bpf_probe_read_user
returns an error (-14). As a result opensnoop returns an empty filename string.I'm aware of #2253 and implemented the solution that supposedly should fix the issue (https://lkml.org/lkml/2019/5/2/1100) to no avail.
#3094 is somewhat related and the solution there looks to be similar to the above (i.e. adding
bpf_probe_read_user
from the later version).Has anyone encountered something like that or knows how can I get more information about the issue?
Cheers,
Vadim
The text was updated successfully, but these errors were encountered: