bcc: bpf_probe_read_user returns error (-14) on Android 11, Kernel 4.14, ARM64

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

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 23 (3 by maintainers)

Commits related to this issue

Most upvoted comments

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_probe_read_user I simply expanded bpf_probe_read function (from kernel/trace/bpf_trace.c), so that it looks like this:

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 above

Since BCC can’t see bpf_probe_read_[user|kernel] when I port them manually, I tried a different idea. I know that in absence of bpf_probe_read_[user|kernel] BCC would fall back to bpf_probe_read. So I changed bpf_probe_read so that if probe_kernel_read fails try reading unsafe_ptr as a user space pointer (i.e. call probe_user_read).

This fixed my issue and now tools like opensnoop display the path correctly.

But the fact that this hack worked tells me, that previously BCC couldn’t “see” bpf_probe_read_[user|kernel] despite them being available in the kernel. I don’t know if this is something that BCC developers would consider worth fixing so I’m leaving this ticket open for now. Otherwise please feel free to close this ticket. If you have any more questions about the issue or the “fix” I’ll be happy to help.

Thanks all who replied to the ticket, it helped me narrow down the issue.