Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #44 from vmware/dbozzuto-adjust-kernel-read
Browse files Browse the repository at this point in the history
Remove kernel 5.5 gating around bpf_probe_read_str
  • Loading branch information
dbozzuto authored Mar 2, 2021
2 parents 0d36c78 + 9a97e9d commit 6c8dc76
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/bcc_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@
// while the old version returns 0 on success. Some of the logic we use does depend on the non-zero result
// (described later).
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
#define bpf_probe_read_kernel_str bpf_probe_read
#define bpf_probe_read_str bpf_probe_read
#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0)
#define bpf_probe_read_kernel_str bpf_probe_read_str
#endif
#endif

Expand Down Expand Up @@ -379,11 +376,11 @@ static inline void __set_key_entry_data(struct data_t *data, struct file *file)

static u8 __submit_arg(struct pt_regs *ctx, void *ptr, struct data_t *data)
{
// Note: On some kernels bpf_probe_read_kernel_str does not exist. In this case it is
// Note: On some kernels bpf_probe_read_str does not exist. In this case it is
// substituted by bpf_probe_read. The return value for these two cases mean something
// different, but that is OK for our logic.
// Note: On older kernel this may read past the actual arg list into the env.
u8 result = bpf_probe_read_kernel_str(data->fname, MAX_FNAME, ptr);
u8 result = bpf_probe_read_str(data->fname, MAX_FNAME, ptr);
events.perf_submit(ctx, data, sizeof(struct data_t));
return result;
}
Expand Down

0 comments on commit 6c8dc76

Please sign in to comment.