Skip to content

Commit

Permalink
fix(capture): remove CONFIG_KALLSYMS_ALL dependency (#3381)
Browse files Browse the repository at this point in the history
Change symbols used to identify a pipe to be from the text section
instead of data section.
This way, kernels compiled with CONFIG_KALLSYMS but without
CONFIG_KALLSYMS_ALL will be supported by the capture programs.
  • Loading branch information
AlonZivony committed Aug 14, 2023
1 parent a8ddb7e commit fc8d363
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/ebpf/c/common/ksymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ statfunc void *get_etext_addr()
statfunc struct pipe_inode_info *get_file_pipe_info(struct file *file)
{
struct pipe_inode_info *pipe = BPF_CORE_READ(file, private_data);
char pipe_fops_sym[14] = "pipefifo_fops";
char pipe_write_sym[11] = "pipe_write";
void *file_write_iter_op = BPF_CORE_READ(file, f_op, write_iter);

if (BPF_CORE_READ(file, f_op) != get_symbol_addr(pipe_fops_sym))
if (file_write_iter_op != get_symbol_addr(pipe_write_sym))
return NULL;

return pipe;
Expand Down
6 changes: 6 additions & 0 deletions pkg/ebpf/c/vmlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,15 @@ typedef unsigned int fmode_t;

struct dir_context {
};
struct iov_iter {
};
struct kiocb {
};

struct file_operations {
int (*iterate_shared)(struct file *, struct dir_context *);
int (*iterate)(struct file *, struct dir_context *);
long (*write_iter)(struct kiocb *, struct iov_iter *);
};

struct file {
Expand Down
6 changes: 3 additions & 3 deletions pkg/events/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -9629,7 +9629,7 @@ var CoreEvents = map[ID]Definition{
{handle: probes.DoSpliceRet, required: true},
},
kSymbols: []KSymbol{
{symbol: "pipefifo_fops", required: true},
{symbol: "pipe_write", required: true},
},
},
params: []trace.ArgMeta{
Expand Down Expand Up @@ -9982,7 +9982,7 @@ var CoreEvents = map[ID]Definition{
{"prog_array", "send_bin", []uint32{TailSendBin}},
},
kSymbols: []KSymbol{
{symbol: "pipefifo_fops", required: true},
{symbol: "pipe_write", required: true},
},
},
},
Expand All @@ -10004,7 +10004,7 @@ var CoreEvents = map[ID]Definition{
{"prog_array", "send_bin", []uint32{TailSendBin}},
},
kSymbols: []KSymbol{
{symbol: "pipefifo_fops", required: true},
{symbol: "pipe_write", required: true},
},
},
},
Expand Down

0 comments on commit fc8d363

Please sign in to comment.